-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
More hash
optimization
#50041
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
More hash
optimization
#50041
Conversation
…d hash of arbitrary real types by not hashing the denominatior when it is one
Do you have benchmarks? |
|
Now that we've successfully unbroken hashing on master, I think this is ready to go. |
For optimization 1, the OP is out of date, only Float16s are changed, not Float32s as well? I also don't see the speedup: julia> @btime sum(hash, reinterpret(Float16, typemin(UInt16):typemax(UInt16)));
224.000 μs (0 allocations: 0 bytes)
shell> git checkout more-hash-optimization -- base/float.jl base/gmp.jl base/rational.jl
julia> @btime sum(hash, reinterpret(Float16, typemin(UInt16):typemax(UInt16)));
223.333 μs (0 allocations: 0 bytes) |
Updated benchmarks. I agree that I'm not seeing much improvement for |
If this doesn't provide measurable performance benefits, we should probably remove it: Lines 658 to 669 in 0a2d6fc
|
This is two separate optimizations.
The first is speeding up
hash(::Union{Float16, Float32})
using the fact that they always are within the range ofInt64
so you don't need to check that (or check whether they are within theUInt64
range.The second is that
AbstractFloat
s andInteger
s will never have a denominator that isn't 1, so we can change the rules of hashing to not hash the denominator if it is 1.