Re:Ruby 3.0 and the new FiberScheduler interface
by Rapzid on Tuesday December 29, 2020 @10:35PM
(#25578157)
Golang, .Net, and BEM all use preemptive scheduling IIRC. Don't know the specifics of each implementation, but you can use timers to signal the process and "wake" the scheduler.
Re:Ruby 3.0 and the new FiberScheduler interface
by masklinn on Wednesday December 30, 2020 @02:11AM
(#25579375)
Beam uses reduction, basically instructions count. I believe native functions can still lock up a scheduler (and must provide an estimate of their icount) which is one of the reasons why they’re tricky.
Re:Ruby 3.0 and the new FiberScheduler interface
by valenterry on Tuesday December 29, 2020 @10:37PM
(#25578177)
That depends. A long-running function is usually just a semantically long running function which consists of multiple (usually suspendable) parts. Of course there are exceptions, such as long running cpu heavy calculations for which a single atomic call takes longer than just milliseconds. But I think this is rather rare.
And for just semantically long running functions, it is not difficult to write a scheduler that tries to be "fair", however you want to interpret that. But of course it requires to fully embrace asynchronous programming, something that will probably difficult in Ruby.
This limitation is present in every modern asynchronous programming system I've ever seen. They simply can't deal with long function calls. There's a loop under the hood which constantly executes queued functions. Any long-running function will stall the execution pipeline and increase latency. It's just like cooperative multitasking...