reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

`rustls-tls-native-roots` does blocking IO during `.build`

Open chebbyChefNEQ opened this issue 5 months ago • 3 comments

repro Cargo.toml

[package]
name = "test-rs"
version = "0.1.0"
edition = "2021"

[dependencies]
reqwest = { version = "~0.12", default_features = false, features = ["rustls-tls-native-roots"] }
use reqwest::ClientBuilder;

fn main() {
    for _ in 0..10 {
        let start = std::time::Instant::now();
        ClientBuilder::new().build().unwrap();
        println!("built in: {:?}", start.elapsed());
    }
}

this produces the following flamegraph, which include loading certs std::fs.

Not sure what's a nice solution as wrapping the load in tokio::spawn_blocking would introduce a breaking change.

chebbyChefNEQ avatar Sep 27 '24 01:09 chebbyChefNEQ