Optimize Fetcher::find and fix quickinstall reporting (#579)

* Optimize `Fetcher::find`: Make it non-async to avoid boxing
   and return `AutoAbortJoinHandle<...>` instead.
   
   Since spawning a new task in tokio box the future anyway, boxing the
   returned future again in `Fetcher::find` merely adds unnecessary
   overheads.
* Optimize `QuickInstall::report`: Make it async fn instead of ret `JoinHandle`
   
   This provides several benefits:
    - On debug build, no task will be spawned
    - The calls to `self.stats_url()` can be evaluated in parallel.
    - The task now returns `()` so that the task spawned is smaller.
* Fix `QuickInstall::find`: `warn!` if quickinstall report fails

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-11-30 14:15:22 +11:00 committed by GitHub
parent ff737730f4
commit ab3e47c42b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 84 deletions

View file

@ -20,7 +20,7 @@ use crate::{
drivers::fetch_crate_cratesio,
errors::BinstallError,
fetchers::{Data, Fetcher, TargetData},
helpers::{remote::Client, tasks::AutoAbortJoinHandle},
helpers::remote::Client,
manifests::cargo_toml_binstall::{Meta, PkgMeta, PkgOverride},
};
@ -162,10 +162,7 @@ async fn resolve_inner(
.cartesian_product(resolvers)
.map(|(target_data, f)| {
let fetcher = f(opts.client.clone(), data.clone(), target_data);
(
fetcher.clone(),
AutoAbortJoinHandle::spawn(async move { fetcher.find().await }),
)
(fetcher.clone(), fetcher.find())
}),
);