dashmap icon indicating copy to clipboard operation
dashmap copied to clipboard

ensure shard count == # keys

Open amilkov3 opened this issue 2 years ago • 1 comments

much like a sharded db, i have keys that are totally independent of each other so it would be nice to have a way to just make sure that writes to a single key do not block reads or writes to any other key. as far as i understand currently the shard count is calculated based off # of cores. and writes to a key in one shard block all ops to the other keys in that shard?

is this or will this be possible?

amilkov3 avatar Mar 02 '23 20:03 amilkov3

Is this method sufficient?

https://docs.rs/dashmap/latest/dashmap/struct.DashMap.html#method.with_shard_amount

Given that #shards needs to be a power of 2 according to the docs, I'm doubtful that having exactly one shard per key is possible but, having shards == capacity may be.

Otherwise would a try_reshard be better for once you exceed capacity?

imagine-hussain avatar Mar 13 '23 08:03 imagine-hussain