Simplify hashing of unique IDs to improve performance
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox115 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Attachments
(1 file)
Currently we pass unique IDs through mozilla::HashGeneric() to generate a hash code which we pass to the hash table, which then processes it further with ScrambleHashCode().
The latter step is sufficient to generate good hash codes. The documentation comment states:
* This function aims to produce as uniform an output distribution as possible,
* especially in the most significant (leftmost) bits, even though the input
* distribution may be highly nonrandom, given the constraints that this must
* be deterministic and quick to compute.
So we should be able to return the ID directly as the hash code. Also, since these are assigned sequentially we can the top 32 bits as collissions in the bottom 32 bits are highly unlikely.
If further justification were needed I discovered that DefaultHasher<uint64_t>::hash works like this already:
// Just convert the integer to a HashNumber and use that as is. (This
// discards the high 32-bits of 64-bit integers!) ScrambleHashCode() is
// subsequently called on the value to improve the distribution.
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 1•2 years ago
|
||
This removes the first HashGeneric step and relies on the ScrambleHashCode step
that happens in the hash table implementation.
This improved the benchmark result from 47.5 ns to 44.1 ns, a reduction of
7.2%.
Updated•2 years ago
|
Comment 3•2 years ago
|
||
bugherder |
Description
•