Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): scan checkpoint ls-files output by record, not by byte #26687

Closedhieu-lee(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/26687/headopened View on GitHub

Showing 1 changed file with 16 additions and 11 deletions.

x
0 of 1 viewed, 1 left
16 additions and 11 deletionsapps/server/src/vcs/GitVcsDriver.tsModified
View file
@@ -909,12 +909,22 @@
env: commitEnv,
maxOutputBytes: 4_096,
outputMode: "truncate",
+ // Large repositories list every tracked path; jump between NULs instead of visiting each byte.
onStdoutChunk: (chunk) => {
- for (const byte of chunk) {
- if (recordStart) skipped = byte === 83;
+ let index = 0;
+ while (index < chunk.length) {
+ if (recordStart) {
+ const tag = chunk[index]!;
+ skipped = tag === 83;
+ if ((tag >= 97 && tag <= 122) || (!sparseCheckout && skipped)) {
+ specialFlags = true;
+ }
+ }
+ const nul = chunk.indexOf(0, index);
+ const end = nul === -1 ? chunk.length : nul;
if (skipped && sparseCheckout) {
- if (byte !== 0) skippedRecord.push(byte);
- else {
+ for (let byte = index; byte < end; byte += 1) skippedRecord.push(chunk[byte]!);
+ if (nul !== -1) {
if (skippedRecord.at(-1) !== 47) {
const name = Buffer.from(skippedRecord).subarray(2);
if (!NodeBuffer.isUtf8(name)) specialFlags = true;
@@ -923,13 +933,8 @@
skippedRecord = [];