Skip to content

perf(store): use FxHashMap/FxHashSet for traversal seen maps#5214

Merged
jedel1043 merged 1 commit intoboa-dev:mainfrom
iammdzaidalam:perf/fxhash-store
Apr 6, 2026
Merged

perf(store): use FxHashMap/FxHashSet for traversal seen maps#5214
jedel1043 merged 1 commit intoboa-dev:mainfrom
iammdzaidalam:perf/fxhash-store

Conversation

@iammdzaidalam
Copy link
Copy Markdown
Contributor

Closes #5213

This switches HashMap / HashSet to FxHashMap / FxHashSet in the structured clone/store path (core/runtime/src/store/from.rs and to.rs).

Problem

The store path uses standard collections for traversal bookkeeping (e.g. SeenMap, ReverseSeenMap).

These maps are keyed by internal identities (pointer-like values) and are hit a lot during deep or cyclic object traversal. Using the default hasher here is probably doing more work than needed.

Change

Replace those maps with FxHashMap / FxHashSet.

This only affects internal bookkeeping. There is no intended semantic change.

Benchmark

Ran a local benchmark using boa_cli with repeated structuredClone() on a deep cyclic object graph (10 rounds, release build).

Metric std (main) FxHash (this PR) Improvement
Median 10,423 ms 6,894 ms ~33.8% faster
Min 9,231 ms 6,050 ms ~34.4% faster
Max 12,028 ms 8,806 ms ~26.7% faster

Notes

  • no intended semantic change
  • only touches internal traversal bookkeeping
  • FxHash is already used in other perf-sensitive parts of the engine

Test plan

  • cargo test -p boa_engine -p boa_runtime passes
  • manually tested structured cloning on deep / cyclic graphs

@iammdzaidalam iammdzaidalam requested a review from a team as a code owner March 21, 2026 17:55
@github-actions github-actions bot added Waiting On Review Waiting on reviews from the maintainers C-Runtime Issues and PRs related to Boa's runtime features and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 21, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 21, 2026
@github-actions
Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,539 50,539 0
Ignored 1,426 1,426 0
Failed 998 998 0
Panics 2 2 0
Conformance 95.42% 95.42% 0.00%

Tested main commit: 58a24587890677d94618259dfaa5f257ab5ef9c9
Tested PR commit: 6f04b02b844665dec6d3dfb1c7fe09d6a9aab7ca
Compare commits: 58a2458...6f04b02

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.80%. Comparing base (6ddc2b4) to head (6f04b02).
⚠️ Report is 938 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5214       +/-   ##
===========================================
+ Coverage   47.24%   59.80%   +12.56%     
===========================================
  Files         476      582      +106     
  Lines       46892    63460    +16568     
===========================================
+ Hits        22154    37953    +15799     
- Misses      24738    25507      +769     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

LGTM

@jedel1043 jedel1043 added this pull request to the merge queue Apr 6, 2026
Merged via the queue into boa-dev:main with commit ea390c6 Apr 6, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Runtime Issues and PRs related to Boa's runtime features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(store): Use FxHash for traversal seen maps

2 participants