Repository navigation
[medium] perf(git-review): key the PR cache through the cached runGit - #639
Merged
Merged
Conversation
getCachedGitReviewData derived its cache key from `git symbolic-ref --short HEAD` (and `rev-parse --short HEAD` when detached) with a bare execFileSync, so every render spawned git once per git-pr / git-ci-status widget even when the PR data itself was a cache hit. The widgets now pass their render context and the ref lookup goes through git.ts's runGit, whose persistent cache (invalidated by HEAD/index mtime) is already shared with the git-branch and git-sha widgets. Without a context (the detached refresh child, fetchGitReviewData) the lookup is unchanged. Measured on a warm render with no refresh due (model, git-branch, git-pr, git-ci-status): 2 git spawns -> 0. bench2 CPU median 1363 -> 1319 ms (-3.3%, 40 passes) and 1443 -> 1375 ms (-4.7%, 30 passes), wall median -12% / -4%, p90 overlapping on this heavily loaded host. stdout is byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
@elhoim Please remove branch protection for all these PRs so I can modify them if needed before squash merging to the main repo. Thanks! |
Contributor
Author
|
@sirmalloc Done - branch protection is removed from all 13 of my open PR branches on elhoim/ccstatusline ("Allow edits by maintainers" was already on), so you can push to them directly. Feel free to modify before squash merging. Thanks! |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 30, 2026
Merged
sirmalloc
pushed a commit
that referenced
this pull request
Nov 5, 2026
…791) With a tag named like the current branch, `git symbolic-ref --short HEAD` prints "heads/<branch>". The refresh child keys the PR cache by the full ref with "refs/heads/" stripped since #774, but the render's lookup through the cached runGit (#639) still used --short. The two then hash to different cache files: the child writes the PR to one, Git PR and Git CI Status read the other, and the widgets show "(no PR)" on every render while a refresh runs again each time its lock goes stale. The child also never releases the lock it was handed, since that lock belongs to the other cache file. The render's lookup now reads `symbolic-ref HEAD` and strips the prefix the same way, which is also the command Git Branch already runs, so the cached runGit answers both. Co-authored-by: effectustasi <216187407+effectustasi@users.noreply.github.com>
This was referenced Nov 7, 2026
Closed
Closed
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.
BLUF
git-pr/git-ci-statuswidget ran on every render.getCachedGitReviewDatabuilt its cache key fromgit symbolic-ref --short HEAD(andrev-parse --short HEADwhen detached) through a bareexecFileSync, even when the PR data itself was a cache hit. The key lookup now goes throughgit.ts's cachedrunGit, which thegit-branch/git-shawidgets already warm.Details
GitPrandGitCiStatusnow pass their rendercontextin the options ofgetCachedGitReviewData.runGit('symbolic-ref --short HEAD', context), falling back torunGit('rev-parse --short HEAD', context). Those are the same commands and the samebranch:/head:/unknownkey as before.runGit's persistent cache is invalidated when the HEAD or index mtime changes, so a checkout or a detached-HEAD commit still re-keys immediately.fetchGitReviewData) nothing changes.deps.runGit) so it can be tested, and falls back to the old path when absent.runGitstill serves the old cached ref (the mtime unchanged), the two sides can disagree once. The child then writes under the live ref and leaves the parent's lock in place, so refreshes for the old key pause until the lock goes stale (30 s). This is the same class of window a branch switch already has between the parent's lookup and the child's.Measurements
Spawn counts (strace, config: model + git-branch + git-pr + git-ci-status,
gitCacheTtlSeconds: 0):symbolic-ref --short HEADRenders that happen to trigger the detached 30 s review refresh also show that child's git calls. Those are unchanged and not counted above.
bench2 (round-robin fork/exec; CPU is user+sys including reaped children; the host was heavily loaded, so compare ratios):
node -e 0Checks
bun tsc --noEmit: clean.bun run lintis left to CI.bun run build: OK.bun test: the new tests (ref viarunGit, detached fallback, same cache or lock path as the uncached lookup) and the updated widget tests pass. The full suite on this very loaded host shows the same timeout-driven failures as unmodifiedmain:fetchUsageData error handling, custom-command capture, and several TUI menu tests. None of them touch this code.git.ts. It only importsrunGit, which [medium] fix(git): stop respawning git outside repos and across session cwds #631 and [medium] perf(jj): detect repos without spawning and cache jj commands #632 both keep exported, so there is no textual conflict with them.git-review-cache.tsand its test file. Its hunks are elsewhere (fetch/negative cache), but its interface addition nearGitReviewDataand its appended tests may need a trivial rebase next to this one.🤖 Generated with Claude Code