-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Reuse bytes when cleaning the URL paths #2179
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2179 +/- ##
==========================================
+ Coverage 98.5% 98.51% +<.01%
==========================================
Files 41 41
Lines 2276 2284 +8
==========================================
+ Hits 2242 2250 +8
Misses 18 18
Partials 16 16
Continue to review full report at Codecov.
|
/cc @thinkerou |
Any benchmark report? |
Not yet, but I can add some tests and get benchmark-results later. |
Time cost increases a little bit(maybe those test cases of paths are not general cuz those are mocks) and the memory allocs decreases to 25% when using bytes pool. |
@thinkerou @appleboy |
@panjf2000 maybe you should create PR in https://github.com/julienschmidt/httprouter first. |
Good point, I will open a PR to httprouter later. |
Profiling
Mem:
|
Add ref: julienschmidt/httprouter#292 |
Actually julienschmidt/httprouter@7b49e86 is already added in this PR, only the julienschmidt/httprouter@8e4b52b is missed, I will add it now. |
@panjf2000 thanks. |
@appleboy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* path: use stack buffer in CleanPath to avoid allocs in common case Sync from julienschmidt/httprouter@8222db1 * path: sync test code from httprouter * path: update path_test.go to the latest code Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* path: use stack buffer in CleanPath to avoid allocs in common case Sync from julienschmidt/httprouter@8222db1 * path: sync test code from httprouter * path: update path_test.go to the latest code Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Signed-off-by: Andy Pan panjf2000@gmail.com