Skip to content

Async Future Memory Optimisation #622

Open

Description

@tomassedovic
Metadata
Contact @dingxiangfei2009
Team(s) compiler (@tmandry)
Goal document 2026/async-future-memory-optimisation

Summary

We want to solve async-future memory bloat problem.

Playground

async fn combining_future(compute: impl Future<Output = ()>) {
    async {}.await;
    compute.await;
}

fn main() {
    let blob = [0u8; 65536];
    let monster = combining_future(combining_future(combining_future(combining_future(async move {
        async {}.await;
        println!("{:?}", blob)
    }))));
    println!("{}", std::mem::size_of_val(&monster));
    //~^ prints at least 1000000 bytes
}

We would like to deliver the first async-future memory packing scheme -Zpack-coroutine-layout as a nightly-only compiler flag, followed by a more aggressive memory packing scheme built on top of the foundation of the first pack-coroutine-layout support. Meanwhile, we would like to conduct two experiments in two possible approaches that could further improve the memory economy of async-futures.

  • Explore the memory layout optimisation by enabling coroutine state inlining.
  • Explore direct lowering of Rust async-futures, and coroutines in particular, into native LLVM coroutine intrinsics.

This issue is intended for status updates only.

For general questions or comments, please contact a goal owner or post in the Zulip topic.

Activity

  1. added this to the 2026 milestone on May 5, 2026
  2. tomassedovic commented on May 5, 2026

    @tomassedovic
    ContributorAuthor

    This issue is intended for status updates only.

    For general questions or comments, please contact the owner(s) directly.

  3. locked and limited conversation to collaborators on May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions