Skip to content

Commit ba54cce

Browse files
Pin the hash seed in the microbenchmark harness (#9126)
Settings::default() leaves hash_seed = None, so every benchmark process draws a random str hash secret. That changes globals-dict probe lengths between runs and makes dict/loop/string microbenchmarks swing by 10-17% with no code change. Use a fixed seed so results only move when the code does. Co-authored-by: CodSpeed Bot <no-reply@codspeed.io>
1 parent 8b2f9d8 commit ba54cce

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎benches/microbenchmarks.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ fn bench_rustpython_code(group: &mut BenchmarkGroup<'_, WallTime>, bench: &Micro
107107
settings.path_list.push("Lib/".to_string());
108108
settings.write_bytecode = false;
109109
settings.user_site_directory = false;
110+
// Pin the str/bytes hash secret so dict/set probe sequences (and thus
111+
// timings) are reproducible across benchmark runs.
112+
settings.hash_seed = Some(0);
110113

111114
let builder = Interpreter::builder(settings);
112115
let defs = rustpython_stdlib::stdlib_module_defs(&builder.ctx);

0 commit comments

Comments
 (0)