Choosing a concurrent map #113
-
Hi, First, thank you for this fantastic crate! I particularly appreciate how well-documented things are. On that note, I'm working on a crate that provides HTTP sessions as a I'm currently using For that last reason, it seems That said, I'm even less sure about what overhead I'm curious if someone might be able to shed some light on an overhead comparison between |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
Hi! Nice to hear that you're considering this crate for your project. So, first and foremost, I'd like to start with There, you'll have to measure the expected number of sessions in the in-memory cache. For instance, if the system has 32 CPU cores, and the expected number of cached sessions is 2048, In short, I'd say that which concurrent hash map implementation is better is totally dependent on the type of workloads and the system that the service is aimed at. Now, the second topic, garbage collection, you really don't need to care about it unless you're considering To be specific, the EBR garbage collector will kick in after an instance of -> Here, one significant difference between In summary, in terms of 'latency', the overhead of garbage collection should not be observable, however, in terms of |
Beta Was this translation helpful? Give feedback.
Hi!
Nice to hear that you're considering this crate for your project.
So, first and foremost, I'd like to start with
dashmap
's sharding vs the fine-grained locking mechanism inscc::HashMap
. From my understanding, the number of shards in adashmap
instance is determined at runtime by querying the number of cores in the system; say, if the system has 32 CPU cores, the number of shards will be 32, and the number of locks in thedashmap
instance is fixed to 32. On the other hand, the number of locks in ascc::HashMap
instance is not fixed, and relates to the number of entries in it; you can approximate it byexpected number of entries * 2 / 32
where 2 comes from the fact that the average loa…