GeezerVison is showing github.com — perf(server): checkpoint capture scans the index listing by record in… · incognitojam/styal@bc58367
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 |
|---|
@@ -915,7 +915,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( | 915 | 915 | let specialFlags = false; | 916 | 916 | let recordStart = true; | 917 | 917 | let skipped = false; | 918 | | - let skippedRecord: number[] = []; | | 918 | + let skippedRecord: Uint8Array[] = []; | 919 | 919 | const skippedPaths: string[] = []; | 920 | 920 | yield* vcsProcess.run({ | 921 | 921 | operation, | @@ -925,27 +925,35 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( | 925 | 925 | env: commitEnv, | 926 | 926 | maxOutputBytes: 4_096, | 927 | 927 | outputMode: "truncate", | | 928 | + // Only tags and sparse skip-worktree paths matter; scan NUL-delimited records. | 928 | 929 | onStdoutChunk: (chunk) => { | 929 | | - for (const byte of chunk) { | 930 | | - if (recordStart) skipped = byte === 83; | | 930 | + let start = 0; | | 931 | + while (start < chunk.length) { | | 932 | + const end = chunk.indexOf(0, start); | | 933 | + if (recordStart) { | | 934 | + const tag = chunk[start]!; | | 935 | + skipped = tag === 83; | | 936 | + if ((tag >= 97 && tag <= 122) || (!sparseCheckout && tag === 83)) { | | 937 | + specialFlags = true; | | 938 | + } | | 939 | + } | 931 | 940 | if (skipped && sparseCheckout) { | 932 | | - if (byte !== 0) skippedRecord.push(byte); | 933 | | - else { | 934 | | - if (skippedRecord.at(-1) !== 47) { | 935 | | - const name = Buffer.from(skippedRecord).subarray(2); | | 941 | + skippedRecord.push( | | 942 | + Buffer.from(chunk.subarray(start, end === -1 ? undefined : end)), | | 943 | + ); | | 944 | + if (end !== -1) { | | 945 | + const record = Buffer.concat(skippedRecord); | | 946 | + if (record.at(-1) !== 47) { | | 947 | + const name = record.subarray(2); | 936 | 948 | if (!NodeBuffer.isUtf8(name)) specialFlags = true; | 937 | 949 | else skippedPaths.push(name.toString("utf8")); | 938 | 950 | } | 939 | 951 | skippedRecord = []; | 940 | 952 | } | 941 | 953 | } | 942 | | - if ( | 943 | | - recordStart && | 944 | | - ((byte >= 97 && byte <= 122) || (!sparseCheckout && byte === 83)) | 945 | | - ) { | 946 | | - specialFlags = true; | 947 | | - } | 948 | | - recordStart = byte === 0; | | 954 | + recordStart = end !== -1; | | 955 | + if (!recordStart) break; | | 956 | + start = end + 1; | 949 | 957 | } | 950 | 958 | }, | 951 | 959 | }); | |
|