Skip to content
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

Optimise the heap data structure. #57

Open
Ben-PH opened this issue Mar 14, 2020 · 0 comments
Open

Optimise the heap data structure. #57

Ben-PH opened this issue Mar 14, 2020 · 0 comments

Comments

@Ben-PH
Copy link

Ben-PH commented Mar 14, 2020

I'm not familiar enough with this projects finer details and intent behind src/native/heap.rs, so my assumptions may be a bit off. I have, however, recently been doing some work that looks to me like it relates quite closely with this implementation: A heap backed priority queue with removal of arbitrary entry.

To start, it's commented that things aren't optimised. I would like to discuss how I might bring in some optimizations I have in mind.

  • I can see that the heaps sink/swim functions are manually defined. If you compare it with std-lib implementation, it has an interesting use of a data struct with custom Drops, which seems to improve things through minimizing movement of values in memory. I'd like to try and tap into the std-lib implementation, otherwise port it in and see if it improves things.
  • The heap appears to be an array of references into a linked list. The linked list itself is likely to have cache-unfriendly memory layout. The change I have in mind allows for cache-friendly arrays.
  • It looks like entries are identified by index. A change I have in mind should allow indexing to be kept, and also allow for lookup by unique id based on hash-map lookup: O(1)~

I would like to discuss these things in more detail before I get started, so I keep within the design intent of the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant