Async Rust never left the MVP state

68 points by radim


tobin_baker

This article is far more constructive than I expected from the title.

proctrap

I want to work on this in the compiler and as such have submitted it as a Project Goal

Stop generating statemachines that don’t have to be there
Make the compiler’s job easier by removing panic paths and branches
Make statemachines smaller

Love to see this getting tackled - I've seen a couple posts that rustc is currently throwing a bit too much code at LLVM and praying for the optimizers to catch it all. Notably this one here asks for help in funding for the work.

dijit

Gods I'm stupid.

I always presumed async was inherently "bloated" because it requires some kind of runtime, task tracking and "polling" for completions. That overhead is nonzero.

I assumed that "Zero cost abstractions" in this sense was purely about the functions of the language and not to do with any bolted-on runtimes.

It never even occurred to me to look at what rustc emits before it hits LLVM...

dpercy

Panics are relatively expensive. They introduce a path with a side-effect that's not easily optimized out. What if instead, we just return Pending again? Nothing unsafe going on, so we fulfill the contract of the Future type.

In debug builds it would still panic so that wrong behavior is immediately visible, but in release builds we get smaller futures.

In release builds if this case is reached, would you get some kind of deadlock? Or a leak maybe, if tasks are waiting for this always-Pending task?

peter-leonov

For those not familiar with async Rust:

It's amazing how we can write executor agnostic code that can run concurrently on huge servers and tiny microcontrollers.

This is very true. A nested tree of async calls, with maximum optimization, solidifies into a single structure with a state machine inside. It is brilliant indeed!

dubiouslittlecreature

Did the link just die for anyone else?

Edit: it shows me the blog post for like half a second then goes to a 404 page

Edit 2: I went and clicked around to the blog article list, then when I try to open the article from there (where it’s listed) it goes to the 404 page. How do you fuck up a blog that badly? It’s a static page. Or at least ought to be.