Skip to content

fix(core): stop scanning handled requests in the in-memory request queue - #4083

Open
vladfrangu wants to merge 2 commits into
masterfrom
fix/memory-rq-handled-scan
Open

fix(core): stop scanning handled requests in the in-memory request queue#4083
vladfrangu wants to merge 2 commits into
masterfrom
fix/memory-rq-handled-scan

Conversation

@vladfrangu

@vladfrangu vladfrangu commented Aug 29, 2026

Copy link
Copy Markdown
Member

The in-memory request queue kept handled requests in the same Map it walked on every head scan, so fetchNextRequest, isEmpty and isFinished were O(handled) per call and draining a queue was O(N²). With 450k handled requests each call took ~200ms (~1.4s per add/fetch/handle cycle), the in-memory counterpart of #2406.

Handled requests now stay in requests for deduplication only; a separate insertion-ordered pendingRequestIds set holds the unhandled ids and is what the head scan iterates. Ordering is unchanged, since the set mirrors the map's insertion order for those ids.

Closes #2406 — the file-system backend is no longer affected either, since the Rust @crawlee/fs-storage-native client only scans the directory once on open().

[🤖] Claude Code using Fable 5

@github-actions github-actions Bot added this to the 148th sprint - Tooling team milestone Aug 29, 2026
@github-actions github-actions Bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Aug 29, 2026
@vladfrangu
vladfrangu requested review from B4nan and janbuchar August 29, 2026 11:47

@janbuchar janbuchar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The request queue scans all 450k (99.999% of which are done towards the end) requests for each iteration

3 participants