perf(map): index dense numeric key ranges - #8867
Closed
proggeramlug wants to merge 1 commit into
Closed
Conversation
|
Warning Review limit reachedNext included review available in 12 minutes. View limit detailsLimit details: You’ve used all 8 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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. Comment |
proggeramlug
added a commit
that referenced
this pull request
Aug 26, 2026
Contributor
Author
|
Landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Map.clear()The range is admitted only when its span is at most 4x the observed integer-key count and is capped at 1,048,576 slots. A run beginning at 1,000,000 therefore costs the same as a run beginning at zero, while isolated large keys cannot trigger a magnitude-sized allocation.
Mac-mini evidence
Unchanged codehz/ecs row:
5k entities: 3 commands each + sync (15k total commands).Exact 11-pair alternating cohort, repeat 64, two warmups and six measured rounds per process:
03b8d566953b5ffc7915341b1c946de5941b4b1344ee7c20b9bbd761b9409208e432c9d2d0124ccbc336d3458ae3539f2a3a9048658ddf92ef49231934301b44The post-change native sample reduces
map::find_key_indexfrom 355/3,728 main-thread samples (9.52%) to 48/2,983 (1.61%), an 83.1% relative reduction in normalized share. That confirms that the measured gain comes from removing the intended hash probes.Node 26.5.1 versus candidate, 11 alternating pairs, reports 2.882646 ms Node and 22.222847 ms Perry: 7.709x by independent medians and 7.642x by paired medians, with 22/22 semantic oracles. The preceding landed stack measured 8.172x.
Verification
cargo test -p perry-runtime --lib --quiet: 2,706 passed, 0 failed, 4 ignoredpython3 scripts/gc_runtime_root_holders.py --self-testpython3 scripts/gc_runtime_root_holders.pycargo fmt --all -- --checkgit diff --check