-
Notifications
You must be signed in to change notification settings - Fork 271
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
CompressHandler: Ignore MIME types, re-use writers via sync.Pool #44
Comments
In addition:
|
+1 |
#48 has likely made this much harder now due to the limitations around defining a global pool:
var gzipPool = sync.Pool{
// Can't pass the level when we call New()
New: func() interface{} {
return gzip.NewWriter(nil)
},
}
Is there a solution here that I'm missing? I think this PR had more value as changing gzip levels should be done with caution in a HTTP context, but a pooled gzip writer nets everyone a performance gain, but unfortunately that's how things have shaken out. @kisielk - would appreciate your feedback/input here. |
How about a separate pool for every compression level? There's only 11 of them and the size overhead for a pool is not that large. |
👍 |
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days. |
Note: raising this as an issue half as a reminder to address this, and to provide someone a chance to get to it before I can.
As per this great article on gzip performance: http://blog.klauspost.com/gzip-performance-for-go-webservers/
gzip.NewWriter
via async.Pool
(being very conscious of the need to explicitlyReset()
items coming out of the pool)Content-Type
header here: https://github.com/gorilla/handlers/blob/master/compress.go#L30-L38 - also see here for relevant types: https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-CloudFlare-gzip-Quick example:
I'll update here before I begin work in earnest, but it won't be until after the weekend as I need to submit patches to the sessions stores first. If someone wants to pick this up before then (it's fairly straightforward patch) then just say so. Happy to guide you in writing tests as well.
The text was updated successfully, but these errors were encountered: