Implement efficient clearing of the Hashtable#106
Open
Bobobalink wants to merge 2 commits intoteslamotors:mainfrom
Open
Implement efficient clearing of the Hashtable#106Bobobalink wants to merge 2 commits intoteslamotors:mainfrom
Bobobalink wants to merge 2 commits intoteslamotors:mainfrom
Conversation
4288b82 to
249b567
Compare
This allows us to directly find the bucket that points to each value in the value array, which makes erasing elements given an iterator faster (before we needed one key lookup for each element erased). Practically, this makes clearing large "chunks" of the FixedMap faster.
249b567 to
a7c35b7
Compare
Instead of iterating over the linked list (also requires hash lookups) and erasing one by one, just reset the backing linked list and value storage, then 0 out the bucket array.
a7c35b7 to
219a7aa
Compare
Bobobalink
commented
Apr 12, 2024
| { | ||
| // update the backlink of the value pointed to by the bucket we're about to put in | ||
| // table_loc | ||
| bucket_for_value_index(bucket.value_index_) = table_loc; |
Contributor
Author
There was a problem hiding this comment.
this is actually quite a lot of extra work that is required for every single insertion and deletion. We expect there to be a lot of buckets that need to be moved, and now each of those moves also requires touching this separate array.
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.
Instead of iterating over the linked list (also requires hash lookups) and erasing one by one, just reset the backing linked list and value storage, then 0 out the bucket array.