-
Notifications
You must be signed in to change notification settings - Fork 374
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
Explore replacing BTreeSet in IndexedMap with a sorted Vec #1473
Comments
I'd be interested to look at this seeing as it is a way away still in terms of milestones. Could I be assigned this to track it better? :) |
You're welcome to work on it! We use milestones more to track "when do we need to work on this", but we welcome contributions to address any issue, even if it doesn't have a milestone! That said, this one is gonna be more than a bit tricky, I imagine. Sadly the Rust std/hashbrown HashMap doesn't have any guarantees about when it rehashes, I don't believe, unlike the C++ HashMap where you get them as a function of capacity. Building our own HashMap is probably the first rabbit hole to go down, but that will need to be relatively carefully benchmarked. |
Happy to start going down this rabbit hole :) |
Post-#1553 we'll probably want to also consider replacing the heap-allocated string there with a |
Requirement clarification : But how important is it to also iterate through newly added key in ongoing iteration ? |
We don't need to iterate, but we do need to be able to decide whether a key would have already been sent to a peer or not. Specifically rust-lightning/lightning/src/ln/peer_handler.rs Lines 357 to 378 in 19b5a48
|
Updated the issue title due to the recent merge #1799. |
Hm, maybe we should just close this and open a new issue tagged "good first issue"? |
Sure, closing in favor of #1992 |
We currently use a
BTreeMap
for storing network graph data, as we need to be able to access it starting from a given key and continue iteration. This makes a sorted KV store like a BTree the obvious choice, but we don't actually need the keys to be sorted, we just need them to not change order as we iterate the graph.Technically we also need to be able to check if a new key is below some previous iteration that is in-progress.
Supposedly the
indexmap
crate may offer something like what we need, but ultimately any hashtable that doesn't ever re-hash should suffice, and while creating our own probably won't be as efficient as hashbrown, it'd probably still be faster than a btree, and use way less memory compared to the substantial heap fragmentation that a btree creates.The text was updated successfully, but these errors were encountered: