Rust Async Working Group
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Async Rust Vision Doc, 2024 update ###### tags: `deep-dive` This is a (draft) revamp of the async Rust vision doc. The goal is to outline three things * Where do we want to be by Rust 2023 -- greatest level of detail, scheduled down to months * Where do we want to be by Rust 2024 -- key goals for the upcoming Rust edition * Where do we want to be by Rust 2027 -- longer term prospects, a bit hazy The goal is that, when we're done with this process, we know what we know concretely what we are trying to achieve by 2024 and the big steps we'll be taking to get there (some of which have to happen this year). The 2027 goals are more speculative, but we should have agreement on the "overall shape", if not the precise details or path. ## Tenets These are the criteria and beliefs that we used to form this roadmap. They are ordered such that, if in conflict, we give priority to the first one. **Continuous progress.** People are building foundational layers in async Rust *now*. We need to ship incrementally, building our way to the end goal, but improving stable Rust along the way. **Be ambitious.** We need to continue supporting the async Rust code that exists today, but we shouldn't be held back by it. The current experience isn't where we want it to be, and we shouldn't be afraid to propose and make ambitious changes, as long as there's a path from here to there. **Enable the Rust ecosystem**. The primary role of the Rust org is to build the interconnections that allow the ecosystem to scale and interoperate. Sometimes standardizing one layer simplifies further development atop it, allowing for a flourishing ecosystem. **Consistency is better.** The async Rust experience right now varies dramatically depending on your domain, and getting started involves a lot of decisions with non-obvious and long-lasting implications. We need to find ways to make async Rust more uniform. See also the [Rustacean design principles][rdp] (Reliability, Performant, Supportive, Productive, Transparent, Versatile, in that order). The Async Rust experience as it stands now arguably puts Versatility above Reliability, Supportiveness, and Productivity through constructs like `select!` and `FuturesUnordered` as well as the lack of portable libraries and idioms that work uniformly across runtimes. [rdp]: https://rustacean-principles.netlify.app/how_rust_empowers.html ## Rust 2023: Async fundamentals *How it feels by end of year:* Much like today, but async functions in traits work, and there is progress towards portability. ### Top-line goal: static async functions in traits. Our most important for 2023 is **stabilize statically dispatched async functions in traits**. To feel comfortable stabilizing, we need to establish: * that we are stabilizing a big enough chunk of functionality to be useful, even if some moderate workarounds are required. * that our design will support future standard library functionality like async read/write traits, async iterators, and async closures: * Can we enable a single sync/async trait definition with different modes, or do need a separate family of traits? If the former, we need to ensure that our definition of async functions in traits is compatible with that. * We don't need to know the exact trait definitions, but we do need to know we can support the features they require (e.g., async iterators need async closures). * That we know it is compatible with future support of dynamic dispatch. We will establish these facts through several documents: * Case studies covering key applications we want to enable. We believe that the current support for async fn and RPITIT, combined with a solution for send bounds, would suffice for the following: * Customization points within the AWS SDK ([in progress](https://hackmd.io/EWDCg5ycQNeLHvGBUNbrDQ)) * Embedded async applications with Embassy (already using static async functions in traits, so the goal here is to describe) * Microsoft Project X (eholk?) * Tower and middleware (under discussion) * *For each of these, we will document:* (a) what use cases the project has for async functions in traits; (b) what minimal set of features is required to support the use case adequately; (c) what workarounds would be required and how they could be removed in the future. * Design sketches to ensure we will be compatible with Rust 2024 goals: * Portability requirements to allow hyper, quinn, or another such library to be runtime independent * Design sketch for async closures and async iterator -- the goal here is to show how the functionality could work, not to sketch the ideal API * Dynamic dispatch design space. This is fairly well understood but pulling the blog posts and things together would be useful. **Maybe-async plans.** The biggest unknown here is send bounds and the library. Currently we are considering a "maybe-async" plan similar to what [Eric proposed here](https://theincredibleholk.org/blog/2023/02/16/lightweight-predictable-async-send-bounds/), which would in turn enable (but not require) a single definition of read/write/iterator that can be "made async". To settle this debate, we need to author RFC(s) laying out the plan we expect to take, to be approved by T-lang and T-libs. We don't need to fully implement support for "maybe-async" traits, though, we simply need to ensure that syntax users use to declare "always async" traits is forwards compatible with that work. To be very concrete, while the RFC(s) would lay out sufficient plans for "maybe-async" traits that can be used in sync or async mode... ```rust trait ?async Iterator { } ``` ...we only need to implement support "always-async" traits like `trait async KeyProvider` for the initial stabilization. **Dynamic dispatch workarounds.** Most of the above applications do require support for dynamic dispatch, but they don't actually need it to be provided by the language. For the AWS SDK, for example, it's possible to use the ["erased trait workaround"](https://smallcultfollowing.com/babysteps/blog/2021/10/15/dyn-async-traits-part-6/), and furthermore that workaround is encapsulated within the library and not exposed to end-users. Hopefully this pattern holds true for other applications. We may wish to ship some kind of rust-lang crate to automate the workaround with a procedural macro. ### Secondary goal: support for operator tooling? One of the most common complains from async Rust users is that the tooling story is not great. Common asks: * dump all the active tasks; help me diagnose my deadlock * async-aware CPU profiles that show "per task" data * step-through debugging where pressing "step over" on a `foo.await` call doesn't go into the runtime The Rust org is not currently in a position to deliver on these needs, and it's likely that many of them should be served by projects like [tokio console](https://github.com/tokio-rs/console), that live outside the org. However, we may be able to *help* by building in some key enablers. What are they? ### Tertiary goals There are also some nice to haves: * Improve code generation efficiency -- futures are too big, this costs performance (pnkfelix is currently investigating this) * Lift common limitations of current generators -- e.g. knowing when a local variable has been moved ## Rust 2024: The async is all right *How it feels by end of year:* The standard library is enriched with common traits for iterators, I/O, and they are starting to be used within the ecosystem. Dynamic dispatch works. ### Top-line goals * async iterator API * enable convenient portability for libraries like Hyper and Quinn: * async read, write trait * async timer trait * async task spawning trait * dynamic dispatch for AFIT ## Rust 2027: Async awesomeness *How it feels by end of year:* To get started with async Rust, you open the Rust book, and it shows how to use standard library traits to create common async patterns. Those same patterns work for embedded async, for the most part. You go to the hot new web framework "Rusty Rocket" and things just work; later on, you toggle a switch in your `Cargo.toml` and deploy it using the Fuchsia runtime. ### Top-line goals * support for async drop and structured parallelism * stdlib includes APIs for structured parallelism and concurrency, listening for connections, other basic needs * adequate to build a something like rocket or axum without relying on a particular runtime * default runtime makes getting started easy, but easily changed This is the dreamy future, and it's obviously a bit hazy. It's not even clear that it's *possible* -- certainly achieving things like structured parallelism will require some extensions. Here are some of the known extensions required that we need to be exploring *now*: * *Resource types*, meaning some way to define a global "resource" (e.g., an allocator) that must obey a trait, code against that (unknown) type, and then have it specified by the end artifact. This would be used for async runtimes. * *"True linearity"*: if we want to safely support structured parallelism, we need a way to prevent forgetting futures, or possibly modifications to the future trait, something like that. There are similar challenges for async drop, to avoid the problem of async values being dropped from inside sync code. ## Dates and times | Item | Who | Q1'23 | Q2'23 | Q3'23 | Q4'23 | H1'24 | H2'24 | | ---- | --- | ----- | ----- | ----- | ----- | ----- | ----- | | **Towards 2023 goals:** | | • AWS SDK case study | ![nm][] ![mg][] | ▓▓░ | | • Microsoft study | ![eh][] | ░░░ | | • Tower case study | ![sm][] ![lf][] | ░░░ | | • Embassy case study | ![db][] | ░░░ | | • Async Fn plan | ![nm][] ![tm][] | ░░░ | | • Async Iterator plan | ![nm][] ![tm][] | ░░░ | | • Dyn dispatch plan | ![nm][] ![tm][] | ▓▓░ | | • RPITIT RFC | ![tm][] | ░░░ | | • ?async trait RFC | ![yw][] ![os][] ![eh][] | ▓░░ | ░░░ | | • Minimal impl | ![os][] | ▓░░ | ░░░ | | • Stabilization (1.73 branches July 17) | | ░░░ | ░░░ | :dart: | | • Smaller futures | ![fk][] | ▓▓░ | | | • Generator limitations | ? | | | **Towards 2024 goals:** | | • Implement "dyn*" traits | | | ▓░░ | ░░░ | | • Design notes for `.box` syntax | ? | | ░░░ | ░░░ | | • Stabilize dyn dispatch | | | | | ░░░ | ░░░ | :dart: | | • Nightly support for ?async traits | | | | ░░░ | ░░░ | | | | • Stabilize ?async read/write | | | | ░░░ | ░░░ |:dart: | | | • Stabilize ?async Fn | | | | ░░░ | ░░░ | :dart: | | | • Stabilize ?async iterator | | | | ░░░ | ░░░ | :dart: | | | • Stabilize ?async timer | | | | ░░░ | ░░░ | :dart: | | | • Stabilize ?async spawning | | | | ░░░ | ░░░ | :dart: | | | **Towards 2027 goals:** | | "Resource types" RFC | ![jt][] ![nm][] | ▓░░ | | | | | Async-drop plan | ? | [nm]: https://github.com/nikomatsakis.png?size=20 [tm]: https://github.com/tmandry.png?size=20 [yw]: https://github.com/yoshuawuyts.png?size=20 [os]: https://github.com/oli-obk.png?size=20 [eh]: https://github.com/eholk.png?size=20 [mg]: https://github.com/compiler-errors.png?size=20 [fk]: https://github.com/pnkfelix.png?size=20 [sm]: https://github.com/seanmonstar.png?size=20 [lf]: https://github.com/luciofranco.png?size=20 [db]: https://github.com/dirbaio.png?size=20 [jt]: https://github.com/joshtriplett.png?size=20 [nc]: https://github.com/nrc.png?size=20 --- # Discussion Copy the template below to leave questions and comments for discussion. --- ## Definition of task eholk: Do we want to define what a task is in the language? tmandry: Yeah, eventually we want some std APIs to talk about it. nikomatsakis: Feels like the more ambitious vision, skeptical of jumping straight there now since the vision might change. --- ## Logical stack traces jackwrenn: Been investigating approaches to this. Interested in pursuing an "async frame pointer" approach. eholk: Relation to mw's work? jackwrenn: Interested in language/runtime inspection as opposed to crashdump. Should help with both. nikomatsakis: Would like to identify some mechanism that enables several use cases and define an initiative. tmandry: I would like to find an approach that works for future approaches that aren't an intrusive tree data structure – something like DWARF. nikomatsakis: Tension between generality and efficiency. nikomatsakis: More focused meeting in the future? tmandry: Yep tmandry: What's in scope? nikomatsakis: This feels closer to the mental model, productivity, etc. of the core stuff we're working on than efficiency. --- nikomatsakis: What's the status of drop tracking? eholk: Slow burn, waiting on decision on the MIR-based analysis by cjgillot to prioritize. That's cleaner architecturally, but there are potential issues. nikomatsakis: I sense that there are polish bugs that come up often, workarounds that you have to learn. One is working around drop tracking, another is the "type not general enough" error. Do we have a list, and how important do people think those are? tmandry: I think they're a big deal nikomatsakis: We should pull this into the roadmap and make sure a types team discussion happens. eholk: Could work on burning down the drop tracking more. tmandry: Should try to get to a point of "we think this will/won't have time soon". nikomatsakis: eholk and I should sync up on issues --- ## Async main and tests vincenzopalazzo: I think there is a good probability to have a design for [async main and tests](https://vincenzopalazzo.github.io/async-main-and-tests-initiative/index.html) that I start to investigate maybe is there is consensus on the design would rust 2024 (in beta/nightly maybe) would be a good goal? nikomatsakis: Maybe good goal for 2024, or 2027 since it needs the ability to talk about the runtime (which is the 2027 feature). yosh: I don't think we *have* to be able to talk about the runtime initially. We could have an `async fn main` / `#[test] async fn` working, and figure out the interface to make it portable later on. I suspect this could probably be done using something like `with`-clauses? See also: the next section. nikomatsakis: that assumes that runtime init. etc happens lazilly, right? I'm not sure if we want that. But we should drill in. yosh: I was thinking this could desugar to a sparkling `block_on` basically, at least initially. But yeah, let's drill in (perhaps some other time!) yosh: (apologies for the clunky text-only engagement) --- ## Designing interfaces vs designing types Yosh (on a mandatory work training, so can't be on the call right now): I'm seeing a big emphasis on portable interfaces for timers and spawning tasks in the 2024 section. I don't know how this is being discussed in the call, but I'd like to share that I think in terms of ordering we should be prioritizing defining the actual end-user APIs we want to expose for this functionality *prior* to providing any (stable) abstract interface people can rely on. An example of this will be "task spawning". What we want to expose from the stdlib may not necessarily be compatible with what's currently in use in the ecosystem. We seem to have soft consensus that structured concurrency is good. But the ecosystem relies on APIs which are unstructured. I'd like to make sure that we're clear on the APIs we want to expose and support prior to providing portable interfaces to this. tmandry: I do want to see us exploring this. We'll have to talk about it before we stabilize anything related to spawning. eholk: Timers different? nikomatsakis: Maybe, kind of a task. tmandry: Feels like we can stabilize a simple `Spawn` trait that takes `&self` without spelling out the whole structured concurrency story – but we should have an idea of what it looks like. nikomatsakis: Maybe a roadmap item. I feel the tension between continuous progress and ambition here. nikomatsakis: We're going to need some kind of root spawn, should we start with that? yosh: I don't think we have clarity on "work-stealing spawn" vs "non-work stealing spawn"; making `Send`-bounds a sticking point. I think this is also a thing we need to drill deeper into; would be happy to do a presentation on this if anyone's interested? Just want to make sure we don't over-promise on: "we will deliver compatible interfaces", when it may be tricky? tmandry: I think we can all agree that there should be a design meeting on the space of possibilities and how it relates to structured concurrency. Yosh: definitely nikomatsakis: Need to work backward and figure out what goes in Q2/Q3 that help us know what this design looks like. --- ## 2024 edition changes Yosh: I think we should make sure to take a look at whether there are any changes we want to make related to the 2024 edition. These are not super important, but we also should not overlook them. Some things which we should probably talk about: - `Future` / `IntoFuture` in the prelude - `async Struct` notation (related to the `async Trait` stuff) - …more? nikomatsakis: `IntoFuture` sure Yosh: Should regular types which have async methods need to include `async` or `?async` in their name? We've also considered changing `const fn` to `?const fn`. We should talk about these, not sure what to do. nikomatsakis: Especially because lang team prefers to settle questions on the edition this year. Also, discussion around defaulting to requiring `Send` etc. eholk: Also something about separating `async` in signature from async block. Yosh: Loopy: should it be `async fn read_to_stream` or `fn async read_to_stream` for consistency with `trait async Read`? --- ## Topic name: prompt ---

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully