-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[DON'T MERGE] Switch to SipHash13 #14511
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
Closed
Closed
Conversation
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
- Add the method _hash(into:) as a Hashable requirement. It takes a closure into which the function can feed integer values representing bits to be hashed. - Implement _hash(into:) in terms of hashValue in an extension, for compatibility. - Add struct _QuickHasher, for emulating Swift 4 hashes in the new interface. - Add _defaultHashValue<T>(for:), implementing hashValue in terms of _hash(into:) and _QuickHasher.
We don't need to stream bytes, just words.
This is a version for hasher that uses a nonmutating append, so that we can mark it @effects(readonly), reducing retain/releases around its calls.
This restores speed of String hashing, among other types.
|
@swift-ci please benchmark |
Build comment file:Optimized (O)Regression (54)
Improvement (6)
No Changes (302)
Unoptimized (Onone)Regression (25)
Improvement (15)
No Changes (322)
Hardware Overview |
|
OK, this is way better than I expected. |
# Conflicts: # stdlib/public/core/Hashable.swift
f5ce77f to
52ee818
Compare
|
@swift-ci please benchmark |
Build comment file:Build failed before running benchmark. |
|
@swift-ci please benchmark |
Build comment file:Optimized (O)Regression (42)
Improvement (18)
No Changes (302)
Unoptimized (Onone)Regression (22)
Improvement (30)
No Changes (310)
Hardware Overview |
|
SipHash is now enabled in the main PR |
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 a variant of #14442 where the original hasher is replaced with the SipHash algorithm.
SipHash has a five-word state and more complicated calculations, so I expect things will be slower. But how much slower?