Who Runs Your Rust Future? Hands-On Intro to Async Rust
11–20 of 40 posts
Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust
#12Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust
#13Don'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
#14Don'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
#15Don'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.
It's just doing a loop and a call to poll(), that's it.
It's way way way less expensive than using threads. Of course you must give control to your main loop every once in a while, so if you have a long computation you either create a thread or split it and return control to your main loop.
It's how all GUI programming has always been done.
Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust
#16Don'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 switchi…
True, but if all you are using is async, then you're basically back at Windows 3.1 cooperative multitasking, except now within a Rust program.
Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust
#17Bit weird to have a rust tutorial list JavaScript async as assumed knowledge tbh.
Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust
#18Don'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.
For other things, async task (or green thread, whatevs) per connection is a very nice model that you can't do with thread per connection because I don't think OSes are happy to gave hundreds of thousands of threads.
Re: Who Runs Your Rust Future? Hands-On Intro to Async Rust
#19Don'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
#20Don'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 th…
Sure, if you need to run 20k connections then use async. But the fact of the matter is that the vast majority of software is not going to take on 20k connections. Those people (i.e the majority of software devs) should use threads, because they are much easier to reason about and work with.