GeezerVison is showing github.com — perf(server): checkpoint capture scans the index listing by record in… · pingdotgg/t3code@c6f2b7d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriver.test.ts +9-5Lines changed: 9 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -682,9 +682,13 @@ it.effect.each( | 682 | 682 | }).pipe(Effect.scoped, Effect.provide(layerGitContract)), | 683 | 683 | ); | 684 | 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 }) => | 688 | 692 | Effect.gen(function* () { | 689 | 693 | const fs = yield* FileSystem.FileSystem; | 690 | 694 | const path = yield* Path.Path; | @@ -720,8 +724,8 @@ it.effect.each(["normal", "flags", "sparse"] as const)( | 720 | 724 | ...input, | 721 | 725 | maxOutputBytes: 8, | 722 | 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)); | 725 | 729 | }, | 726 | 730 | } | 727 | 731 | : input, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/vcs/GitVcsDriver.ts +22-14Lines changed: 22 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -899,7 +899,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( | 899 | 899 | let specialFlags = false; | 900 | 900 | let recordStart = true; | 901 | 901 | let skipped = false; | 902 | | - let skippedRecord: number[] = []; | | 902 | + let skippedRecord: Uint8Array[] = []; | 903 | 903 | const skippedPaths: string[] = []; | 904 | 904 | yield* vcsProcess.run({ | 905 | 905 | operation, | @@ -909,27 +909,35 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( | 909 | 909 | env: commitEnv, | 910 | 910 | maxOutputBytes: 4_096, | 911 | 911 | outputMode: "truncate", | | 912 | + // Only tags and sparse skip-worktree paths matter; scan NUL-delimited records. | 912 | 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 | + } | 915 | 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); | 920 | 932 | if (!NodeBuffer.isUtf8(name)) specialFlags = true; | 921 | 933 | else skippedPaths.push(name.toString("utf8")); | 922 | 934 | } | 923 | 935 | skippedRecord = []; | 924 | 936 | } | 925 | 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; | 933 | 941 | } | 934 | 942 | }, | 935 | 943 | }); | |
|