refactor(client): replace futures-cpupool with tokio's thread pool #1514
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The tokio thread pool is already transitively used by the tokio runtime,
so by using it for the DNS as well, the futures-cpupool dependency is
removed without adding a new one.
The code uses tokio-threadpool's
blocking
function which makes thecode very straightforward.
Tokio's thread pool is supposedly faster than futures-cpupool's one.
According to its README, "Why not futures-cpupool? It's 10x slower.".
The user of the library can configure the maximum number of threads for
executing blocking tasks as part of configuring tokio's runtime, which
also holds for any other blocking code besides hyper (e.g. blocking file
operations using tokio-fs ). Hyper no longer needs to concern itself
with that.
BREAKING CHANGE: The
threads
argument is removed fromhyper::client::HttpConnector::new()
andnew_with_handle()
. To setthe maximum amount of threads to use for DNS resolving, configure the
max_blocking
parameter of the tokio runtime instead.The function
hyper::client::HttpConnector::new_with_executor()
isremoved. The thread pool of the tokio runtime is now always used. Use
new()
ornew_with_handle()
instead.