openclaw/scripts/lib/benchmark-interval-delay.ts
Peter Steinberger f9dc685d71
improve: keep large workspace transfers responsive (#147626)
* perf(workspace): offload inventory and manifest processing

Keep the Gateway and paired nodes responsive during large workspace transfers with bounded computation workers. Hosts retain session authority, Git processes, file writes, durable acceptance, and cleanup.

Use transferable UTF-8 payloads for supported Unicode inventories, preserve independent errors during cancellation, and compare already-decoded manifests without copying their object graphs between threads.

* test(workspace): finish manifest fixture ownership

* refactor(workspace): distinguish stage input implementation

* test: register workspace benchmark and honor system Bash
2026-09-13 19:35:25 -07:00

18 lines
565 B
TypeScript

import { performance } from "node:perf_hooks";
/** Timer drift also captures work that blocks before the native histogram's first poll. */
export function startBenchmarkIntervalDelay(): () => number[] {
const intervalMs = 10;
const samples: number[] = [];
let previousTick = performance.now();
const timer = setInterval(() => {
const now = performance.now();
samples.push(Math.max(0, now - previousTick - intervalMs));
previousTick = now;
}, intervalMs);
timer.unref();
return () => {
clearInterval(timer);
return samples;
};
}