Skip to content

fix(core): seed the V8 RNG and string hashes in walltime mode - #105

Open
not-matthias wants to merge 1 commit into
cod-3936-add-always-sparkplug-to-codspeed-node-analysis-mode-v8-flagsfrom
cod-3936-walltime-random-seed
Open

not-matthias wants to merge 1 commit into
cod-3936-add-always-sparkplug-to-codspeed-node-analysis-mode-v8-flagsfrom
cod-3936-walltime-random-seed

Conversation

@not-matthias

Copy link
Copy Markdown
Member

Walltime mode now passes the same seed flags as analysis mode: --hash-seed=1 and --random-seed=1, plus --no-randomize-hashes on 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-seed still applies even though Node boots from a snapshot, because --rehash-snapshot is 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.
  • crypto randomness and key iteration order are unchanged.

--predictable and the GC flags stay analysis-only, because they change walltime timing.

The runner's exec-harness node wrapper copies these flags by hand and needs the same walltime update. Until then, checkV8Flags will warn about the missing seed flags under codspeed exec.

Stacked on #104.

Refs COD-3936

@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 6 benchmarks

3 warnings, 1 note

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 13 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

ℹ️ 16 benchmarks have no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 5 improved benchmarks
❌ 6 regressed benchmarks
✅ 253 untouched benchmarks
⏩ 56 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory wait 500ms 22 KB 28.1 KB -21.44%
❌ Memory wait 1sec 22 KB 27.5 KB -19.97%
❌ Memory wait 500ms 22.7 KB 28.2 KB -19.53%
❌ Walltime short body 1.6 µs 1.9 µs -11.61%
❌ Walltime short body 1.7 µs 1.9 µs -10.13%
❌ Walltime switch 2 108 ns 120 ns -10%
⚡ CPU Simulation wait 500ms 49.7 ms 25 ms +99.06%
⚡ CPU Simulation wait 1sec 90.2 ms 50.3 ms +79.39%
⚡ Memory wait 1sec 28.7 KB 22.1 KB +29.49%
⚡ Walltime switch 1 84 ns 72 ns +16.67%
⚡ Walltime switch 2 96 ns 84 ns +14.29%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cod-3936-walltime-random-seed (5e52a1d) with cod-3936-add-always-sparkplug-to-codspeed-node-analysis-mode-v8-flags (8ecc3ba)

Open in CodSpeed

Footnotes

  1. 56 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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.
@not-matthias
not-matthias force-pushed the cod-3936-walltime-random-seed branch from c40ae87 to 5e52a1d Compare October 26, 2026 11:19
@not-matthias
not-matthias marked this pull request as ready for review October 26, 2026 11:20
@not-matthias
not-matthias added this pull request to stack #110 October 26, 2026 11:20
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the separate runner wrapper update explicitly deferred by the author.

Summary

Walltime mode now requests fixed V8 random and hash seeds. Analysis mode uses the same helper, while disabled mode stays unseeded.

  • Walltime runs now request fixed V8 random and hash seeds.

Reviews (1) · Last reviewed commit: "fix(core): seed the V8 RNG and string ha..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant