Repository navigation
perf(extraction): read the next file batch while the current one is dispatched - #496
Merged
Merged
Conversation
…ispatched Parse-loop time falls 3-4% on supabase and n8n (4 runs per build, ranges not overlapping). Whole-index wall time is within the run-to-run variation on all five measured projects. Graph fingerprints are identical and peak memory is within 1%.
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
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.
Indexing a large project spends a median 3–4% less time in its parse loop (supabase 5.85 s to 5.67 s, n8n 15.48 s to 14.85 s) because the next batch of files is read while the current one is being parsed. The gain does not reach the whole index time on any project I measured, so this is a small change in one phase, not a faster
init.codegraph init, median of 4 runs per buildPeak memory differs by +0.2% to +0.9% (no clear change), and the node and edge counts plus an md5 of the ordered node and edge rows are identical in every run on every project. Builds
f045e5f7and the same with this change; 40 runs, 0 rejected, order B C C B B C C B per project, declared before the runs. Under the rule I declared there ("land only when whole-index time is clear") this was rejected; I am landing it because the parse-loop gain is real on the two largest projects, nothing got worse beyond noise, and the change is small.What changes
The parse loop read 10 files, waited, then handed them to the parser pool, so the pool sat idle during every read.
readBatchis now a function; the loop starts reading batch n+1 before it dispatches batch n. At most one extra batch of file contents is held in memory (peak memory stayed within 1% in the runs above). The read function is unchanged and never rejects, so an abort in the middle leaves no unhandled error.Checks
Native stack traceorWorker exited unexpectedlyin the raw output.Not covered: why overlapping the read recovers only part of the 6–9% the stage timers allowed (the UTF-8 decode and path validation still run on the main thread); Bun; Windows and macOS.
Summary by cubic
Speeds up indexing by reading the next batch of files while the current batch is being parsed, so the parser pool no longer sits idle during reads. Parse-loop time falls a median 3–4% on large projects (supabase 5.85 s to 5.67 s, n8n 15.48 s to 14.85 s); whole-index time stays within run-to-run variation, graph output is identical, and peak memory stays within 1%. At most one extra batch of file contents is held in memory, and the read function still never rejects.
Written for commit 1cdfdf4. Summary will update on new commits.
Summary by CodeRabbit