julia
faa3d41f - Faster AbstractArray hashing with a static hash seed (#39950)

Commit
4 years ago
Faster AbstractArray hashing with a static hash seed (#39950) Previously, the `object_id` lookup for `hash(AbstractArray, h)` dominated the hashing time for `AbstractArray`: ``` julia> using StaticArrays, BenchmarkTools julia> a = @SVector [1,2,3,4,5]; julia> @btime hash($a, UInt(0)) 77.935 ns (0 allocations: 0 bytes) 0xdeb6d0657a261f74 julia> @btime hash(AbstractArray, UInt(0)) 58.643 ns (0 allocations: 0 bytes) 0xc03f1dbe32103a9e ``` This replaces the hash of the objectid with a static randomly-generated number. Now: ``` julia> @btime hash($a, UInt(0)) 18.580 ns (0 allocations: 0 bytes) 0x5e77b8bf73067ebd ``` and for a random `Float64` vector ``` julia> @btime hash($a, UInt(0)) 29.031 ns (0 allocations: 0 bytes) 0x9a574d69612587eb ``` Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Author
Parents
Loading