Files
VictoriaMetrics/lib/atomicutil/cacheline.go
Aliaksandr Valialkin 539498058e lib/atomicutil: add CacheLineSize const equal to the size of CPU cache line, and use this const for padding against false sharing across the code base
This should reduce the waste of memory on the padding from 128 bytes to 64 bytes on GOARCH=amd64,
while preserving bigger padding for platforms with bigger cache line sizes.

See https://stackoverflow.com/questions/68320687/why-are-most-cache-line-sizes-designed-to-be-64-byte-instead-of-32-128byte-now

Thanks to @tIGO for the hint
2025-06-06 10:21:40 +02:00

11 lines
172 B
Go

package atomicutil
import (
"unsafe"
"golang.org/x/sys/cpu"
)
// CacheLineSize is the size of a CPU cache line
const CacheLineSize = unsafe.Sizeof(cpu.CacheLinePad{})