HeaderMap: Store pos and hash as u16#386
Merged
seanmonstar merged 3 commits intohyperium:masterfrom Jan 27, 2020
Merged
Conversation
Member
|
Oh sweet! (I've filed #387 for the deprecation errors.) |
HeaderMap currently truncates all hashes to 16 bits, and limits its capacity to 32768 elements. The comments say this is done in order to store positions and hashes as u16, to improve cache locality. However, they are currently stored as usize. This patch changes the code to match the comments. This does not appear to cause any measurable improvement or regression in speed in the HeaderMap benchmarks. However, it should at least reduce the memory footprint of every Headermap.
The actual maximum capacity is 24578 (i.e. `32768 * 3/4`). A higher number would cause the raw capacity (i.e. `capacity + capacity/3` rounded to the next power of 2) to overflow `u16`.
Contributor
Author
|
Note that the I didn't change |
seanmonstar
approved these changes
Jan 27, 2020
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
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.
HeaderMap currently truncates all hashes to 16 bits, and limits its
capacity to 32768 elements. The comments say this is done in order to store
positions and hashes as
u16, to improve cache locality. However, they arecurrently stored as
usize. This branch changes the code to match thecomments.
This does not appear to cause any measurable improvement or regression in
speed in the HeaderMap benchmarks on my workstation. However, it should at
least reduce the memory footprint of every Headermap.