Async Rust Never Left MVP State, Needs Compiler Optimization

Original: Async Rust never left the MVP state

Why This Matters

Highlights critical performance issues in Rust's async implementation affecting embedded development

Tweede Golf engineer Dion argues async Rust generates excessive binary bloat, particularly on microcontrollers. The bar function produces 360 MIR lines versus 23 for non-async code. A Project Goal was submitted to address compiler optimization needs for async code generation.

Dion from Tweede Golf explains that async Rust creates significant binary bloat, especially problematic for embedded systems where every byte matters. While async Rust enables executor-agnostic code across servers and microcontrollers, it fails to deliver promised zero-cost abstractions. Analysis shows a simple bar function generates 360 lines of MIR compared to 23 lines for equivalent non-async code. The generated state machine includes multiple states: Unresumed, Returned, Panicked, and suspend points for each await. The Returned and Panicked states exist for safety - ensuring Future::poll doesn't cause undefined behavior when called on completed futures. Dion has submitted a Project Goal to address these compiler optimization issues at the root level, seeking funding for the effort. This represents part 2 of a blog series examining async Rust internals and potential compiler improvements.

Source

tweedegolf.nl — Read original →