perf(file-system): Fix quadratic file rescans in the FS request queue#2011
Draft
vdusek wants to merge 1 commit into
Draft
perf(file-system): Fix quadratic file rescans in the FS request queue#2011vdusek wants to merge 1 commit into
vdusek wants to merge 1 commit into
Conversation
BREAKING CHANGE: The file system request queue no longer emits the 'Request <unique_key> not found in state, skipping.' warning. The cache refresh no longer scans the queue directory, so orphaned request files (e.g. written by another process) are silently ignored.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2011 +/- ##
==========================================
+ Coverage 93.35% 93.44% +0.09%
==========================================
Files 179 179
Lines 12482 12467 -15
==========================================
- Hits 11652 11650 -2
+ Misses 830 817 -13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
The file system request queue client was O(n²):
forefront=Trueinvalidated the whole cache, andRequestManagerTandemadds every loader request withforefront=True, which triggered a full rescan per processed request.json.loadran on the event loop.Processing a 10k
RequestListthrough the tandem meant roughly 50M file parses.Changes
_refresh_cachenow derives pending requests from the recoverable state's key→sequence maps and reads only those files, instead of globbing and parsing the whole directory.handled_requestsfor deduplication), so cache refreshes,is_empty, and the persisted state blob scale with the backlog rather than with every request ever processed._parse_request_filereads the file in a singleasyncio.to_threadcall instead of runningjson.loadon the event loop.Results
Processing 200 requests through the tandem pattern went from 20,100 file parses (2.8 s) to 1 (0.3 s), and scaling is now linear (2,000 requests in about 2.6 s). Ordering semantics (forefront LIFO, regular FIFO), deduplication, and crash-recovery behavior are preserved and covered by new regression tests.
Logging changes
The file system request queue no longer emits the
Request <unique_key> not found in state, skipping.warning. The cache refresh no longer scans the queue directory, so orphaned request files (e.g. written by another process) are silently ignored.