@devries-cameron20 / t3code Mirror · read-only / commits / c6f2b7dbae
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 13:15 UTC

perf(server): checkpoint capture scans the index listing by record instead of by byte (#21329)

Co-authored-by: maria-rcks <maria@kuuro.net>

Joseph Vidal committed Oct 29, 2026 at 13:50 UTC c6f2b7dbae472b1a6ce75bd74bc7071f4c96b789
2 files changed +31 -19
apps/server/src/vcs/GitVcsDriver.test.ts
+9 -5
@@ -682,9 +682,13 @@ it.effect.each(
682 }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
683 );
684
685 -it.effect.each(["normal", "flags", "sparse"] as const)(
686 - "checkpoint index inspection handles entries beyond the output cap (index=%s)",
687 - (indexMode) =>
685 +it.effect.each(
686 + (["normal", "flags", "sparse"] as const).flatMap((indexMode) =>
687 + [1, 3, 4096].map((chunkSize) => ({ indexMode, chunkSize })),
688 + ),
689 +)(
690 + "checkpoint index inspection handles entries beyond the output cap (index=$indexMode, chunk=$chunkSize)",
691 + ({ indexMode, chunkSize }) =>
692 Effect.gen(function* () {
693 const fs = yield* FileSystem.FileSystem;
694 const path = yield* Path.Path;
@@ -720,8 +724,8 @@ it.effect.each(["normal", "flags", "sparse"] as const)(
724 ...input,
725 maxOutputBytes: 8,
726 onStdoutChunk: (chunk) => {
723 - for (let i = 0; i < chunk.length; i++)
724 - input.onStdoutChunk?.(chunk.subarray(i, i + 1));
727 + for (let i = 0; i < chunk.length; i += chunkSize)
728 + input.onStdoutChunk?.(chunk.subarray(i, i + chunkSize));
729 },
730 }
731 : input,
apps/server/src/vcs/GitVcsDriver.ts
+22 -14
@@ -899,7 +899,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
899 let specialFlags = false;
900 let recordStart = true;
901 let skipped = false;
902 - let skippedRecord: number[] = [];
902 + let skippedRecord: Uint8Array[] = [];
903 const skippedPaths: string[] = [];
904 yield* vcsProcess.run({
905 operation,
@@ -909,27 +909,35 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
909 env: commitEnv,
910 maxOutputBytes: 4_096,
911 outputMode: "truncate",
912 + // Only tags and sparse skip-worktree paths matter; scan NUL-delimited records.
913 onStdoutChunk: (chunk) => {
913 - for (const byte of chunk) {
914 - if (recordStart) skipped = byte === 83;
914 + let start = 0;
915 + while (start < chunk.length) {
916 + const end = chunk.indexOf(0, start);
917 + if (recordStart) {
918 + const tag = chunk[start]!;
919 + skipped = tag === 83;
920 + if ((tag >= 97 && tag <= 122) || (!sparseCheckout && tag === 83)) {
921 + specialFlags = true;
922 + }
923 + }
924 if (skipped && sparseCheckout) {
916 - if (byte !== 0) skippedRecord.push(byte);
917 - else {
918 - if (skippedRecord.at(-1) !== 47) {
919 - const name = Buffer.from(skippedRecord).subarray(2);
925 + skippedRecord.push(
926 + Buffer.from(chunk.subarray(start, end === -1 ? undefined : end)),
927 + );
928 + if (end !== -1) {
929 + const record = Buffer.concat(skippedRecord);
930 + if (record.at(-1) !== 47) {
931 + const name = record.subarray(2);
932 if (!NodeBuffer.isUtf8(name)) specialFlags = true;
933 else skippedPaths.push(name.toString("utf8"));
934 }
935 skippedRecord = [];
936 }
937 }
926 - if (
927 - recordStart &&
928 - ((byte >= 97 && byte <= 122) || (!sparseCheckout && byte === 83))
929 - ) {
930 - specialFlags = true;
931 - }
932 - recordStart = byte === 0;
938 + recordStart = end !== -1;
939 + if (!recordStart) break;
940 + start = end + 1;
941 }
942 },
943 });