-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Finalize one-shot hashing interface #19495
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
Conversation
- Don’t expose the raw execution seed to _rawHashValue. - Change the type of _rawHashValue’s seed from (UInt64,UInt64) to a single Int. Working with a pair of UInt64s is unwieldy, and overkill in practice. Int as a seed also integrates nicely with Int as a hash value. - Remove _HasherCore._generateSeed(). Instead, simply call finalize() on a copy of the hasher to get a seed suitable for _rawHashValue. - Update Set and Dictionary to store a single Int as the seed value. Note that this doesn’t affect the core hasher, which still mixes in the actual 128-bit execution seed during its initialization. To reduce the potential of confusion, use the name “rawSeed” to refer to an actual 128-bit seed value.
@swift-ci please test |
@swift-ci please smoke benchmark |
@swift-ci please smoke test compiler performance |
Build comment file:Performance: -O
Code size: -Osize
Performance: -Onone
How to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the regressions before you merge the PR. Noise: Sometimes the performance results (not code size!) contain false alarms. Unexpected regressions which are marked with '(?)' are probably noise. If you see regressions which you cannot explain you can try to run the benchmarks again. If regressions still show up, please consult with the performance team (@eeckstein). Hardware Overview
|
The improvements seem accidental. The -Onone histogram regression implies there might be an extra uninlined function call. I don't think it matters. |
_rawHashValue(seed:)
is an underscoredHashable
requirement with a default implementation, introduced earlier for 5.0. It speeds up hashing of small-sized keys by eliminating some resiliency overhead._rawHashValue
._rawHashValue
’s seed from(UInt64,UInt64)
to a singleInt
. Working with a pair ofUInt64
s is unwieldy, and overkill in practice.Int
as a seed also integrates nicely withInt
as a hash value._HasherCore._generateSeed()
. Instead, simply callfinalize()
on a copy of the hasher to get a seed suitable for_rawHashValue
.Set
andDictionary
to store a single Int as the seed value.Note that this doesn’t affect the core hasher, which still mixes in the actual 128-bit execution seed during its initialization. To reduce the potential of confusion, use the name
rawSeed
to refer to an actual 128-bit seed value.rdar://problem/44724660