seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.92k stars 1.13k forks source link

Feature request: singlethreaded mode #299

Open vi opened 6 years ago

vi commented 6 years ago

Can reqwest work without threading?

$ strace -cc -f target/release/reqwest-get-test > /dev/null
strace: Process 10619 attached
strace: Process 10620 attached
strace: Process 10621 attached
strace: Process 10622 attached
strace: Process 10623 attached
strace: Process 10624 attached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 83.33    0.050000         617        81         8 futex

If reqwest is used just to make one little puny REST request, it looks like overkill to bring up all that machinery.

This may make easier to embed reqwest-using libraries into other [non-Rust] applications.

seanmonstar commented 6 years ago

I'm sure it's possible. However, it's not a goal I'd personally strive for. If someone wanted to do the work to get something like that, cool!

reqwest creates at least 1 extra thread so that it can run multiple requests in parallel. It creates 4 additional threads as workers for blocking DNS. With some work, we could eventually have non-blocking DNS, and thus not need separate threads for it.

vi commented 6 years ago

It makes sence if the program is going to issue more than one request. If it is a little command-line tool that just does some one request, another approach may be preferrable.

lnicola commented 5 years ago

@vi you can get that using the trust-dns feature, at the cost of increased binary size and longer build times.