I was trying to use reqwest, which has a dependency on async-compression, and was getting stack overflows on Windows with some very simple code:
async fn get_bytes_from_url(&self, url: &str) -> Option<Bytes> {
let response = reqwest::get(url).await.ok()?.error_for_status().ok()?;
response.bytes().await.ok()
}
After investigating, I discovered that bytes() returns a future which contains an enum that holds the appropriate decoder for the current protocol is. That enum is over 2kb in size because BrotliDecoder is 2592 bytes by itself:

Which is significantly larger than any of the other decoders offered by this crate:
| Type |
Size (bytes) |
BrotliDecoder |
2592 |
GzipDecoder |
120 |
ZlibDecoder |
32 |
Would it be possible to Box the decoder state to shrink the size of BrotliDecoder? I know BrotliDecoder really just wraps the brotli_decompressor crate but it doesn't seem very active so I thought I would start by asking here first. 🙂
I was trying to use
reqwest, which has a dependency onasync-compression, and was getting stack overflows on Windows with some very simple code:After investigating, I discovered that
bytes()returns a future which contains an enum that holds the appropriate decoder for the current protocol is. That enum is over 2kb in size becauseBrotliDecoderis 2592 bytes by itself:Which is significantly larger than any of the other decoders offered by this crate:
BrotliDecoderGzipDecoderZlibDecoderWould it be possible to
Boxthe decoder state to shrink the size ofBrotliDecoder? I knowBrotliDecoderreally just wraps thebrotli_decompressorcrate but it doesn't seem very active so I thought I would start by asking here first. 🙂