Closed cristaloleg closed 6 years ago
BenchmarkHTTPCacheMamoryAdapterSetParallel-4 ================== WARNING: DATA RACE Read at 0x00c4200ca030 by goroutine 27: github.com/victorspringer/http-cache/adapter/memory.(*Adapter).Set() /Users/olegkovalov/go/src/github.com/victorspringer/http-cache/adapter/memory/memory.go:81 +0x57 github.com/victorspringer/http-cache/adapter/memory/benchmark.BenchmarkHTTPCacheMamoryAdapterSetParallel.func1() /Users/olegkovalov/go/src/github.com/victorspringer/http-cache/adapter/memory/benchmark/benchmark_comparison_test.go:63 +0x138 testing.(*B).RunParallel.func1() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:623 +0x156 Previous write at 0x00c4200ca030 by goroutine 26: runtime.mapassign_fast64() /usr/local/Cellar/go/1.10.1/libexec/src/runtime/hashmap_fast.go:522 +0x0 github.com/victorspringer/http-cache/adapter/memory.(*Adapter).Set() /Users/olegkovalov/go/src/github.com/victorspringer/http-cache/adapter/memory/memory.go:88 +0xd4 github.com/victorspringer/http-cache/adapter/memory/benchmark.BenchmarkHTTPCacheMamoryAdapterSetParallel.func1() /Users/olegkovalov/go/src/github.com/victorspringer/http-cache/adapter/memory/benchmark/benchmark_comparison_test.go:63 +0x138 testing.(*B).RunParallel.func1() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:623 +0x156 Goroutine 27 (running) created at: testing.(*B).RunParallel() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:616 +0x24b github.com/victorspringer/http-cache/adapter/memory/benchmark.BenchmarkHTTPCacheMamoryAdapterSetParallel() /Users/olegkovalov/go/src/github.com/victorspringer/http-cache/adapter/memory/benchmark/benchmark_comparison_test.go:59 +0x1de testing.(*B).runN() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:141 +0x127 testing.(*B).launch() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:290 +0xb2 Goroutine 26 (running) created at: testing.(*B).RunParallel() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:616 +0x24b github.com/victorspringer/http-cache/adapter/memory/benchmark.BenchmarkHTTPCacheMamoryAdapterSetParallel() /Users/olegkovalov/go/src/github.com/victorspringer/http-cache/adapter/memory/benchmark/benchmark_comparison_test.go:59 +0x1de testing.(*B).runN() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:141 +0x127 testing.(*B).launch() /usr/local/Cellar/go/1.10.1/libexec/src/testing/benchmark.go:290 +0xb2 ================== --- FAIL: BenchmarkHTTPCacheMamoryAdapterSetParallel-4 benchmark.go:147: race detected during execution of benchmark
In the "Set" method I wasn't locking before store length check, it's been already fixed. Thanks for the advise!