4 ms·
Have also a look at concurrent_map. It is a concurrent BTreeMap, this means it maintains key order (not insertion order but the keys implement Ord). https://li
by _nalply 2y ago
Have also a look at concurrent_map. It is a concurrent BTreeMap, this means it maintains key order (not insertion order but the keys implement Ord).
https://lib.rs/crates/concurrent-map https://lib.rs/crates/concurrent-map
I am using it for a transactional in-memory key-value store experiment.
- ibraheemdev 2y agoLooks very interesting, but seems to serve a pretty different use case: > This is an ordered data structure, and supports very high throughput iteration over lexicographically sorted ranges of values. If you are looking for simple point operation performance, you may find a better option among one of the many concurrent hashmap implementations that are floating around. Pay for what you actually use :)
- CyberDildonics 2y agoIf you just need a key-value data concurrent data structure it should be much faster and scale better to have a hash map instead of something that is keeping a sorted order.
- _nalply 2y agoDifferent use cases. An ordered map shines if you need some ordering of keys. One use case is an ordered index, for example if you have an age index and need to list only adult people. A hashmap won't work here, I think. So just use a DBMS, but if you don't want, perhaps this ordered concurrent map.
- CyberDildonics 2y agoDid you think my comment said that there is no use for an ordered map? You seem to be listing basic uses for a fundamental data structure. You said you were using it for a "key-value store". If all you need is a key value lookup, all you need is a hash map. When it comes to concurrency the difference is even more pronounced because hash maps can have lots of concurrent IO due to working on different parts of memory that are mostly independent of each other while a sorted data structure is going to have to move things around, which means more atomic swapping, which means more chances for collisions or race conditions where other threads are going to have to retry their compare and swaps or back off and try parts of their operation again.