Skip to content

BrotliDecoder type is very large #172

@wesleywiser

Description

@wesleywiser

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:

image

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. 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions