Skip to content

Pin the hash seed in the microbenchmark harness - #9126

Merged
youknowone merged 1 commit into
mainfrom
codspeed/bench-pin-hash-seed
Oct 15, 2026
Merged

youknowone merged 1 commit into
mainfrom
codspeed/bench-pin-hash-seed

Conversation

@codspeed

@codspeed codspeed Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Requested in #9010.

Why

benches/microbenchmarks.rs builds the interpreter from Settings::default(), which leaves hash_seed = None. Each benchmark process then picks a random str hash secret. Depending on the seed, the names in the module globals dict collide more or less, so dict, loop, string and compare microbenchmarks move by 10–17% between runs even when the code is the same. Examples:

Change

Set settings.hash_seed = Some(0) in bench_rustpython_code. The hash secret is set once per process by the first interpreter, and every RustPython interpreter in this harness uses the same settings, so all microbenchmarks now hash with the same secret on every run.

Benchmark code and CPython comparisons are not affected. The first CodSpeed run on this PR can move the affected benchmarks once, since the fixed seed may give different collisions than the random seed in the base run. After that, results should only change when the code does.

benches/execution.rs uses the same Settings::default() pattern and could be pinned the same way if needed.

Comment @codspeedbot pin the hash seed in benches/execution.rs too and I'll do it.

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.
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7d5538a5-ccab-4cfd-a6d2-9821886e238d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@youknowone
youknowone marked this pull request as ready for review October 15, 2026 01:28
@youknowone

Copy link
Copy Markdown
Member

@fanninpm Thank you!

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T01:30:07.029234Z bacf259 Draft marked ready
🔒 Security Review ✅ Completed 2026-10-15T01:31:11.288851Z bacf259 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@youknowone
youknowone merged commit ba54cce into main Oct 15, 2026
25 checks passed
@youknowone
youknowone deleted the codspeed/bench-pin-hash-seed branch October 15, 2026 01:28
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.

2 participants