Perform startup/init code eagerly in entry::install_crates (#880)

The startup/init code in `entry::install_crates` performs a lot of blocking operations, from testing if dir exists to reading from files and there is no `.await` in there until after the startup.

There are also a few cases where `block_in_place` should be called (e.g. loading manifests, loading TLS certificates) but is missing.

Most of the `Args` passed to `entry::install_crates` are actually consumed before the first `.await` point, so performing startup/init code eagerly would make the generated future much smaller, reduce codegen and also makes it easier to optimize.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-11 15:06:46 +11:00 committed by GitHub
parent 18bc81f46f
commit c5d0b84aa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 98 additions and 90 deletions

View file

@ -32,7 +32,7 @@ fn main() -> MainExit {
let start = Instant::now();
let result = run_tokio_main(entry::install_crates(args, jobserver_client));
let result = run_tokio_main(|| entry::install_crates(args, jobserver_client));
let done = start.elapsed();
debug!("run time: {done:?}");