-
Notifications
You must be signed in to change notification settings - Fork 129
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
Use gzipWriterPools index rather then gzip level in GzipResponseWriter #20
Use gzipWriterPools index rather then gzip level in GzipResponseWriter #20
Conversation
This still looks like the index is getting calculated on every request as Have you run benchmarks to check if there are any significant improvements? |
I'll change when the index is calculated to when the function is first called and will add some benchmarks. |
Could you also please provide some context as to the reasoning behind this change? |
This removes the need to calculate the index twice on every request. benchmark old ns/op new ns/op delta BenchmarkGzipHandler_S2k-8 84140 85446 +1.55% BenchmarkGzipHandler_S20k-8 429932 433044 +0.72% BenchmarkGzipHandler_S100k-8 2147390 2115058 -1.51% BenchmarkGzipHandler_P2k-8 21868 21994 +0.58% BenchmarkGzipHandler_P20k-8 103495 103410 -0.08% BenchmarkGzipHandler_P100k-8 518237 503005 -2.94% benchmark old allocs new allocs delta BenchmarkGzipHandler_S2k-8 20 20 +0.00% BenchmarkGzipHandler_S20k-8 23 23 +0.00% BenchmarkGzipHandler_S100k-8 25 25 +0.00% BenchmarkGzipHandler_P2k-8 20 20 +0.00% BenchmarkGzipHandler_P20k-8 23 23 +0.00% BenchmarkGzipHandler_P100k-8 25 25 +0.00% benchmark old bytes new bytes delta BenchmarkGzipHandler_S2k-8 6136 5770 -5.96% BenchmarkGzipHandler_S20k-8 46340 46055 -0.62% BenchmarkGzipHandler_S100k-8 205909 201839 -1.98% BenchmarkGzipHandler_P2k-8 6235 6197 -0.61% BenchmarkGzipHandler_P20k-8 48350 48611 +0.54% BenchmarkGzipHandler_P100k-8 225116 224954 -0.07%
The main reason behind the change is to not calculate the pool index on every request, but only when NewGzipLevelHandler is called. This increase the performance a little bit, see the benchmarks in the commit. |
It looks like the latest commit you've pushed does what you're looking for as it now calls Now you just need to clean up the rename from |
This removes the need to calculate the index twice on every request. benchmark old ns/op new ns/op delta BenchmarkGzipHandler_S2k-8 84140 85446 +1.55% BenchmarkGzipHandler_S20k-8 429932 433044 +0.72% BenchmarkGzipHandler_S100k-8 2147390 2115058 -1.51% BenchmarkGzipHandler_P2k-8 21868 21994 +0.58% BenchmarkGzipHandler_P20k-8 103495 103410 -0.08% BenchmarkGzipHandler_P100k-8 518237 503005 -2.94% benchmark old allocs new allocs delta BenchmarkGzipHandler_S2k-8 20 20 +0.00% BenchmarkGzipHandler_S20k-8 23 23 +0.00% BenchmarkGzipHandler_S100k-8 25 25 +0.00% BenchmarkGzipHandler_P2k-8 20 20 +0.00% BenchmarkGzipHandler_P20k-8 23 23 +0.00% BenchmarkGzipHandler_P100k-8 25 25 +0.00% benchmark old bytes new bytes delta BenchmarkGzipHandler_S2k-8 6136 5770 -5.96% BenchmarkGzipHandler_S20k-8 46340 46055 -0.62% BenchmarkGzipHandler_S100k-8 205909 201839 -1.98% BenchmarkGzipHandler_P2k-8 6235 6197 -0.61% BenchmarkGzipHandler_P20k-8 48350 48611 +0.54% BenchmarkGzipHandler_P100k-8 225116 224954 -0.07%
…zipresponsewriter-index
The commits are a bit messed up, but when I try to squash them it messes up the code. This is what happened the first time, that's why I pushed broken code. |
This looks better, thanks! I'll deal with squashing the commits via the merge button. |
🎉 💯 |
Thanks |
This removes the need to calculate the index on every request.