diff --git a/lib/storage/partition.go b/lib/storage/partition.go index c61e281f1..ddd13fc48 100644 --- a/lib/storage/partition.go +++ b/lib/storage/partition.go @@ -869,10 +869,18 @@ func hasActiveMerges(pws []*partWrapper) bool { } var ( - bigMergeWorkersCount = (cgroup.AvailableCPUs() + 1) / 2 - smallMergeWorkersCount = (cgroup.AvailableCPUs() + 1) / 2 + bigMergeWorkersCount = getDefaultMergeConcurrency(4) + smallMergeWorkersCount = getDefaultMergeConcurrency(8) ) +func getDefaultMergeConcurrency(max int) int { + v := (cgroup.AvailableCPUs() + 1) / 2 + if v > max { + v = max + } + return v +} + // SetBigMergeWorkersCount sets the maximum number of concurrent mergers for big blocks. // // The function must be called before opening or creating any storage.