3 ms·
> Task counts themselves are also a pretty useless metric. Sure, you can have may fibers doing nothing. Sorry if I wasn't explicit. I was talking about tasks/f
by brunosutic 5y ago
> Task counts themselves are also a pretty useless metric. Sure, you can have may fibers doing nothing.
Sorry if I wasn't explicit. I was talking about tasks/fibers performing actual work, like handling HTTP connections.
It's practically possible for Async Ruby programs to do work with hundreds of thousands Async Tasks (concurrent fibers).
Some users have worked with millions of Async tasks, but I'm not sure if it was practical work, or proof of concept.
> You can easily have tens of thousands of threads on Linux.
Thank you for the correction about threads on Linux. I'm not sure if you're talking about threads in general or threads in Ruby?
I've only lightly tested increasing the number of threads in Ruby to about a thousand, and my test code was very slow.
I think that has to do with thread switching overhead. Threads have a relatively high switching overhead, so I don't think it's advisable to run more than 100 threads - in Ruby at least.
- formerly_proven 5y ago> I think that has to do with thread switching overhead. Threads have a relatively high switching overhead, so I don't think it's advisable to run more than 100 threads - in Ruby at least. If you run many threads the bytecode VM of all threads are contending for the GIL in order to advance the program.
- grncdr 5y agoWhile true, the same would apply to code using Async blocks. Async does not attempt (or intend) to enable parallel execution of VM byte code. If the parent commenter saw a speed up in their tests, it’s reasonable to assume that is because of the difference in overhead of switching threads vs fibers.
- formerly_proven 5y agoFibers don't contend on the GIL.