concurrent-map icon indicating copy to clipboard operation
concurrent-map copied to clipboard

Suggest that concurrent-map would use custom shard_count for each instance

Open SeunghoonBaek opened this issue 2 years ago • 1 comments

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!

SeunghoonBaek avatar May 04 '23 08:05 SeunghoonBaek

Yeah, Honestly having this lever will enable users to tune the number according to their concurrency needs and memory overhead threshold.

pavan-aeturi avatar Aug 06 '24 04:08 pavan-aeturi