qichengzx / bitcask

Bitcask is a log-structured fast KV store.
MIT License
15 stars 2 forks source link

index.go 使用 sync.Map 会不会更快 #1

Closed wenjy closed 2 years ago

qichengzx commented 2 years ago
goos: darwin
goarch: amd64
pkg: test/imap
cpu: Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
BenchmarkSyncMapSet
BenchmarkSyncMapSet-6                1920424           891.2 ns/op
BenchmarkSyncMapSet-6                2042548           855.9 ns/op
BenchmarkSyncMapGet
BenchmarkSyncMapGet-6                6582354           152.5 ns/op
BenchmarkSyncMapGet-6                7979156           146.9 ns/op
BenchmarkSampleMapSet
BenchmarkSampleMapSet-6              3584612           373.1 ns/op
BenchmarkSampleMapSet-6              3752061           391.4 ns/op
BenchmarkSampleMapGet
BenchmarkSampleMapGet-6              8030916           168.2 ns/op
BenchmarkSampleMapGet-6              7997119           168.3 ns/op

sync.Map 与 普通 map+mutex 对比,写入无明显性能优势,读取性能提升也不多。