4 ms·
So is preemptive or cooperative better in your opinion ? I couldn't figure it out from your comment.
by dewiz 11y ago
So is preemptive or cooperative better in your opinion ? I couldn't figure it out from your comment.
- findjashua 11y agopreemptive. Cooperative scheduling runs the risk that a long-running actor might starve the other actors
- davidw 11y agoNote that "better" means better for some kinds of things. Preemptive scheduling has a cost, just like running a program on top of, say, Linux costs more than if you coded it specifically to run on the chip itself with no OS.
- strmpnk 11y agoExactly. In terms of fault tolerance, a buggy actor is isolated in regards to scheduling others. Bad behavior has a more limited scope. This isn't to say that one can't create a process that eventually has harmful consequences to the entire system, it just means it's much less likely. These little points of isolation add up. Scheduling, memory management, lifecycle, crashes, &c... It's why it's a bit funny when I hear Akka compared. Akka is quite impressive but I'd never consider it a true alternative to an Erlang or BEAM style runtime.
- atemerev 11y agoAkka is quite good in terms of reliability (I developed in both Akka and Erlang). All actors in Akka are supervised by default, and restarted if any exception happens. This allows skipping most of error handling in Akka code. If something's wrong, your actor will be restarted. Works great!
- strmpnk 11y agoThis assumes failure is clean. Some failures are tougher, for example, imagine code going into an infinite loop. It either system, you have waste but the scale of the disruption in Erlang is kept isolated where Akka would fail to release the thread. Otherwise, I'd definitely agree that Akka handles vanilla failures just fine by using supervision trees.
- Blackthorn 11y agoCooperative scheduling can work fine so long as the scheduler can detect blocking and pull them out of the run queue. This still counts as cooperative.