-
Notifications
You must be signed in to change notification settings - Fork 967
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
util: improve BufferPool, eliminate unexpected allocations #407
base: master
Are you sure you want to change the base?
Conversation
The buffer pool is now mainly for reusing block read/write buffers. After #367 merged, the baseline does not work well as wish. Last two commits simplify BufferPool and highly increase the reuse rate of pooled buffers. The raw benchmark output files: master.txt, pr.txt Benchstat:
|
Could you check this allocator? https://github.com/xtaci/smux/blob/master/alloc.go |
It's limited to 64KB? |
Using sync.Pool to manage bare slices is not the proper way, since it'll bring unexpected allocations. This PR solves this problem with small tricks and makes BufferPool a bit faster.
benchmarks: