Repository navigation
Use a fast fixed hasher for the .NET-style set index (1.3x, same output) - #179
Merged
Merged
Conversation
…asher The key-to-entry index behind the .NET HashSet and Dictionary copies used std's default SipHash with a random seed. It is only looked up, never enumerated (enumeration order comes from the entry array), so its hash cannot change any output. Swap it for FxHash's rotate-xor-multiply mix, with no seed. Same output: bench --baseline reports every response identical on the small list (61) and the big list (1,147), and the snapshot gate passes. On tealc the small list goes 1,417 -> 1,077 ms (1.32x) and the big list 58.0 -> 44.7 s (1.30x). The WASM module shrinks from 961,191 to 911,892 bytes (243.9 -> 234.9 KB brotli). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PTSQFMEdmByebgkoa9RiqH
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
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 |
This was referenced Oct 21, 2026
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.
This is the first same-output speed change of the Rust-native phase (#138). The planner is 1.3x faster, and every plan stays byte for byte the same.
The change
NetHashSetandNetDictionaryinrust/dotnet-compatcopy .NET'sHashSetandDictionary. Each keeps its entries in an array, in the order .NET would enumerate them, plus a stdHashMapfrom key to entry index for lookups. That index used std's default hasher: SipHash, with a new random seed for every map. SipHash is built to resist hash flooding, and it is slow on small keys like a grid location.The index is only ever looked up. It is never enumerated, because enumeration order comes from the entry array. So its hash function cannot change any output. This PR swaps it for FxHash's rotate-xor-multiply mix, the one rustc uses, in a new
dotnet_compat::FastHasher(about 60 lines, no new crate). It has no seed, so maps also behave the same from run to run.Hash flooding doesn't apply here. The keys come from the user's own blueprint, and the planner runs in their own browser.
Why this first
I profiled with samply at 2 kHz on the first 93 big-list fields (13.7 s of planning, including the five slowest). A* was 67% of all samples. The SipHash index of the .NET-style sets was about 14%:
contains_keywas 9.9% on its own, most of it A*'sgoals.contains().Results
cargo run --release -p benchon tealc (8 cores, Linux). Each run is compared with--baselineto a run ofmainon the same machine:The WASM module also gets smaller: 961,191 bytes to 911,892 (-5.1%), and 243.9 KB to 234.9 KB with brotli. That is probably the SipHash and random-seed code dropping out. A
mainbuild made locally is exactly the size of the live module, so the comparison is fair.Checks run
cargo fmt,cargo clippy --all-targets -- -D warnings: cleancargo test --all-targets: 194 passed, 7 ignored. The 2 new tests check that the hasher is fixed, that a 40 x 40 block of grid cells has no collisions, and that a partial last word is hashed.cargo test --release -p snapshots -p contract -- --include-ignored: 37 passed, covering all 2,748 snapshots and the scoreboardcargo build --workspace --target wasm32-unknown-unknown: OKMerging deploys the site, with the same plans and a smaller, faster planner. I'll run the 61-blueprint live check after the deploy.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PTSQFMEdmByebgkoa9RiqH