Top
Best
New

Posted by ingve 16 hours ago

An OS with no threads: The Actor Model(www.timdbg.com)
295 points | 141 commentspage 4
textlapse 6 hours ago|
How does this compare with Swift actor model?
objectforlife 15 hours ago||
So.. message passing? Alan Kay was right all along?
InsidiousWombat 13 hours ago|
"right" is one dimensional. It was always a good tool from reasoning perspective. Just not always from performance perspective
flossly 12 hours ago||
Next: async/evented model? Just one giant event loop (per CPU)? /joke
zbentley 12 hours ago|
You joke, but that’s … almost kinda-sorta just what a hardware interrupt controller is.
YesThatTom2 13 hours ago||
Sounds like a great follow-on project to Amoeba OS by Andrew Tanenbaum.
cess11 14 hours ago||
"We need a way to send a request to another actor, and provide it a way to send back a response that can be connected to the original request. For that, we have a “reply slot”, represented as a ReplyTo<R> in the code for actors."

It's probably partly due to habit but I like the BEAM solution to this, i.e. provide your sender ID and let the receiver figure it out. Oftentimes you don't care about a response, you just want to flick a switch at a distance or throw some garbage into a bucket.

For me it makes the basic model simpler to hold in my mind and it's been a nice learning experience to look at how stuff on the BEAM gets from there to state machines and generic servers and supervisors and so on.

One of the nicest things with the BEAM is that it feels like I have an OS available when programming. I don't get that with threading in e.g. Java, and I don't think I'd get it from Golang either.

Does Rust have pattern matching on function declarations? I.e. could the match-block be switched for several handle-functions instead in the example? If not, then I think I prefer the BEAM way there too, it's quite nice to break out the message handlers into functions matching on the message instead of going through a match/case and then into the actual handlers.

The preemptive multitasking on the BEAM is convenient too, it almost always gives the result I want.

I don't see an example in TFA of how the actors are addressed, do they get a number when instantiated or somesuch and then one does like a send-syscall with that number?

timmisiak 7 hours ago||
> Does Rust have pattern matching on function declarations?

Nope, that'd make this a fair bit nicer.

> how the actors are addressed, do they get a number when instantiated or somesuch

There's a system to register an instance with a name for lookups, everything else is based on explicit handles passed around.

pjmlp 13 hours ago|||
> One of the nicest things with the BEAM is that it feels like I have an OS available when programming. I don't get that with threading in e.g. Java, and I don't think I'd get it from Golang either.

I certainly feel like that when doing Java and .NET runtimes, Java especially is what made me stop caring about POSIX.

Both are the closest I have been able to do in mainstream to the OS abstraction layers, past my Smalltalk and Lisp experiences.

kibwen 13 hours ago||
> Does Rust have pattern matching on function declarations?

Rust supports patterns in function declarations, but not for the purposes you're thinking of. In function arguments, patterns are required to be irrefutable, so no redeclaring a function with different refutable patterns each time. Rust only wants a single source of truth for each function (possibly attributable to an allergy of anything that could be mistaken for C++-style function overloading), and since Rust pointedly declines interprocedural type inference, redeclaring your function multiple times with full type annotations every time would just be more verbose anyway (in contrast to something like Haskell, which supports what you're asking for but allows type inference in function signatures).

jvanveen 10 hours ago||
Another Rust OS, running (almost) on a Fairphone, https://pinnacle-os.eu/blog/fairphone-4/
jerf 11 hours ago||
There are some serious drawbacks with this being the fundamental model of an OS. An OS needs to be able to handle everything that you might want that OS to be able to do. A strict actor model has some performance issues, because it requires all message communication to be copied around. There are some pathological cases for this where you need lots of copying and communication for things that are not difficult with sharing. Even Erlang actually doesn't have full memory isolation, because it can share immutable binary terms between processes and do garbage collection on the references rather than copying them around entirely. Since the language has no way to modify the immutable values, it's safe, but it also means the naive understanding of "no shared state" is not actually true, in a way that will matter to an OS.

You can also get some performance issues depending on how your route messages; for instance Erlang does this pattern matching thing on messages but that can let them back up and create subtle and hard-to-diagnose memory leaks, and subtle performance issues trying to pick certain messages out of a queue. In a specific Erlang program the solution is, broadly speaking, "don't do that", but an OS must be ready for vastly more pathological conditions than "a specific Erlang program".

Also, cooperative multitasking at the operating system is well explored and a known major failure. It damn near killed MacOS and required a massive and expensive effort to get MacOS off of it before it did kill it. In a nutshell, as you scale up the probability that at least one process will misbehave and fail to give up its time slice approaches one, at scales much smaller than what constitutes a modern OS. I don't like it even today even in my own code, but the only reason it is even remotely viable is that it is still contained to single OS processes and even if one OS process has something not cooperating the surrounding OS is fundamentally pre-emptive. If that was not the case, all "async" code would be dead in the water today and nobody would be using it at all. If an OS is going to be actor based I would 100% expect those actors to be threads, in the sense of being independently scheduled entities. not being cooperatively scheduled.

Or, to put it another way, the reason anyone is using cooperative multitasking today is precisely because they're using it in an OS that is ensconcing them within a threaded environment at the OS level (where here an "OS process" is a thread for these purposes). If you take that layer away and everything is running in the same cooperative context, suddenly the costs of cooperative multitasking literally exponentially skyrocket and it is completely unappealing.

I also think there's some dissonance between having Rust and having a requirement that all code be actors within a given OS, because the two overlap a lot. Actors are already a fairly viable mechanism for managing memory, if you just don't let actors fiddle with other actor's memory. So this super rich and complicated borrowing mechanism is really doing a lot of work that is redundant to the actor boundary. "Actors" as one technique in a Rustacean's toolbelt is a fine choice, but if the OS itself is going to lift up actors as the one true and fundamental approach to writing code, Rust burns a lot of design budget on problems that are suddenly nowhere near as large anymore, because the OS really ought to be providing isolation fundamentally.

Now, of course, if you're just playing around, hey, do as you like. But as a serious foundation for an OS that others might use there are major issues here.

On the plus side, as Erlang demonstrates, if you make it so actors can communicate across the network then you get the ability to build large computers out of small ones with some relative ease. Though to raise actors up to the OS level, you might need to do something that Erlang really doesn't and make a real, type-level distinction between local actors and actors that might be remote, because actors over the network necessarily have unreliable message passing, and implementing local OS services with "unreliable message passing" will add additional complication to every such interaction. Being able to do what Go does with channels and make message handoff and reception an explicit synchronization point is really, really convenient, and can even be harnessed to do some OS-level optimizations like "hey OS, here's my buffer, you're the OS and specially blessed so instead of sending me a copy of a byte buffer for me to then copy into my own local representation why don't you just take this handle to some memory and slam it straight in there" fairly safely, mitigating some of the performance impacts I mentioned at the top.

timmisiak 7 hours ago||
> An OS needs to be able to handle everything that you might want that OS to be able to do

This isn't designed to be a fully general purpose OS.

> it requires all message communication to be copied around

In most cases there are zero copies. Ownership is transferred.

> Erlang does this pattern matching thing on messages but that can let them back up

Not covered in the article, but this OS doesn't let an actor choose what to handle. Which has its own issues.

evmar 9 hours ago||
> In a nutshell, as you scale up the probability that at least one process will misbehave and fail to give up its time slice approaches one

The OP mentions that the kernel kills processes that fail to give up their time slice. This might have its own problems (e.g. an algorithm that unexpectedly rarely goes over budget) but I believe iOS has taken a similar approach.

brcmthrowaway 13 hours ago||
What if someone wanted to do multicore number crunching??
pjmlp 13 hours ago|
See Connection Machine, talking across CPUs via Pvars.
bluegatty 12 hours ago||
neat idea!
arbor-group 10 hours ago|
[dead]
More comments...