Keep duplicate-path setup out of the Git filter CI budget (#8753)

* test(server): prepare duplicate paths before measuring Git filtering

* test(server): clarify the observer path preparation boundary

---------

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
paseo-bot[bot]
2026-11-04 12:25:42 +00:00
committed by GitHub
parent cab5eedfe3
commit 0e7f452c2f
@@ -624,7 +624,10 @@ test("Git refresh, command tracing and 10,000 ignored alias events do no synchro
await writeFile(join(worktree, 'ignored', 'noise'), 'noise');
await symlink(worktree, alias, process.platform === 'win32' ? 'junction' : 'dir');
const subscription = await service.requestWorkingTreeWatch(alias, () => { notifications++; });
const events = Array.from({ length: process.env.GIT_IO_TRACE ? 2 : 10000 }, (_, i) => ({ type: 'update', path: join(i % 2 ? alias : worktree, 'ignored', 'noise') }));
// The observer hashes and coalesces paths in a Map before delivery. Reuse
// two prepared strings instead of constructing 10,000 equal-valued strings.
const noisePaths = [join(worktree, 'ignored', 'noise'), join(alias, 'ignored', 'noise')];
const events = Array.from({ length: process.env.GIT_IO_TRACE ? 2 : 10000 }, (_, i) => ({ type: 'update', path: noisePaths[i % 2] }));
let fsCalls = 0;
const hook = createHook({ init(_id, type) { if (type.startsWith('FSREQ')) fsCalls++; } });
// Collect repository setup and event-fixture garbage before measuring
@@ -648,15 +651,18 @@ test("Git refresh, command tracing and 10,000 ignored alias events do no synchro
assert.equal(unrelatedWorkStarted, false, 'control work must not contaminate the cold filter');
hook.enable();
let blockingMs;
let elapsedMs;
let cpu;
try {
// This callback is synchronous: measure its own span, without waiting
// for marker IO, loader messages or other event-loop callbacks.
const startedAt = performance.now();
const startedCpu = threadCpuUsage();
callback(null, events);
const cpu = threadCpuUsage(startedCpu);
cpu = threadCpuUsage(startedCpu);
// Cap coarse Windows CPU accounting by elapsed time; exclude descheduling.
blockingMs = Math.min(performance.now() - startedAt, (cpu.user + cpu.system) / 1000);
elapsedMs = performance.now() - startedAt;
blockingMs = Math.min(elapsedMs, (cpu.user + cpu.system) / 1000);
} finally {
hook.disable();
await marker('FILTER_END');
@@ -665,7 +671,7 @@ test("Git refresh, command tracing and 10,000 ignored alias events do no synchro
assert.equal(unrelatedWorkStarted, true, 'control work must run outside the filter span');
assert.equal(fsCalls, 0, "filesystem calls");
assert.equal(notifications, 0, "ignored event notification");
assert.ok(blockingMs < 20, 'blocking filter work: ' + blockingMs);
assert.ok(blockingMs < 20, 'blocking filter work: ' + JSON.stringify({ blockingMs, elapsedMs, cpu }));
console.log(JSON.stringify({ blockingMs, fsCalls }));
// Alias identity remains useful after deletion: no per-event realpath can recover this file.
callback(null, [{ type: 'delete', path: join(worktree, 'tracked.txt') }]);