Repository navigation
Optimize the performance of intrusive_heap - #1674
Merged
Merged
Conversation
Contributor
Author
|
Ping... |
intrusive_heap
Collaborator
|
/ok to test d19ebed |
Collaborator
sorry for the delay. last week was a c++ standardization meeting. i was maxed. |
Contributor
Author
No worries, and thanks for your reply! I was aware of the C++ meeting from my email with Maikel, so I totally understand and was happy to wait. |
Collaborator
|
/ok to test f96b537 |
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.
Recently, I refactored the intrusive heap. Conservatively speaking, after the refactoring, the performance of the intrusive heap on small datasets has nearly doubled, while on large datasets, it has improved by at least 20%, depending on the specific application scenario.
When inserting into or removing nodes from a binary heap, the parent pointers of nodes along the sift-up or sift-down path remain unchanged. By leveraging this fact, we can reduce the maintenance of parent pointers in the heap. Moreover, using double pointers greatly simplifies operations and eliminates many branches.
Undoubtedly, there are faster implementations available, such as the quad heap. However, without altering the original design, preserving compatibility, and after careful trade-offs, this is arguably the best implementation you will find.