Live data from Hacker News

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

aibodh.com

21–30 of 40 posts

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

#21
post #11

Bit weird to have a rust tutorial list JavaScript async as assumed knowledge tbh.

Could it be that this is related to the high (anecdotally observed) correlation between Async and webdev in rust? Most of the web-related crates I've run into require Async.

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

#23
post #17
post #11

Bit weird to have a rust tutorial list JavaScript async as assumed knowledge tbh.

Yeah, it also makes it seem like Rust is weird for using Future as the type name, but actually JavaScript (Promise) is the odd one out here. Probably a JS dev learning Rust without much exposure to other languages

I think it's also good that we did not name it Promise because there are a lot of differences in implementation that really matter, and so if Rust had gone with the same name, some people might be confused about some things.

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

#24
post #11

Bit weird to have a rust tutorial list JavaScript async as assumed knowledge tbh.

JS async is similar to C# async (which I think it was based on), think lots of developers are familiar with one or both of those. As one of those developers Rust async definitely threw me for a loop (literally?) when I first encountered it.

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

#25

Earlier quoted context omitted.

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…

> You use async to preserve system resources. For example you can easily exhaust the host with ~20k connections running a thread-per-connection schema... 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 re…

async gives you a few other advantages, it allows you to handle bi-streams much easier than two sync threads especially when it comes to synchronization.

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

#26

Ok, what is going on in the comments here? I get people liking the article but this many comments just to say they liked it is very un-HN to me. Smells like bots to me.

Taking a quick look at the commenter's in question, it seems possible that the person who wrote the article asked people they know to boost it on yc. They don't appear to be bots at least.

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

#29
post #18
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 can mix and match. For work, I run a conferencing server ... packet processing runs in one thread per core, out of band signalling runs in async on a separate pool of threads. It used to all be async, but using threads for packet processing shaved a little cpu, doing my own timers shaved a little cpu, cpu pinning the threads and the sockets shaved a little cpu, and at the end of the day we shaved a couple instanc…

> 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

I don’t think I ever seem this patterns, What I’ve seen is either a thread pool for tasks (what essentially async is), or dedicated threads for each parts of the processing (a thread for the UI, and a thread for some background services like playing music).

Post reply on HN