GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(server): scan checkpoint ls-files output by record, not by byte by hieu-lee · Pull Request #26687 · pingdotgg/t3code

Conversation

@hieu-lee

@hieu-lee hieu-lee commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Every turn-end checkpoint capture streams git ls-files --full-name --sparse -v -z for the whole repository through an onStdoutChunk callback, which looped over every byte in JS with for…of. On large repositories this blocks the server event loop for tens of milliseconds per turn.

The callback now jumps between NUL record terminators with Uint8Array.indexOf, checks only the tag byte at the start of each record, and copies record bytes only for skipped (S) records under sparse checkout. Parser state still carries across chunks, so records split between chunks behave as before. specialFlags and skippedPaths come out the same.

Measurements

Harness: the old and new callbacks copied verbatim into a scratch module and fed identical 64 KiB chunks of ls-files -v -z output. 5 warmup rounds, then 9 interleaved runs per implementation, median reported. --expose-gc --max-semi-space-size=512 so heapUsed deltas track allocation. Node 24.18, macOS (Apple Silicon).

Input Before After
Real repo (this checkout, 28,875 files, 2.1 MB) 10.19 ms 0.93 ms (11x)
Synthetic 100k files, 4.8 MB 21.4 ms, 15.7 MB heap 2.7 ms, 13 KB heap
Synthetic 300k files, 14.5 MB 61.8 ms 7.0 ms

What limits the new number: native indexOf scanning for NUL across the buffer, which is memory bandwidth bound. The JS work is now one tag check per record.

Benchmark script (real repo)
// lsfiles.mjs exports oldScanner/newScanner: the old and new callback bodies verbatim.
import { spawnSync } from "node:child_process";
import { oldScanner, newScanner } from "./lsfiles.mjs";
const cwd = process.argv[2];
const out = spawnSync("git", ["ls-files", "--full-name", "--sparse", "-v", "-z"], { cwd, maxBuffer: 1 << 30 }).stdout;
const chunks = []; for (let o = 0; o < out.length; o += 65536) chunks.push(out.subarray(o, o + 65536));
const run = (make) => { const s = make(false); for (const c of chunks) s.onStdoutChunk(c); return s.result(); };
for (let w = 0; w < 5; w++) { run(oldScanner); run(newScanner); }
const t = { old: [], new: [] }, a = { old: [], new: [] };
for (let k = 0; k < 9; k++) for (const [n, m] of [["old", oldScanner], ["new", newScanner]]) {
  gc(); const h = process.memoryUsage().heapUsed; const t0 = performance.now(); run(m);
  t[n].push(performance.now() - t0); a[n].push(process.memoryUsage().heapUsed - h);
}
const med = (x) => x.toSorted((p, q) => p - q)[x.length >> 1];
for (const n of ["old", "new"]) console.log(n, med(t[n]).toFixed(2), "ms", med(a[n]), "B heap");

Validation

  • GitVcsDriver.test.ts: 56/56 pass, including the existing sparse, skip-worktree, assume-unchanged, and split-record capture cases. (With my global git config, one unrelated remote-URL test fails because of a url.insteadOf rewrite. It passes with GIT_CONFIG_GLOBAL=/dev/null.)
  • Differential fuzz, old vs new: 20,000 random byte streams × sparse on/off, random 1–6 byte chunk splits, empty records, invalid UTF-8, trailing /, lowercase/S/H tags, missing final NUL. Identical specialFlags and skippedPaths every time.
  • vp run check:changed: format, lint, knip, and typecheck pass.

Not checked: Windows. The change is pure byte scanning, so nothing platform-specific is involved.

Authored with Claude Opus 5.5 via the Claude Code harness in T3 Code.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hieu-lee @claude
perf(server): scan checkpoint ls-files output by record, not by byte
988e364
Every checkpoint capture streams `git ls-files -v -z` for the whole
repository and inspected each byte in JS. Jump between NUL terminators
with indexOf and look only at each record's tag byte instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 28, 2026
macroscopeapp[bot]
macroscopeapp Bot approved these changes Oct 28, 2026
View reviewed changes
@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 988e364

Macroscope's review found this PR approvable — Checkpoint capture now scans Git output by NUL-delimited record to reduce processing overhead in large repositories. The change retains existing sparse-checkout handling and temporary-index safeguards without changing product defaults.

You can add or adjust custom eligibility rules. Learn more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: pingdotgg/t3code
  • Branch: main
  • File: .coderabbit.config.ts
  • Commit: 9826dbb
  • Layers: Repository TS config
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67786b8d-49ad-4498-a110-bcaa5e143db2
Commits

Reviewing files that changed from the base of the PR and between 9826dbb and 988e364.

Files selected for processing: 1
  • apps/server/src/vcs/GitVcsDriver.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The checkpoint index scan now uses indexOf to locate NUL delimiters. It retains checks for special index flags, collection of sparse-checkout skipped paths, and detection of non-UTF-8 paths.

Changes: Git index scan

Layer / File(s) Summary
Scan NUL-delimited index records
apps/server/src/vcs/GitVcsDriver.ts
The stdout scan uses indexOf to advance between NUL-delimited records. It retains special-flag checks and sparse-checkout skipped-record byte collection.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 988e3

No merge-blocking issue was found in the checkpoint scan update.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description covers the problem (per-byte JS loop blocking the event loop on large repos), the change (indexOf-based NUL scanning, tag-byte check, sparse skipped-record copy), measurements, and val… Add the 'Scope and approval' section. Link the triaged bug issue or the discussion with the maintainer approval comment. If no issue exists, explain why this focused perf fix qualifies as a very small, obvious change under the template's ex…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title names the main change: the checkpoint ls-files output scan now steps between NUL records instead of checking every byte. It uses the conventional commit format and matches the raw summary an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the checkpoint ls-files output scan now steps between NUL records instead of checking every byte. It uses the conventional commit format and matches the raw summary and objectives. It is 68 characters, which is within a normal title length.

Full details: Description check

Explanation

The description covers the problem (per-byte JS loop blocking the event loop on large repos), the change (indexOf-based NUL scanning, tag-byte check, sparse skipped-record copy), measurements, and validation. It follows the template's Problem, Change, and Verification intent. The 'Scope and approval' section is missing: it has no linked triaged issue or maintainer-approved discussion, and no explanation of why the change qualifies without one. The Verification section is strong, and it names the test run, fuzzing, and the unchecked Windows case.

Resolution

Add the 'Scope and approval' section. Link the triaged bug issue or the discussion with the maintainer approval comment. If no issue exists, explain why this focused perf fix qualifies as a very small, obvious change under the template's exemption. The rest of the description can stay as written. The template also asks for the model and harness used, and the description already includes this.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hieu-lee

hieu-lee commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@juliusmarminge ready for review. Checkpoint capture's ls-files -v -z scan went from 10.2 ms to 0.93 ms on a real 28.9k-file repo (about 11x), with a differential fuzz against the old scan. Related to #21328 and #9661 S3 only in touching the same capture path; it does not change what git re-hashes. CI workflows on this fork PR show action_required, so they are waiting on a maintainer to approve the run. CodeRabbit and Macroscope are done with no open findings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 28, 2026
Track performance audit fixes #9661
Closed
[Bug]: New worktrees stay racily clean, so every checkpoint capture and status refresh re-hashes the whole checkout (2 s instead of 0.2 s on t3code) #21328
Closed
@t3dotgg

t3dotgg commented Oct 31, 2026

Copy link
Copy Markdown
Member

Note

🤖 Claude Opus 5.5 responding on behalf of Theo

Closing: this is covered by #21329, which landed. Reopen if a needed part is still missing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@t3dotgg t3dotgg closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@macroscopeapp macroscopeapp[bot] macroscopeapp[bot] approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@hieu-lee @t3dotgg
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.