fix(core): defer snapshot repository discovery#36290
Merged
Merged
Conversation
Contributor
Author
|
Independent verification confirmed the source cause and benchmark direction.
Caveats: trial blocks were sequential rather than interleaved, real user plugins/MCP/config were active, and the change defers rather than removes discovery, so the first actual snapshot operation pays it. The post-candidate baseline returning to the original range makes the location-readiness win credible despite those confounders. |
kitlangton
force-pushed
the
location-profile
branch
from
July 10, 2026 21:26
aa601b0 to
996f6fa
Compare
This was referenced Jul 19, 2026
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.
Summary
Bottleneck
Per-node acquisition timing identified Snapshot setup as the dominant location-readiness cost during concurrent cold starts:
opencodelife-hubbrowser-controlopenevalexperimentsSnapshot eagerly called
git.repo.discover()and canonicalized the worktree while the location layer was acquired. Most reconnected locations need config/session data immediately but do not perform a snapshot operation.flowchart LR subgraph Before L1[Acquire location] --> G1[Discover Git repository] G1 --> R1[Location ready] end subgraph After L2[Acquire location] --> R2[Location ready] R2 --> C[First snapshot operation] C --> G2[Discover and memoize Git repository] endBenchmark
An isolated Bun harness launched a fresh local server for each trial with temporary database/data/state paths, waited for authenticated health, then measured
/api/locationfor one real repository followed by four concurrent cold repositories. The active managed daemon was never contacted or restarted.Two seven-run baseline series bracketed the candidate run to control for cache warming:
The benchmark used one warmup plus five preliminary measurements, then two warmups plus seven measured A/B runs. Raw spreads were noisy, but both bracketing baselines remained materially slower than every candidate median.
Semantics
The first call to
capture,files,diff,preview,restore, orcheckoutresolves the same repository/worktree state as before.Effect.cachedshares one Location-scope-owned initialization fiber across concurrent and subsequent operations. Acquiring that shared fiber is uninterruptible, while waiting for its result remains interruptible, so cancelling the first caller neither blocks cancellation nor memoizes an interrupted result.When snapshots are disabled,
capturecan now return without performing Git discovery at all.Follow-up
This removes the largest measured node from the reconnect herd in #36285. Remaining measured costs are concurrent project resolution, config discovery, and eager Shell output setup; they should be optimized in separate benchmarked changes.
Verification
bun typecheckfrompackages/core: passedbun run test test/snapshot.test.ts test/session-runner.test.tsfrompackages/core: 121 passed