-
Notifications
You must be signed in to change notification settings - Fork 892
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
Switch from sync to a tokio runtime #3367
Conversation
230c766
to
65a24a8
Compare
9092cb8
to
3c4ced6
Compare
Having briefly skimmed over some parts of this: what limits us from just using |
3a86fbb
to
6c2f960
Compare
This is in The block-on stuff is scaffolding during the transition. The starting point was: With an async main, that will blow up at runtime, because you get If that is changed naively by just making main() async, and reqwest async, then we get rust's async function tainting everything and will change all the relevant calls to async, but there are a number of places where types need to change to be compatible with async requirements; so the commit becomes huge and unwieldy very quickly. So the approach I'm taking is some scaffolding that lets us work this incrementally, and once complete it will just be nice async code. |
Makes sense, thanks for the explanation. Can you give an example of where/how types need to change? I worry that with this approach, you'll need another big set of commits to unwind all the |
Once done the aggregate diff should be precisely the changes needed, and I can rebase squash it all away. We did this with the removal of |
Oh, I guess that makes sense. Other projects I help maintain prefer to rebase-merge so that the small commits make it into main, which can be helpful if you need to chase down a regression later. |
Thats also valid to do; lets assess when this is at the next inflection point (which will be async native with no thunk, but no refactorings for better behaviour) |
6c2f960
to
0446b52
Compare
This is nearly complete, I think its mostly mechanical now, except for the closures in the test suite - there's some lifetime challenges to address there |
0446b52
to
700f06c
Compare
c06eacb
to
a1ca230
Compare
This now complete modulo any refactoring of the commit series we might want to do. The key notes are:
|
a1ca230
to
e84520e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks mostly okay to me.
0c59e2b
to
6927cc8
Compare
Thanks a lot for your hard work, @rbtcollins and @djc! |
Being able to use async where relevant across the codebase makes it possible to use async constructs where relevant. rustup has many places where that can be useful: downloading channel metadata, distribution content, unpacking that content to disk, are work that could usefully proceed in parallel - and async provides a good abstraction for that.
We already have a sophisticated disk IO layer that accomodates various OS latency-inducing behaviours, and adapting that to async without any regressions could be very interesting too - but for now, it co-exists nicely with an async core.
One not necessarily obvious caveat - we can't use tokio::main because it doesn't provide the per-worker-thread injection that we use to facilitate isolated tests. (tl;dr std::env::var/args being global reflect reality well, but not writing tests that interact with those layers).