Repository navigation
feat: an option to turn off the persistence of the session pool - #28
Merged
Merged
Conversation
`SessionPoolOptions::persistence_enabled` (default `true`) is the counterpart of `sessionPoolOptions.persistenceOptions.enable` in Crawlee for JS. Off, the crawler neither restores the pool from its saved state when the crawl starts nor saves it, on `PersistState` events or at the end: no key-value store read, no listener, no write. For crawlers whose sessions only keep HTTP clients and their connections, saving the pool every minute is wasted work, and serializing it costs memory: a few MB at a time for a full pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
SessionPoolOptions::persistence_enabled(defaulttrue), the counterpart ofsessionPoolOptions.persistenceOptions.enablein Crawlee for JS. When it is off, the crawler doesn't restore the pool fromCRAWLEE_SESSION_POOL_STATE_{id}and never saves it. That means no key-value store read at start, noPersistStatelistener and no write at the end. The crawler takes the setting from the pool, so it also applies to a pool passed in with.session_pool(...).Why: some scrapers use sessions only to keep HTTP clients and their connections alive, and saving the pool for them is wasted work. A heap profile showed that serializing a full pool (
to_record) costs about 7 MB at a time, every ~60 s. google-maps-rs needs this because the JS Actor it ports setspersistenceOptions: { enable: false }.The new crawler tests cover both cases. By default, a saved pool is restored and then written over. With the option off, it is neither restored nor written, even after
PersistStateevents.Generated by Claude Code