poem-web / poem

A full-featured and easy-to-use web framework with the Rust programming language.
Apache License 2.0
3.35k stars 267 forks source link

the CompressionAlgo::BR algo is very, very slow > 11s #794

Open rxdiscovery opened 3 months ago

rxdiscovery commented 3 months ago

Hello,

When the browser requests compression with Brotli, the algo used by poem is very slow to generate the compression, taking 11s just to compress the swagger UI page.

it's this algo that's causing the problem : CompressionAlgo::BR

fn custom_compress() -> Compression {
    let algorithms = vec![CompressionAlgo::BR]; // <- ------------ !!!!!!!!!!!!!!!!!!!!!!!
    Compression::new()
        .algorithms(algorithms)
        .with_quality(poem::web::CompressionLevel::Best)
}

especially with one of the compression levels : poem::web::CompressionLevel::Default or poem::web::CompressionLevel::Best

with other algo's there is no slowness, it's instantaneous :

    let algorithms = vec![CompressionAlgo::DEFLATE,CompressionAlgo::GZIP];

(Poem version : 3.0.0)

sunli829 commented 1 month ago

It's really slow, the problem might be with async-compression, I'm not sure.

rxdiscovery commented 1 month ago

@sunli829 try upgrading to the new version "v0.4.10" , maybe this will solve the problem ?!