concurrent-map
concurrent-map copied to clipboard
Suggest that concurrent-map would use custom shard_count for each instance
Hello, concurrent-map maintainers :)
I accidentally found this concurrent-map repository, which looks very cool!
Me and one of my team members suggested how to use custom SHARD_COUNT for each concurrent map instance instead of global SHARD_COUNT.
It looks like this one.
// A "thread" safe map of type string:Anything.
// To avoid lock bottlenecks this map is dived to several (SHARD_COUNT) map shards.
type ConcurrentMap[K comparable, V any] struct {
shards []*ConcurrentMapShared[K, V]
sharding func(key K) uint32
shardCount uint32 // <- THIS IS ADDED
}
I'll submit my source code for it on PR, could you please review my changes? Thanks!
Yeah, Honestly having this lever will enable users to tune the number according to their concurrency needs and memory overhead threshold.