-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Heap] Switch to a custom _Index type that incrementally tracks depth #71
Comments
Might also consider trying to access the BSR (bit scan reverse) function which at least for x64 should be fairly quick, see more information here: https://probablydance.com/2020/08/31/on-modern-hardware-the-min-max-heap-beats-a-binary-heap/ quote:
|
@hassila That's exactly what |
Having a dedicated type for nodes in the tree was a good idea -- I find Unfortunately, the original goal of putting the levels in the index (a.k.a. An alternative option would've been to remove |
The
Heap
implementation currently uses naked integers as indices, and uses_binaryLogarithm
to determine whether a particular index addresses a min or max node. This is a relatively expensive(*) operation that may have some measurable performance impact.(*) Well, at least compared to a mov?
Instead, try switching to a custom _Index struct containing both a storage position and its associated depth.
Beyond a potential performance win, this would also allow for better code organization -- by allowing us to move the utility methods for retrieving the parents/children of an index to the Index type itself:
The text was updated successfully, but these errors were encountered: