Repository navigation
perf(server): code snapshots stop re-reading uncommitted files - #1045
Merged
Merged
Conversation
Before each message reaches the agent, Threadlines saves a git snapshot of the checkout. PostHog shows 12% of messages waiting over 5 s on it (nearly all Windows and Linux), and many hitting git's 30 s timeout, after which no snapshot is saved at all. Each snapshot loaded the tree over the cached scratch index with `read-tree -m -i`, which drops every entry the tree lacks, so `git add -A` read and hashed every never-committed file again. A checkpoint now stages over the cache as it is (`stageCheckout`). A cached entry stays only when a cold build would stage it the same way: a tree path when it is the tree's entry, any other file when it is listed under the same name, went in as new (the cache's name records the tree it was staged over), is not a link, and is not under another spelling of a folder. Everything else is read again, so the tree matches a cold build. A failed write after a warm start retries cold. The untracked listing now runs against an index loaded from the tree instead of no index, so git no longer checks every committed file against the ignore rules. Measured on a Windows PC, 100k tracked files plus 3,000 new 50 KB files: `git add` 2,255 -> 141 ms, the listing 1,635 -> 825 ms, same tree. Turn latency telemetry also says whether the snapshot failed to save.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
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.
Before each message reaches the agent, Threadlines saves a git snapshot of the checkout. PostHog shows 12% of messages waiting over 5 s on it, nearly all on Windows and Linux. Many stop at git's 30 s timeout, after which no snapshot is saved at all. Every snapshot re-read and re-hashed every file that was never committed, because loading the tree over the cached index (
read-tree -m -i) drops those entries.A checkpoint now stages over the cached index as it is. A cached entry is kept only when a cold build (
read-tree <tree>+add -A) would stage it the same way:read-tree -mkeeps it), since git reads a changed file's index blob for line endings and keeps modes and submodule commits under some settings;Everything else is dropped and read again, so the snapshot tree matches a cold build. Kept files that an ignore rule added mid-capture now covers are dropped after staging. A failed write after a warm start retries cold. Non-UTF-8 paths take the cold path.
The untracked listing runs against an index loaded from the tree instead of no index, so git no longer checks every committed file against the ignore rules.
Turn latency telemetry also reports whether the snapshot failed to save (
docs/telemetry.mdupdated).Measured on a Windows PC, 100k tracked files plus 3,000 new 50 KB files:
git add2,255 -> 141 ms, listing 1,635 -> 825 ms, same tree id.Not covered: the first snapshot in a new worktree is still cold (9.5 s at 100k files on that PC). Starting it from the worktree's own index was tried and dropped after review: that index can hold blobs from older conversion rules, staged mode or case changes, and assume-unchanged entries.