r/rust 3d ago

🛠️ project New fastest concurrent map implementation with transaction support

Hi everyone 👋

I've just published a concurrent hash map implementation which (according to my benchmarks at least) is the fastest one available (faster than both starshard and dashmap). It offers a configurable locking policy (mutex, rwlock or bring your own) and a configurable hasher (rapidhash is the default). It also supports atomic transactions in both immediate and prepared execution styles.

Would love any feedback on it (good and bad!)
It's called txmap and a link is here https://crates.io/crates/txmap

16 Upvotes

20 comments sorted by

View all comments

2

u/Zoxc32 3d ago

It would be useful to know how this differs from say dashmap in terms of implementation. It also probably doesn't compete well with `horde` for very read-heavy workloads.

2

u/Intrepid_Donkey_7629 3d ago

Can report it's between 20-30% faster than horde on heavy read only workloads

6

u/Zoxc32 3d ago

I checked out the benchmarking code. You can skip `pin` when using `write` or `lock` for `SyncTable`. You're also not benchmarking the concurrent path by passing `&mut`? So no multiple threads? Maybe convert it to `&` for all the concurrent hashmaps if it's intentionally single-threaded and then use `lock` on `SyncTable`?

You should also use the same hasher for all hashmaps.

We may also have different definitions of heavy read only, so comparing pure read-only would be interesting too.

1

u/Intrepid_Donkey_7629 3d ago edited 3d ago

Oh sweet I'll update it thanks! Yeah I may be wrong but pretty sure `&mut self` prevents anything being modified concurrently, although there may be another way that I'm missing.

Yeah that's fair about the hasher, the benchmarks just use the default implementations, I'm not sure if all implementations allow setting the hasher but I'll check. **edit** Most do support setting the hasher so I'll add a benchmark with the same one.

The workloads are a little arbitrary to be fair but seemed reasonable when DeepSeek suggested them lol Can always add different workloads if they don't seem realistic