RedisShake
RedisShake copied to clipboard
refactor: Use sync.Pool to reuse the []byte with specific length
在 #747 后,可以对 RDB Parse 做个基准 Benchmark
原本直觉上 ParseRDB 的频繁小内存分配会成为内存瓶颈,但是实际上池化的代价更大一些
# before
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
BenchmarkParseRDB-16 20 150637274 ns/op 213802609 B/op 1900710 allocs/op
BenchmarkParseRDB-16 20 155507008 ns/op 213802064 B/op 1900714 allocs/op
BenchmarkParseRDB-16 20 151941175 ns/op 213801739 B/op 1900715 allocs/op
BenchmarkParseRDB-16 20 151335552 ns/op 213801515 B/op 1900718 allocs/op
BenchmarkParseRDB-16 20 148564198 ns/op 213801514 B/op 1900716 allocs/op
# after
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
BenchmarkParseRDB-16 40 152801292 ns/op 212345090 B/op 1481219 allocs/op
BenchmarkParseRDB-16 40 159080792 ns/op 212362787 B/op 1481263 allocs/op
BenchmarkParseRDB-16 40 158858734 ns/op 212349859 B/op 1481234 allocs/op
BenchmarkParseRDB-16 40 157454181 ns/op 212330968 B/op 1481179 allocs/op
BenchmarkParseRDB-16 40 156932052 ns/op 212318951 B/op 1481155 allocs/op