←back to thread

A Few Words About Async

(yoric.github.io)
82 points vinhnx | 4 comments | | HN request time: 0.264s | source
1. jiggunjer ◴[] No.45787918[source]
Recently had to familiarize myself with python async because a third party SDK relies on it.

In many cases the lib will rely on threads to handle calls to synchronous functions, got me wondering if there's a valid use case for running multiple async threads on a single core.

replies(3): >>45788200 #>>45788569 #>>45788995 #
2. ◴[] No.45788200[source]
3. conradludgate ◴[] No.45788569[source]
I frequently use single threaded async runtimes in Rust. Particularly if it's background processing that doesn't need to be particularly high throughput.

Eg in a user application you might have the performance sensitive work (eg rendering) which needs to be highly parallel - give it a bunch of threads. However when drawing the UI, handing user input, etc you usually don't need high throughput - use only 1 thread to minimise the impact on the rendering threads

In my work with server side code, I use multiple async runtimes. One runtime is multithreaded and handles all the real traffic. One runtime is singlethreaded and handles management operations such as dispatching metrics and logs or garbage collecting our caches

4. electroglyph ◴[] No.45788995[source]
i would say: probably not

if your async thread is so busy that you need another one, then it's probably not an async workload to begin with.

i work on a python app which uses threads and async, but only have one async thread because it's more than enough to handle all the async work i throw at it.