util: improve BufferPool, eliminate unexpected allocations#407
Open
qianbin wants to merge 2 commits intosyndtr:masterfrom
Open
util: improve BufferPool, eliminate unexpected allocations#407qianbin wants to merge 2 commits intosyndtr:masterfrom
qianbin wants to merge 2 commits intosyndtr:masterfrom
Conversation
Contributor
Author
|
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 |
Contributor
Author
It's limited to 64KB? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: