Async Rust never left the MVP state
68 points by radim
68 points by radim
This article is far more constructive than I expected from the title.
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.
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...
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?
Yes. Those futures would be "stuck" and never resolve. However, you can reach such state only from an already-buggy low-level async code, and code that can't properly track which futures have finished is likely already leaking and deadlocking.
You can't incorrectly poll with .await.
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!
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.
This feels a little unnecessarily rude/aggressive in tone. Websites have bugs sometimes — reporting them is useful, but this comment is just kind of mean?
For what it's worth, I'm pretty sure I followed your reproduction steps and I am not getting any 404s. I tried on my phone and desktop, with and without JavaScript enabled. So maybe whatever you were/are experiencing was more complex than it seemed?