-
Notifications
You must be signed in to change notification settings - Fork 94
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
use BTreeMap as backing store for objects #231
Conversation
Two more benchmarks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very impressive! I think it's a great change for now. Real world workloads could of course end up behaving differently. But the outcomes with the existing benchmarks are about as close as we'll get to these for now.
Thank you!
crates/runestick/src/object.rs
Outdated
use crate::{ | ||
FromValue, InstallWith, Item, Mut, Named, RawMut, RawRef, RawStr, Ref, ToValue, | ||
UnsafeFromValue, Value, Vm, VmError, | ||
}; | ||
use std::borrow; | ||
use std::cmp; | ||
use std::collections::BTreeMap as HashMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe alias it to something more... neutral? :)
Aye, will fix the name. Do you care to repro the improvement on your machine? |
I.e.
You might need to add me as a remote, not sure if fetches PRs. |
Can confirm:
|
@udoprog Thanks! Updated the PR to re-expoert BTreeMap from the root crate like the other collections. Good to go? |
Yep! Merge whenever you feel like it. |
I've tried a dozen different methods here to see if I can improve some usages, and this seems to be the simplest and most stupid one: simply switch backing storage. I think the tradeoff here is that since BTreeMaps use cmp::Ord instead of cmp::Eq, we have to prefix search at each node of the BTree, so if there's a common prefix to members lookups will increase in cost.
Overall these results are expected: the brainfuck interpreter relies heavily on
self
so I'd expect it to improve, and the fibonnaci is pure recursive calls and should be unaffected. I cannot motivate why aoc_2020_{1a, 1b} got faster, however, nor that 11a does not improve... It might just be completely overshadowed by some other operation.@udoprog it'd be interesting to see if you can replicate similar gains.
Methods I've also tried:
This version has: