Skip to content

Commit 4bd0611

Browse files
committed
docs: describe process isolation
Document the environment contract, the parent and child roles, and the Vitest and test caveats.
1 parent d4c8e42 commit 4bd0611

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

‎CLAUDE.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,26 @@ so exercise all three of these when developing or reviewing a plugin change
115115
Running these locally outside the CodSpeed runner is expected to log
116116
`instrument-hooks: failed to write environment.json` and skip actual measurement
117117
writes — the point is to verify the plugin's control flow and output per mode,
118-
not to produce real measurements.
118+
not to produce real measurements.
119+
120+
## Process isolation
121+
122+
In instrumentation/simulation/memory runs with active instrument hooks, every
123+
benchmark runs in its own process (`packages/core/src/isolation.ts`), so the
124+
allocator and JIT state of one benchmark can't change the measurement of the
125+
next. Walltime runs and runs outside CodSpeed are not affected.
126+
127+
- `CODSPEED_PROCESS_ISOLATION`: unset, `1` or `true` turns it on (default),
128+
`0` or `false` runs all benchmarks in one process, any other value is an error.
129+
- The parent process re-runs itself (`process.execPath`, `process.execArgv` and
130+
`process.argv.slice(1)`, so the V8 flags survive) once per benchmark with
131+
`CODSPEED_ISOLATED_BENCHMARK=<uri>`. The child runs only that benchmark, whatever
132+
the user filters are, and the parent exits with the child's exit code
133+
(`128 + N` for signal `N`).
134+
- The child prints no banner or summary lines. They come from the parent.
135+
- Vitest measures in forked workers, so the plugin records the command of the
136+
main Vitest process (`CODSPEED_ISOLATION_COMMAND`) and each worker runs that
137+
command, i.e. one Vitest run per benchmark.
138+
- Tests that drive a plugin in-process against a mocked core must set
139+
`CODSPEED_PROCESS_ISOLATION=false`, or the plugin would start the test runner
140+
again for every benchmark.

0 commit comments

Comments
 (0)