Repository navigation
perf: hash arena identities without SipHash in content tables #370
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
Merged
+161
−45
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
84f024d
perf: hash arena identities without SipHash in content tables
polaz 437f493
perf: take the seeded table hasher from structured-asn1
polaz b8b2cd8
build(bench): lock competitor harnesses to structured-asn1 0.20.2
polaz 3c8b4f7
fix(xmldsig): keep values an XPath reads as signing dependencies
polaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| use super::SeededState; | ||
| use core::hash::BuildHasher; | ||
|
|
||
| /// Distinct values among `bits` low bits of the hashes of `keys`. | ||
| fn distinct_low_bits(state: &SeededState, keys: impl Iterator<Item = u64>, bits: u32) -> usize { | ||
| let mask = (1_u64 << bits) - 1; | ||
| keys.map(|key| state.hash_one(key) & mask) | ||
| .collect::<std::collections::BTreeSet<_>>() | ||
| .len() | ||
| } | ||
|
|
||
| #[test] | ||
| fn equal_keys_hash_equally_within_a_table() { | ||
| // A table finds a key only if every hash of it agrees, for integer words, | ||
| // strings and the node-shaped tuples the XPath engine stores. | ||
| let state = SeededState::default(); | ||
| assert_eq!(state.hash_one(42_u64), state.hash_one(42_u64)); | ||
| assert_eq!(state.hash_one("prefix"), state.hash_one("prefix")); | ||
| assert_eq!( | ||
| state.hash_one((7_usize, 3_u8, 1024_usize)), | ||
| state.hash_one((7_usize, 3_u8, 1024_usize)) | ||
| ); | ||
| assert_ne!(state.hash_one("ab"), state.hash_one("ba")); | ||
| assert_ne!(state.hash_one(("a", "bc")), state.hash_one(("ab", "c"))); | ||
| } | ||
|
|
||
| #[test] | ||
| fn strided_identities_spread_across_buckets() { | ||
| // A stylesheet can select every 2^k-th node, so slot indices sharing low | ||
| // zero bits must still reach distinct buckets. 4096 keys over 4096 | ||
| // buckets fill about 63% when hashing is uniform. | ||
| let state = SeededState::default(); | ||
| for stride in [1_u64, 1 << 8, 1 << 16, 1 << 32] { | ||
| let distinct = distinct_low_bits(&state, (0..4096).map(|key| key * stride), 12); | ||
| assert!(distinct > 2400, "stride {stride}: {distinct} buckets"); | ||
| } | ||
| // hashbrown reads the top seven bits as the control byte. | ||
| let control = (0..4096_u64) | ||
| .map(|key| state.hash_one(key << 20) >> 57) | ||
| .collect::<std::collections::BTreeSet<_>>(); | ||
| assert_eq!(control.len(), 128); | ||
| } | ||
|
|
||
| #[test] | ||
| fn tables_are_seeded_independently() { | ||
| // A document cannot carry collisions computed for one table to another. | ||
| let first = SeededState::default(); | ||
| let second = SeededState::default(); | ||
| assert_ne!(first.hash_one(1_u64), second.hash_one(1_u64)); | ||
| assert_ne!(first.hash_one("namespace"), second.hash_one("namespace")); | ||
| } |
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.