-
Notifications
You must be signed in to change notification settings - Fork 17.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
proposal: net/http: add support for RFC8878 Content-Encoding: zstd
to http.DefaultTransport
#62492
Comments
Content-Encoding: zstd
to http.DefaultClient
Content-Encoding: zstd
to http.Client
It would be weird to do this before internal/zstd is exposed publicly. Probably it should be moved to compress/zstd first. |
I don't think so, see how the std handles http2 for example. |
They are really quite different, I don't think this would be reasonably possible. I also don't think it's a concern. |
Agreed. Ideally we would implement support for both compressing and decompressing in |
I filed #62513 to add |
Brotli use more CPU than Zstd, Zstd also supports adaptative compression to efficiently use both the CPU and IO resources. |
That's technically an artifact of the implementation, not the compression format. Theoretically, gzip and brotli could do the same thing. A major problem with Brotli is the use of a 120KiB static dictionary. This bars its use from any embedded application. It also forces any Go implementation to bloat by 120KiB. |
could there be some kind of hook for adding content encodings so you could opt in to compression formats with large static dictionaries, like |
I am extremely not convinced that 120KiB is a problem, see above Even if you |
A good chunk of that is due to transitive dependencies on "fmt" and "encoding/binary", both of which pull in "reflect". Modifying the code to remove those dependencies drops the linked in size to 100KiB. |
Shared dictionary support for brotli is trialing in Chrome 117. And shared dictionaries for zstd trialing in 118. https://github.com/WICG/compression-dictionary-transport |
Personally I'm happy if any of the two "better than gzip" mechanisms gets support in the standard library. By compressing |
Content-Encoding: zstd
to http.Client
Content-Encoding: zstd
to http.DefaultTransport
|
I think @silverwind is referring to Brotli (RFC 7932) and Zstandard (RFC 8878) with regard to the two "better than gzip" algorithms.
|
Chrome has turned this on by default https://chromestatus.com/feature/6186023867908096 |
Currently the default http transport will magically send
Accept-Encoding: gzip
header and handle decompression if the consumer is not handling that themselves.Chrome recently added opt-in support for
Content-Encoding: zstd
https://chromestatus.com/feature/6186023867908096.I propose that the default transport sends
Accept-Encoding: gzip, zstd
and handles the decompression following the same logic that gzip have.Implementation wise
internal/zstd
's performance sounds good enough, for a rough estimation I copied theBenchmarkLarge
frominternal/zstd
and made acompress/gzip
version, the compression ratio were 3.21 vs 3.24 respectively (very comparable) and on my Ryzen 3600 CPU the output's throughput are really similar:Neither is a particularly high performance implementation, but if
compress/gzip
is good enough zstd should also be (except maybe for memory usage ?).Addinginternal/zstd
to a binary adds469KiB
with 2186909. I guess this could be optimized by sharing some of the lz77 routines between gzip and zstd if this were a concern.This is true but missleading, most of it is
reflect
.Tested with (
GOOS=linux GOARCH=amd64 GOAMD64=v3
and without stripping debug information):The text was updated successfully, but these errors were encountered: