Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add status quo story: first steps into async #56

Merged
merged 9 commits into from
Mar 19, 2021

Conversation

Frederik-Baetens
Copy link
Contributor

@Frederik-Baetens Frederik-Baetens commented Mar 18, 2021

Hi! This is my experience as a newcomer to async in Rust. Niko might recognize some of these sentiments from me replying to his tweet asking for stories similar to this one surrounding async.

I haven't picked a character yet, as I feel like the character would have a very different experience depending on whether or not they've had previous experience with async in other languages. If I can assume that it not being mentioned means they don't have any experience with it, Alan would probably a decent choice. For now I've used my own name but I will replace it.

I took a very story like approach to writing this, I hope it's not too verbose.

Rendered


### Woes of a newcomer to async
Being reasonably confident in their choice of ecosystem, Frederik starts building their distributed system.
After a while, they want to introduce another networking library of which the api isn't async. Luckily Frederik picked up on that blocking was not allowed in async (or at least not in Tokio), through reading some blog posts about async. More reddit discussions point them towards spawn\_blocking in Tokio, and even rayon. But they're none the wiser about how to apply these paradigms in a neat manner.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only skimmed this, but the point about "at least not in Tokio" makes me a bit sad, because there's so much stuff written about async-std trying to implement a solution that allows blocking, but they never ended up doing it, and now everyone still thinks they allow it.

Copy link
Contributor Author

@Frederik-Baetens Frederik-Baetens Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mention that not because I'm under the impression that they allow it, but because I know it might some day be possible. It might well never happen, but I didn't want to state it as a certainty since I'm not educated enough to ascertain that blocking in async will forever be impossible.

I mention that specific blog post later in my sources.

Also, your blog post about blocking (also in my sources) has helped a lot so far! Thanks a lot for writing it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the wording to or at least not in any of the currently existing executors to avoid confusion :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this spirit of stories being personal experience and thus they cannot be wrong only misinformed, it might be interesting to throw this into a story about mixing blocking into the async world. I, however, have already suggested we separate the blocking vs non-blocking aspects of this story into a separate story so I wouldn't add that to this story per say.

Copy link
Contributor Author

@Frederik-Baetens Frederik-Baetens Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really intend for this story to be about blocking, but more about the uncertainty that starting in async brings with it. Both surrounding ecosystem choices, but also surrounding design patterns. Design patterns for inclusion of sync code is just one particular example here. This story is really about the need for an authoritative path for newcomers, which provides them with a solid foundation to explore the ecosystem with, and less about any specific technical problems surrounding blocking.

Blocking & ecosystem documentation might be very separate issues with very different solutions, but for me, in this story, they all felt like contributors to the larger cloud of uncertainty.

But I suppose that a very nice technical solution and/or guides on how to handle blocking in async would have made my experience a lot better. Perhaps once I get a better overview on how to deal with blocking in async, I could write a second story about it, and what would have made the experience better. If I were to write a story now, it would be a bit short and touch on a lot of the same things as described here anyways.

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great 🎉. I've added some comments on how we might tidy the story up a tiny bit as well as my suggestion that Barbara is indeed the right character for this story.


### Woes of a newcomer to async
Being reasonably confident in their choice of ecosystem, Frederik starts building their distributed system.
After a while, they want to introduce another networking library of which the api isn't async. Luckily Frederik picked up on that blocking was not allowed in async (or at least not in any of the currently existing executors), through reading some blog posts about async. More reddit discussions point them towards spawn\_blocking in Tokio, and even rayon. But they're none the wiser about how to apply these paradigms in a neat manner.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that this knowledge came through blog posts and not through documentation or any sort of hint from the compiler.


Their paranoia about choosing the right ecosystem is eased after a few days of research, and some more conversations on the Rust subreddit, after which they discover that most of the RPC libraries they might want to use are situated within the most popular Tokio ecosystem anyways. Tokio also has a brief tutorial, which teaches them some basic concepts within Tokio and talks a bit more about async in general.

### Woes of a newcomer to async
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there are two large questions posed by this story, and I'm wondering if they should be broken up into two stories:

  • Getting started means almost immediately reckoning with the choice of runtime.
  • How to mix blocking and non-blocking apis.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its ok to merge as is, there could and should be more stories focusing on the blocking/non-blocking mix in particular, it doesn't feel like the primary focus here

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@Frederik-Baetens
Copy link
Contributor Author

Frederik-Baetens commented Mar 19, 2021

I noticed that this is quite close to the issue #46 although I did choose a modified version of barbara since I had experience with Rust, but not with Async.

A lot of #54 also shows up in this story. If there was a more convenient, or better explained way to integrate sync code into my project, I would have had less problems I think. Even though I'm trying to make a performant database, it's still for a thesis, and not supposed to be a production system. Being able to rapidly prototype with sync code in my async project would have helped a lot.

In hindsight, I also feel a good bit of Would be happy with sync, but the libraries and things are in async. At the time I didn't really think too much about it, since conversations with community members made me decide on async back then, but now I still feel forced to use async because of the RPC libraries being async. This opinoin might be totally misplaced though, perhaps it's really easy to use these RPC libs with sync code, but in that case I think some more authoritative guidance on design patterns is needed.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was really helpful! Thanks. I really enjoyed reading it, and I thought it was really interesting that you used Barbara here. You identified exactly the reasons in the FAQ, it was fascinating to see how being active in the rust community influenced your sources of information.

@nikomatsakis nikomatsakis self-assigned this Mar 19, 2021
@nikomatsakis
Copy link
Contributor

Assigning to self to merge after async-foundations triage meeting.

@nikomatsakis nikomatsakis merged commit 3a2b0f9 into rust-lang:master Mar 19, 2021
@nikomatsakis nikomatsakis added the status-quo-story-ideas "Status quo" user story ideas label Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-quo-story-ideas "Status quo" user story ideas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants