Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`sync.Once` uses an atomic integer as gate to check if the slab is already initialized and therefore yields a ~9% performance improvement for `get` operations. ``` goos: linux goarch: amd64 pkg: github.com/grafana/loki/v3/pkg/util/mempool cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz │ bench.old │ bench.new │ │ sec/op │ sec/op vs base │ Slab/1KB-8 138.5n ± 2% 125.1n ± 2% -9.71% (p=0.000 n=10) Slab/1MB-8 140.5n ± 3% 128.1n ± 2% -8.83% (p=0.000 n=10) Slab/128MB-8 143.0n ± 3% 130.4n ± 3% -8.81% (p=0.000 n=10) geomean 140.7n 127.8n -9.12% ``` Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
- Loading branch information