Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use sync.Pool to reuse the []byte with specific length #749

Draft
wants to merge 5 commits into
base: v4
Choose a base branch
from

Conversation

Zheaoli
Copy link
Collaborator

@Zheaoli Zheaoli commented Jan 1, 2024

#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

@Zheaoli Zheaoli marked this pull request as draft January 1, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant