Skip to content

Replace ahash with rapidhash#7954

Merged
youknowone merged 5 commits into
RustPython:mainfrom
fanninpm:replace-ahash-with-rapidhash
May 25, 2026
Merged

Replace ahash with rapidhash#7954
youknowone merged 5 commits into
RustPython:mainfrom
fanninpm:replace-ahash-with-rapidhash

Conversation

@fanninpm

@fanninpm fanninpm commented May 23, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #7800.

Back in 2021, ahash was added to RustPython in #2397 because it was faster than the Rust standard library hash/RandomState.
Since then, hashing technology has evolved to the point where rapidhash beats ahash in both the SMHasher and SMHasher3 test suites.
Additionally, rapidhash has very minimal direct dependencies and is portable across CPU architectures.

cc @coolreader18 @joshuamegnauth54

Summary by CodeRabbit

  • Chores
    • Replaced the workspace hashing dependency with an alternative implementation and updated usages across crates for consistent hashing behavior.
    • Adjusted dependency grouping so the previous hash crate is no longer included in the automated grouping/configuration.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 4bdcd70d-0475-4054-b30b-7357b866056c

📥 Commits

Reviewing files that changed from the base of the PR and between fd63103 and 133a66c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/dependabot.yml
  • Cargo.toml
  • crates/codegen/Cargo.toml
  • crates/codegen/src/lib.rs
  • crates/stdlib/Cargo.toml
  • crates/stdlib/src/contextvars.rs
  • crates/vm/Cargo.toml
  • crates/vm/src/builtins/type.rs
  • crates/vm/src/intern.rs
  • crates/vm/src/vm/interpreter.rs
  • crates/vm/src/vm/mod.rs
💤 Files with no reviewable changes (1)
  • .github/dependabot.yml
✅ Files skipped from review due to trivial changes (1)
  • crates/codegen/Cargo.toml

📝 Walkthrough

Walkthrough

This PR replaces the ahash crate with rapidhash across the workspace: workspace dependencies updated, Dependabot pattern removed, and hasher types switched from ahash::RandomState to rapidhash::quality::RandomState in codegen, stdlib, and vm crates.

Changes

Hash Library Migration

Layer / File(s) Summary
Workspace dependency and Dependabot configuration
Cargo.toml, .github/dependabot.yml
Workspace removes ahash and adds rapidhash = "4.4.1"; Dependabot cargorandom group patterns no longer includes "ahash".
Codegen crate migration
crates/codegen/Cargo.toml, crates/codegen/src/lib.rs
crates/codegen removes ahash dep, adds rapidhash, and updates IndexMap/IndexSet aliases to use rapidhash::quality::RandomState.
Stdlib crate migration
crates/stdlib/Cargo.toml, crates/stdlib/src/contextvars.rs
crates/stdlib swaps ahash for rapidhash and updates the Hamt IndexMap hasher to rapidhash::quality::RandomState.
VM crate migration
crates/vm/Cargo.toml, crates/vm/src/builtins/type.rs, crates/vm/src/intern.rs, crates/vm/src/vm/mod.rs, crates/vm/src/vm/interpreter.rs
crates/vm replaces ahash with rapidhash and updates PyAttributes, StringPool.inner, PyGlobalState.frozen, and the interpreter frozen registry HashMap types to rapidhash::quality::RandomState.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • RustPython/RustPython#7665: Adds ahash to Dependabot Cargo random group patterns; this PR removes it from the same configuration.

Suggested reviewers

  • coolreader18
  • youknowone

"🐰 I hopped through Cargo trees today,
swapped ahash out, made rapidhash play,
maps and sets now hum with speed,
a nimble hop for every need.
⚡🥕"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: replacing the ahash hashing library with rapidhash across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@ShaharNaveh ShaharNaveh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to adjust dependabot as well?

@fanninpm

Copy link
Copy Markdown
Contributor Author

Do we need to adjust dependabot as well?

That will be the last commit in the series.

@fanninpm fanninpm marked this pull request as ready for review May 24, 2026 03:46
@fanninpm fanninpm force-pushed the replace-ahash-with-rapidhash branch from fd63103 to 133a66c Compare May 24, 2026 14:30

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@youknowone youknowone merged commit bc3d00e into RustPython:main May 25, 2026
26 checks passed
@fanninpm fanninpm deleted the replace-ahash-with-rapidhash branch May 26, 2026 03:00
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.

3 participants