Repository navigation
fix(core): seed the V8 RNG and string hashes in walltime mode - #105
not-matthias wants to merge 1 commit into
Conversation
Walltime runs left Math.random() and V8's hash seed random per process, so benchmarks using random inputs or hash-heavy structures varied between runs for reasons unrelated to the code under test. Pass the analysis-mode seed flags (--hash-seed=1, --random-seed=1, and --no-randomize-hashes on Node < 18) in walltime too, via one shared helper. Disabled mode stays unseeded. crypto randomness and key iteration order are unchanged.
Merging this PR will degrade performance by 1.13%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
|
Walltime mode now passes the same seed flags as analysis mode:
--hash-seed=1and--random-seed=1, plus--no-randomize-hasheson Node.js < 18. Both modes get them from one shared helper. Disabled mode stays unseeded, so runs outside CodSpeed keep the normal behavior.Without these flags, every walltime process used a random
Math.random()seed and a random hash seed. Benchmarks that use random inputs, or that depend on hash table layout (collisions, lookup cost), could vary between runs for reasons that have nothing to do with the code under test.Checked on Node.js 24:
Math.random()returns the same sequence on every run, including in worker threads and in vitest walltime forks.--hash-seedstill applies even though Node boots from a snapshot, because--rehash-snapshotis on by default. With seed 1 the internal dictionary layout of the same object is identical across runs. Seed 2 gives a different but stable layout, and no flag gives a different layout each run.cryptorandomness and key iteration order are unchanged.--predictableand the GC flags stay analysis-only, because they change walltime timing.The runner's exec-harness
nodewrapper copies these flags by hand and needs the same walltime update. Until then,checkV8Flagswill warn about the missing seed flags undercodspeed exec.Stacked on #104.
Refs COD-3936