async-rs / async-rs/futures-timer

Optimise the heap data structure.

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
219
Forks
42
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/async-rs/futures-timer/blob/30e562cdde45b8a6ee93d22094df8664ff8dfdfb/src/native/heap.rs#L8) 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 `Drop`s, 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading src/native/heap.rs and comparing its sink/swim implementation with the standard-library heap implementation mentioned in the issue. Review the proposed cache-friendly storage and unique-id lookup ideas with maintainers first; the issue does not specify tests or a concrete completion criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.