lib/blockcache: fix TestCache by ensuring that the cache size can be divided by the number of cache shards

Fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2204
This commit is contained in:
Aliaksandr Valialkin 2022-02-16 18:46:22 +02:00
parent 6ff71474a6
commit 5366d9be73
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -4,10 +4,17 @@ import (
"fmt"
"sync"
"testing"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/cgroup"
)
func TestCache(t *testing.T) {
const sizeMaxBytes = 1024 * 1024
sizeMaxBytes := 64 * 1024
// Multiply sizeMaxBytes by the square of available CPU cores
// in order to get proper distribution of sizes between cache shards.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2204
cpus := cgroup.AvailableCPUs()
sizeMaxBytes *= cpus * cpus
getMaxSize := func() int {
return sizeMaxBytes
}