Repository navigation
feat: run each analysis benchmark in its own process - #122
not-matthias wants to merge 3 commits into
Conversation
Merging this PR will degrade performance by 18.44%3 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Benchmarks measured in one process share allocator, JIT, and heap state, so a benchmark's simulation or memory result depends on the ones that ran before it. Walltime runs already run every benchmark in fresh processes. Add `analysisIsolation()`, which reads the same environment as `walltimeIsolation()` but always uses one fork per benchmark: analysis measures a benchmark once, and `CODSPEED_WALLTIME_FORKS` does not apply. `CODSPEED_PROCESS_ISOLATION=false` keeps every benchmark in one process. Analysis forks reuse `runForks`: the instruments hold the measurement, so a fork writes empty samples, which tell the parent it measured its benchmark. Refs COD-4156
In simulation and memory mode, the parent now runs each task in one fresh process, which measures only that task. Children keep quiet about the banner and summary, like walltime forks. The in-process integration test mocks the core, which forks cannot see, so it turns isolation off. Refs COD-4156
With Vitest 5, simulation and memory runs now reuse the walltime fork flow: workers queue each benchmark instead of measuring it, and the main process runs one fresh `vitest bench` per benchmark once the run is over. The fork is restricted to the benchmark's file and measures only that benchmark. `CODSPEED_WALLTIME_FORKS` and the `forks` options do not apply: analysis measures a benchmark once. Vitest 3/4 still don't fork. Closes COD-4156
8728bb6 to
fdf9f67
Compare
TLDR: Simulation and memory runs measured every benchmark in one shared process, so allocator, JIT and heap state from earlier benchmarks leaked into later ones. Each analysis benchmark now runs in its own fresh process, reusing the walltime fork machinery (tinybench and Vitest 5).
core:analysisIsolation()reads the same env aswalltimeIsolation(), but always uses 1 fork.CODSPEED_WALLTIME_FORKSandforksoptions don't apply.CODSPEED_PROCESS_ISOLATION=falserestores the shared process.tinybench: the parent runs each task viarunForks(uri, 1); the child measures only that task.vitest(v5): workers queue analysis benchmarks; the main process runs onevitest benchper benchmark after the run. Vitest 3/4 and benchmark.js are unchanged.valgrind --tool=callgrind --trace-children=yes(runner args),examples/with-typescript-simple-esmandexamples/with-vitest-v5produce one dump per benchmark, each from a distinct PID, none from the parent.switch 1/switch 2measure 4,625/4,683 Ir (shared process: 4,625/3,152).Review notes
Closes COD-4156