Skip to content

Async statemachine optimisation #623

Open

Description

@tomassedovic
Metadata
Contact @diondokter
Team(s) compiler (@eholk)
Goal document 2026/async-statemachine-optimisation
Funding contact Tweede golf

Summary

Add optimisations to the coroutine MIR transform to elide or simplify the generated statemachines.

This will help both async futures and generators.

Note: This has some overlap with this other proposal.
I'm not trying to usurp the issue. I was working on it incidentally at the same time and noticed very late that proposal already existed.


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
  4. diondokter commented on Jul 17, 2026

    @diondokter
    Member

    MCP for async-panics flag opened: rust-lang/compiler-team#1016

  5. diondokter commented on Sep 3, 2026

    @diondokter
    Member

    Update:
    PR for merging identical yields is almost ready. Expect it next week.

    MCP is still open. Unclear how to proceed. A decision is needed on whether the flag is desired even when panic-immediate-abort reaches the same optimization.

  6. diondokter commented on Sep 7, 2026

    @diondokter
    Member
  7. diondokter commented on Oct 1, 2026

    @diondokter
    Member

    Update:

    The open PR got some reactions, including a review from Amanieu who wishes to see things differently. I'm going to reflect on it and come up with a plan to address it. Might mean it'll be in a new PR.

    I kicked the MCP again and it received a 'second' which means its FCP has started. Once it's accepted I can make the PR that adds the flag. It'll be unstable and I don't yet know what it takes to stabilize it except waiting for half a year or so.

    In the mean time, I've been thinking out the 'single await' optimization. I've jotted down what I think is a workable direction, but it needs more investigation. I don't yet know the relevant parts of the compiler that need touching to implement this.

  8. diondokter commented on Oct 22, 2026

    @diondokter
    Member

    MCP + PR to implement the flag has been merged!
    rust-lang/rust#164683

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions