Thincollections, new crate with alternate vector/map/set

https://crates.io/crates/thincollections

This is my first piece of Rust code. I wrote it partly to learn how to work with the heap in Rust, and partly because I needed these for another project.

Checkout the benchmarks for ThinMap here:
https://github.com/mohrezaei/thincollections/blob/v0.5.0/benchmarks/map-results.md

I’d appreciate any feedback.

2 Likes

Cool project! Are there any downsides of these compared to those in the standard library?

ThinVec is very generic and compares quite well with Vec. It’s a tiny bit slower on push if you’re just using it by itself, but it quickly becomes better than Vec if it’s used inside another data structure (e.g. Vec<Vec<_>> or Map<_, Vec<_>>).

ThinMap and ThinSet are special purpose, mostly for primitives, or small key/values. If used as such, they are much better than HashMap/HashSet, with no downsides.

V64 is very special purpose. If you have vectors whose total population is expected to fit in 7 bytes, it’s much faster than Vec, but otherwise, it takes about a 2x hit on push for large vectors (which is not where it’s meant to be used).

2 Likes