perf(sessions): skip codex rescans for unchanged rollouts - #2786
Merged
Merged
Conversation
An unchanged resumed rollout rebuilt its prior context by re-reading the file up to its cursor, and resolved its scope matcher (a git spawn) on every pass, even though it admitted no frame. Past 512 rollouts the prior-context cache thrashed, so every pass re-read every rollout. Rebuild prior context only when the scan has a frame, and resolve the scope matcher lazily on the first frame that consults it.
|
This was referenced Oct 1, 2026
Open
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.
Refs #2658, #2521.
Cause
Every history pass, each unchanged resumed Codex rollout:
CodexContextState::scan_prior), even when the scan had no frame. The prior-context cache holds 512 rollouts, so past that every pass re-read every rollout;ProjectRootMatcher(a git spawn) for its scope, even when no frame consulted it.Change
Evidence
Test
an_unchanged_resumed_rollout_does_not_rebuild_its_prior_context(sessions lib):Isolated hotpath daemon on the 8× store (about 60.6k messages; 120 streamed messages per window, 183 ingested):
matcher_newscan_priorFor comparison, the base store (about 7.6k messages) reads 2.48 MB / 2.05 MB per message.
Suites:
clippy
-D warningsand fmt are clean.