Skip to content

Replace std::collections::HashMap with rustc_hash::FxHashMap #10676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: yj/enforce-fxhasher
Choose a base branch
from

Conversation

hardfist
Copy link
Contributor

@hardfist hardfist commented Jun 15, 2025

This is all automatic generated by copilot agent
This commit replaces all usages of std::collections::HashMap with rustc_hash::FxHashMap throughout the rspack codebase for better performance.

FxHashMap provides significantly better performance for string keys and is already widely used in the Rust ecosystem for performance-critical applications like rustc itself.

Changes:

  • Replace import statements: std::collections::HashMap -> rustc_hash::FxHashMap as HashMap
  • Update type annotations to use FxHashMap
  • Add rustc-hash dependency to crates that needed it
  • Handle special cases where external APIs (like LightningCSS) still require std HashMap
  • Update HashMap construction from ::new() to ::default() where needed

All tests pass and compilation succeeds with these changes.

Summary

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

This commit replaces all usages of std::collections::HashMap with
rustc_hash::FxHashMap throughout the rspack codebase for better performance.

FxHashMap provides significantly better performance for string keys and
is already widely used in the Rust ecosystem for performance-critical
applications like rustc itself.

Changes:
- Replace import statements: std::collections::HashMap -> rustc_hash::FxHashMap as HashMap
- Update type annotations to use FxHashMap
- Add rustc-hash dependency to crates that needed it
- Handle special cases where external APIs (like LightningCSS) still require std HashMap
- Update HashMap construction from ::new() to ::default() where needed

All tests pass and compilation succeeds with these changes.
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Jun 15, 2025
Copy link

codspeed-hq bot commented Jun 15, 2025

CodSpeed Performance Report

Merging #10676 will not alter performance

Comparing feature/replace-std-hashmap-with-rustc-hash (b58eb6d) with yj/enforce-fxhasher (a4648ff)

Summary

✅ 12 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant