Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
marginal improvement: atomic byte-counts
Eliminate an extra lock/unlock on the eviction path by making the `nbytes` field atomic. This produces some marginal performance improvements. e.g. here are the benchmark results from my laptop: ``` [atomic_bytecount] % go test -benchtime 30s -bench . . goos: linux goarch: amd64 pkg: github.com/vimeo/galaxycache cpu: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz BenchmarkGetsSerialOneKey-4 19998571 1849 ns/op 1536 B/op 28 allocs/op BenchmarkGetsSerialManyKeys-4 10693790 3401 ns/op 2394 B/op 46 allocs/op BenchmarkGetsParallelManyKeys-4 12335263 2872 ns/op 2381 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/1-4 12733614 2967 ns/op 2382 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/2-4 12099810 2755 ns/op 2379 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/4-4 13770105 2689 ns/op 2378 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/8-4 13695392 2717 ns/op 2374 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/16-4 12850902 2745 ns/op 2367 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/32-4 13667977 2749 ns/op 2356 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/64-4 13518266 2917 ns/op 2330 B/op 44 allocs/op PASS ok github.com/vimeo/galaxycache 398.172s go test -benchtime 30s -bench . . 1201.40s user 37.27s system 309% cpu 6:39.64 total 2022-08-03 11:55:31 ($? = 0) [master] % go test -benchtime 30s -bench . . goos: linux goarch: amd64 pkg: github.com/vimeo/galaxycache cpu: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz BenchmarkGetsSerialOneKey-4 20515902 1852 ns/op 1536 B/op 28 allocs/op BenchmarkGetsSerialManyKeys-4 10534585 3448 ns/op 2395 B/op 46 allocs/op BenchmarkGetsParallelManyKeys-4 11663724 2968 ns/op 2382 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/1-4 12227192 2956 ns/op 2380 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/2-4 12722972 2972 ns/op 2378 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/4-4 10123365 3382 ns/op 2379 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/8-4 11134406 3433 ns/op 2375 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/16-4 12949555 3012 ns/op 2367 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/32-4 12999852 2946 ns/op 2351 B/op 45 allocs/op BenchmarkGetsParallelManyKeysWithGoroutines/64-4 13319569 3028 ns/op 2325 B/op 44 allocs/op PASS ok github.com/vimeo/galaxycache 406.806s go test -benchtime 30s -bench . . 1166.79s user 37.50s system 295% cpu 6:47.19 total ```
- Loading branch information