-
Notifications
You must be signed in to change notification settings - Fork 224
Optimize hashing using ahash
and multiversion
(-30%)
#428
Optimize hashing using ahash
and multiversion
(-30%)
#428
Conversation
Codecov Report
@@ Coverage Diff @@
## main #428 +/- ##
==========================================
- Coverage 80.80% 80.78% -0.02%
==========================================
Files 353 372 +19
Lines 22649 22643 -6
==========================================
- Hits 18302 18293 -9
- Misses 4347 4350 +3
Continue to review full report at Codecov.
|
}, | ||
DataType::UInt64, | ||
) | ||
let state = new_state!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state is initialized once for one array, will it cause a different hash result in another array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it uses the same seeds each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but there is a hash builder inside get_hash
, this may introduce extra allocate in each time, I did not find a way to improve that.
#[inline]
fn get_hash<H: Hash + ?Sized, B: BuildHasher>(value: &H, build_hasher: &B) -> u64 {
let mut hasher = build_hasher.build_hasher();
value.hash(&mut hasher);
hasher.finish()
}
ahash
and multiversion
(-30%)
Awesome, thanks a lot! I updated the title to match the findings to show up in the changelog nicely. |
This uses the
T::get_hash
, which gives some speedup over the builder.Also move ahash to the compute feature and add multiversioning to select/specialize on necessary instructions.