mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
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:
parent
63bc89dd81
commit
3107224306
1 changed files with 8 additions and 1 deletions
|
@ -4,10 +4,17 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/cgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCache(t *testing.T) {
|
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 {
|
getMaxSize := func() int {
|
||||||
return sizeMaxBytes
|
return sizeMaxBytes
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue