lib/mergeset: use more rawItemsShard shards on multi-CPU systems

This should improve the scalability for registering of new time series on multi-CPU system
This commit is contained in:
Aliaksandr Valialkin 2022-04-06 19:35:50 +03:00
parent ad35068c3a
commit 7bad7133bc
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -125,9 +125,16 @@ type rawItemsShards struct {
// The number of shards for rawItems per table.
//
// Higher number of shards reduces CPU contention and increases the max bandwidth on multi-core systems.
var rawItemsShardsPerTable = cgroup.AvailableCPUs()
var rawItemsShardsPerTable = func() int {
cpus := cgroup.AvailableCPUs()
multiplier := cpus
if multiplier > 16 {
multiplier = 16
}
return (cpus * multiplier + 1) / 2
}()
const maxBlocksPerShard = 512
const maxBlocksPerShard = 256
func (riss *rawItemsShards) init() {
riss.shards = make([]rawItemsShard, rawItemsShardsPerTable)