Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ benchmark is measured. TurboFan remains disabled with `--no-opt`, and Maglev is
explicitly disabled on Node.js 24 and newer.

This changes the measurement baseline compared with earlier releases. It does not
isolate inline-cache feedback from other benchmarks. Walltime flags are unchanged.
isolate inline-cache feedback from other benchmarks.

## Seed flags

Simulation, memory, and walltime mode pass `--hash-seed=1` and `--random-seed=1` (plus
`--no-randomize-hashes` on Node.js < 18). `Math.random()` returns the same
sequence on every run, including in worker threads, and hash tables get the same
internal layout, so hash collisions do not change between runs. Key iteration
order is unaffected, since it follows insertion order. `crypto` randomness stays
random. Walltime mode uses no other analysis flags.

## Testing introspection locally

Expand Down
17 changes: 12 additions & 5 deletions packages/core/src/introspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ const CUSTOM_INTROSPECTION_EXIT_CODE = 0;

const V8_LOG_FILENAME_PATTERN = "codspeed-v8-%p.log";

// Fixed seeds so Math.random() and hash table layout match on every run
const getSeedFlags = (nodeVersionMajor: number) => {
const flags = ["--hash-seed=1", "--random-seed=1"];
if (nodeVersionMajor < 18) {
flags.push("--no-randomize-hashes");
}
return flags;
};

export const getV8Flags = () => {
const nodeVersionMajor = parseInt(process.version.slice(1).split(".")[0]);
const instrumentMode = getInstrumentMode();
Expand All @@ -17,8 +26,7 @@ export const getV8Flags = () => {
case "analysis": {
flags.push(
...[
"--hash-seed=1",
"--random-seed=1",
...getSeedFlags(nodeVersionMajor),
"--no-opt",
"--always-sparkplug",
"--predictable",
Expand All @@ -28,9 +36,6 @@ export const getV8Flags = () => {
"--max-old-space-size=4096",
],
);
if (nodeVersionMajor < 18) {
flags.push("--no-randomize-hashes");
}
if (nodeVersionMajor < 20) {
flags.push("--no-scavenge-task");
} else {
Expand All @@ -48,6 +53,8 @@ export const getV8Flags = () => {
}

case "walltime": {
flags.push(...getSeedFlags(nodeVersionMajor));

// Emit the V8 jitdump
flags.push("--perf-prof");

Expand Down
Loading