Description
I upgraded from 1.45 to 1.46 today and a crate I'm working on seems to hang forever while compiling. I've attempted to create a somewhat minimal test case. For convenience here's a repo that includes the code below: https://github.com/nicholasbishop/rust146hang
Cargo.toml:
[package]
name = "rust146hang"
version = "0.1.0"
edition = "2018"
[dependencies]
actix-web = "2.0"
bb8 = "0.4"
bb8-postgres = "0.4"
tokio-postgres = "0.5"
src/lib.rs:
use actix_web::{web, HttpResponse, Responder};
use bb8_postgres::PostgresConnectionManager;
use tokio_postgres::NoTls;
type Pool = bb8::Pool<PostgresConnectionManager<NoTls>>;
async fn handle_req_1(pool: &Pool) {
let conn = pool.get().await.unwrap();
conn.query_one("", &[]).await.unwrap();
}
async fn handle_req_2(pool: &Pool) {
handle_req_1(pool).await;
}
async fn handle_req_3(pool: &Pool) {
handle_req_2(pool).await;
}
async fn handle_req_4(pool: &Pool) {
handle_req_3(pool).await;
}
async fn handle_req_5(pool: &Pool) {
handle_req_4(pool).await;
}
async fn handle_req_final(pool: web::Data<Pool>) -> impl Responder {
handle_req_5(pool.get_ref()).await;
HttpResponse::Ok().finish()
}
pub fn app_config(config: &mut web::ServiceConfig) {
config.service(
web::scope("").route("/api", web::post().to(handle_req_final)),
);
}
I've found that the slowness seems tied to the depth of the async call chain. In the example code I have a long call chain: handle_req_1
is called by handle_req_2
is called by handle_req_3
, etc. Here's the compilation timing I've observed when changing handle_req_final
to directly call one of the handle_req_N
functions:
handle_req_1 -> 0m12s
handle_req_2 -> 0m28s
handle_req_3 -> 1m06s
handle_req_4 -> 2m18s
handle_req_5 -> 5m01s
These times only include building the rust146hang lib, not the dependencies.
(Caveat: unscientific timings, these are not averaged over multiple
runs or anything.)
$ cargo --version
cargo 1.46.0 (149022b1d 2020-07-17)
$ rustc --version
rustc 1.46.0 (04488afe3 2020-08-24)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status