timothee-haudebourg / btree-range-map

B-tree range map implementation for Rust
11 stars 1 forks source link

Comparison to other techniques #3

Open grovesNL opened 1 year ago

grovesNL commented 1 year ago

Hi! Thank you for publishing this crate. I currently use a BTreeMap<u64, u64> for ranges and have been looking for a better alternative, so RangeMap looks like it might be a great fit.

While I was looking for alternatives, I also came across some other types like the Maple Tree type used for virtual memory allocators in Linux (i.e., allocating disjoint memory ranges), some different approaches based on radix trees, and other approaches trying to use some variations of red-black trees that make use of the range end for queries.

I was wondering if you've done any rough performance comparisons or have any intuition about how any of these (including BTreeMap) might perform against RangeMap? Over time I'd like to investigate more approaches in general, but just curious if you already have some idea of how they might compare based on the trade-offs they're making (maybe for the average case where there are many reads per write).

timothee-haudebourg commented 1 year ago

RangeMap is a btree implementation so I expect it to have roughly the same performances as BTreeMap (with a way better mamoery usage of course). I'm also using a slab to store tree nodes, which means less memory allocations. But no I have never run benchmarks or compared with other techniques because I needed two specific features that no one else provided (at least when I started implementing this, I don't know now):

Because of this second item, the logic of comparing range bounds is a bit more complex and may slow down the computation.