rust-lang / rust-lang/rust

borrowck is superlinear in the number of values held across an `.await`

Open
#159,943 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

I-compiletime needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

An async fn that holds K values across a single .await spends superlinear time in mir_borrowck — doubling K costs ~6.6x. It is one dropck_outlives call on the coroutine's own type, reached from liveness::trace's dropck of boring locals. In our tree a 2000-line e2e test function costs 0.7s in that single call, and borrow checking is 64% of the crate's compile.

$ git clone https://github.com/ashi009/rustc-async-borrowck-repros && cd rustc-async-borrowck-repros
$ rustc -V
rustc 1.97.1 (8bab26f4f 2026-07-14)
$ time rustc --edition 2021 --crate-type=lib --emit=metadata hold_1000.rs
real 0.17
$ time rustc --edition 2021 --crate-type=lib --emit=metadata hold_2000.rs
real 1.15

drop_K.rs binds the same K values but reads each one before the await instead of after, so none cross a suspension point — it stays linear (0.04s and 0.07s). The types do not matter, and neither do borrows or lifetimes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rustc-async-borrowck-repros cases hold_1000.rs, hold_2000.rs, and drop_K.rs, and reproduce their timings with the shown rustc command. Trace the reported path through mir_borrowck, liveness::trace, and dropck_outlives to identify why coroutine values held across .await scale superlinearly. Done means the hold cases scale approximately linearly without regressing the drop_K cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.