Posted by ingve 15 hours ago
https://bookfinder.com/search/?isbn=9780672306556
The core of the actor model is that an actor can interact with the rest of the system in three ways, not just two. It can receive messages, send messages, or spin up a new actor.
(I wrote a parser-compiler for the classic Macintosh OS, which notoriously had cooperative multitasking… by the end I ended up simulating pre-emption by sprinkling calls to a routine that did “check timer, yield to OS if needed”.)
Interrupts and timers are such native embedded concepts that fit into hardware, its literally a perfect fit for an actor system.
What if I want to start a computation and I can't reason how long it takes, so that the OS kills my program, because it spent too much time? In a traditional OS it's not a problem, it can interrupt my program at any moment and resume it later.
> An idle actor instance has no stack, and no register context to save
If I have no stack, what can I use to save program state? Do I need to mess with global variables for this?
I wrote about that. It's the main weakness of this approach. You can solve it fairly easily for a linear style of task (decompression, encryption, etc.) because you can capture your state as a simple future. For cpu intensive recursive algorithms, it gets far messier.
> If I have no stack, what can I use to save program state? Do I need to mess with global variables for this?
All state is actor instance state. Kind of like any class based programming paradigm for an object not actively executing.
Sounds like someone is still discovering the difference between the necessary assumptions for their wish to become true and the assumptions they are actually making.
There's no claim in the article that this is a superior system than threads in the general case.
> A single handler execution has a limited time window and must run to completion in a small time window. The kernel enforces this by killing any instance that exceeds the limit.
And then what? If the actor was in the process of writing a file, what is left of the bytes on disk? Does another or the same actor get restarted to complete the write without introducing corruption?
Also, how does this system handle multi-threading inside an actor? The prior post says Linux apps are supported so it's not just actors all the way down. Do multi-threaded Linux programs starve the OS?
And what is the shape of the OS kernel? Presumably there is a core monolith that handles message passing and execution. Is it ignorant of the hardware? "I can change out a graphics driver, storage driver, or an application all without a reboot" implies the answer is "yes". But, that can't be the whole answer because the core must know about hardware resources in order to know how to execute and kill actors.
Maybe a follow up post covering these core OS issues?
Distributed system equals partial failure and concurrent execution.
The partial failure part is where most naive map-reduce approaches get stuck. This is also where exception handling gets stuck.
It wasn't spelled out, but my reading is that an actor is never "in the process of writing a file" because that would be a blocking operation. It probably has to start with a message which requires data to be written and then copies data into a buffer and generates a message to the kernel that the buffer needs flushed along with a message to its future self about what to write next, then exits. If it wrote everything it needed into the available buffer, it would emit a different message saying the file needs closed. AFAIK it all boils down to the same coding style as Node.js where every blocking file operation becomes an async re-entry point.
Not only would the file get cut off, but tasks will run faster on one machine than on another, meaning that your program may run fine on your computer, but what it'll do on another is anybody's guess.
It also uses one thread on one processor, so it basically throws a lot of performance out of the window. Perhaps it works on embedded, although the idea of a time limit on every message seems rather harsh.
> It also uses one thread on one processor
Zero threads, and 6 processors.
https://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
As the author mentions, my influence was about a decade of Erlang programming which shaped how I think about concurrency, scalability, and maybe most importantly, throughput.