-
Notifications
You must be signed in to change notification settings - Fork 379
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 #1992
Comments
This won't impact the speed of the route-finding, but should reduce the time taken to sync the graph, load the graph from disk, and reduce memory fragmentation/usage. |
I can try and look into this! From what I understand, this would involve changing the I noticed in a comment in |
Well, keeping it strictly sorted is a lot of work. We only actually need a sort order while peers are fetching the graph from us, so keeping it sorted during deserialization is a lot of work that we don't need, and in general it may avoid doing a lot of sorting. Open to benchmarks that prove me wrong though :) |
Gotcha. Will play around with it 👍 |
Hmm, from running the benchmarks locally, it seems like there is not much of a difference in performance. You were right about strictly sorting though - there was a decent regression in Main branch to compare with:
Replaced BTreeSet with Vec (sorted in
Replaced BTreeSet with Vec (strictly sorted on inserts and removes) - see branch here:
Would it still be worth opening a PR for this for reduced memory fragmentation/usage? Also is there a recommended way to see/test that? |
I wouldn't expect the change to make any of our existing benchmarks (materially) faster, indeed (though it looks like both were very slightly faster on I'm not sure exactly the best way to test the memory overhead here, but you may just be able to basically run the |
Cool, I'll give that a try |
So with a brief test to run the I was struggling to interpret this change, so I also ran the test without the line where it actually runs This seems to me to be a reasonable improvement for a relatively small change - I can open a PR if others agree :) |
Sounds worth it to me! Thanks. |
In #1799, we replaced the use of
BTreeMap
s to store the network graph withIndexedMap
s, which are just aHashMap
with an additionalBTreeSet
that keeps the keys sorted. This yielded a ~30% speed improvement (on @TheBlueMatt's Xeon W-10885M with a SK hynix Gold P31) in pathfinding across the board.We can likely do better again by replacing the
BTreeSet
with a sortedVec
.The text was updated successfully, but these errors were encountered: