From 310722430609fd169b81ca4232839f561975de17 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 16 Feb 2022 18:46:22 +0200 Subject: [PATCH] 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 --- lib/blockcache/blockcache_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/blockcache/blockcache_test.go b/lib/blockcache/blockcache_test.go index adbb4a760..362f9cf59 100644 --- a/lib/blockcache/blockcache_test.go +++ b/lib/blockcache/blockcache_test.go @@ -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 }