Live data from Hacker News

Who Runs Your Rust Future? Hands-On Intro to Async Rust

aibodh.com

1–10 of 40 posts

Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust

#4
> What is harder to find is the bridge between them, the part that connects understanding how async works to actually shipping with it.

There is actually already a tutorial at this level: Tokio has its ‘async in depth’ tutorial [1] that walks you through building a toy runtime and using it to run a future.

Not a complaint — you can never have too many tutorials, unless they're about monads — but just a pointer in case you hadn't seen it :)

[1]: https://tokio.rs/tokio/tutorial/async

Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust

#8
Don't use async but use threads instead. Threading treats the CPU as a resource, which it is! Whereas async simply locks the CPU, which can deplete the system for longer computations.

If you hate garbage collection pauses (which most Rust users do) then don't use async.

Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust

#9
post #8

Don't use async but use threads instead. Threading treats the CPU as a resource, which it is! Whereas async simply locks the CPU, which can deplete the system for longer computations. If you hate garbage collection pauses (which most Rust users do) then don't use async.

Your confusing concurrency with parallelism. Async allows one core to switch between many threads of execution that can do work and not stop one thread of execution because it needs to wait for a resource. It's beneficial to use async if you're application is I/O heavy even if it's single threaded.

> Whereas async simply locks the CPUWhereas async simply locks the CPU

This is also completely nonsense, context switching behavior is OS dependent and your average general purpose kernel is not cooperative. You will run for your allotted quanta or reschedule when you run out of coroutines that can execute without waiting for resources.

Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust

#10
post #8

Don't use async but use threads instead. Threading treats the CPU as a resource, which it is! Whereas async simply locks the CPU, which can deplete the system for longer computations. If you hate garbage collection pauses (which most Rust users do) then don't use async.

You use async to preserve system resources. For example you can easily exhaust the host with ~20k connections running a thread-per-connection schema where each thread simply waits for epoll event, async prevents this by having a threadpool of ~16 threads that handle all the connections instead of polling the scheduler wakes it up, asks "do you haev work to do" if not continues to next task. (This heavily varied by the async runtime implementation, each async runtime can and will act differently to maximize efficiency over throughput)
Post reply on HN