<- Back
Comments (141)
- zoom6628OLd(er) person here. If you want look at earliest Actor models then look at COBOL programs from 70s that used queues (it's part of COBOL standard).Programs would read from specific queues for input data, transform that data and then write some to data stores and some to downstream queues. This created DAG environments for data and transaction flow.Scaling in these environments was done by monitoring load and back pressure in the queues and firing multiple readers. Transaction Processing Monitors like VRX and CICS managed this at OS level and the COBOL programs managed at unit level.COncurrency was running multiple units reading from same queue to do same function.this is one reason why a ton of these older systems still running.DAG workflow, automatic balancing, queue based actor models with transactions.Seems like what is old is new again.
- torginusI am a bit skeptical of the non-blocking claims, as actor systems usually make several tradeoffs, that handle the classical 'blocking' issue differently (by which I mean I read a 100MB file synchronously on the UI thread, and the program appears to freeze).Classical actor systems at their simplest only support sending one-way messages, and these are indeed non-blocking.But they are not very powerful either. People usually introduce the 'remote procedure call' on top of this, by which actor A can call actor B and expect B to respond. You can do this with corellation IDs for example.The question is what does actor A do while waiting for 'B'? In the simplest form it continues to serve other messages, making the actor reentrant, which can create incredibly surprising scenarios as code executes while you don't expect to changing actor fields in unexpected ways.Or you can have actor A wait to finish processing the call to 'B'. But now you have blocking, as 'B' can prevent anyone talking to 'A' from making progress.Or you can do something computer-sciencey, like doing transactions and specifying the conditions under which A can server multiple ongoing requests, and how to reconcile them.I'm sure there are many options, but actors have been a cool idea for a while, and many event driven paradigms borrow from it, that are incredibly widespread to the point that I'm sure most people have programmed in a system before, and have experienced 'callback hell'.So they are not a panacea.
- notpublicMay I recommend the following 2 talks on this subject:https://www.youtube.com/watch?v=37wFVVVZlVU Panel Discussion with Sir Tony Hoare, Joe Armstrong, and Carl Hewitthttps://www.youtube.com/watch?v=7erJ1DV_Tlo Hewitt, Meijer and Szyperski: The Actor Model (everything you wanted to know...)The first one is a rare gem: a conversation among the creators of the foundational concurrency models. Carl Hewitt (Actor Model), Tony Hoare (CSP, Communicating Sequential Processes, which inspired Go's goroutines and channels), and Joe Armstrong (co-creator Erlang).
- tancopYou can extend this with "linear type" message passing where you transfer ownership of an object. That avoids physically copying memory and the sender loses write access to enforce the one writer at a time constraint.It means a pipeline of actors can process a file with the same memory usage and only a tiny bit more CPU than a monolithic program, but it stays isolated and hot swappable.This might already be implemented in the OS but the post doesn't mention it.
- torginusThe headline advertises 'no threads', but in the article, it mentions all actor methods are non-blocking, and async. Not blocking what?The whole purpose of async is to have a message pump thread, and allow concurrency by yielding the timeslice. It's also needed because many async runtimes interact with APIs that need to be called from a single main OS thread.I would presume an OS designed to be all actors, all the way down would do away with the need for a message pump thread, and single threaded APIs. In this case, cross-actor calls might as well be sync, with required preemption handled on the OS level.Having to pay the async overhead over 100% of cross-actor calls is very expensive.
- MarceCollI did build something very similar[1] a few months ago.For me the core idea was that I wanted two things:* Simple persistence by default, not bolted on (files, sqlite, postgres). Each actor is an Elm-like init/update/view set of functions and a storage type. That storage type is saved after every update and can be offloaded to disk while the app doesn't receive new messages. So building durable state is very simple (there are some mechanisms for ephemeral state as well).* Actor based capabilities, an actor has access to other actors that provide capabilities. Because actors can also be created ad-hoc with custom code (the language is a lisp-like language) you can narrow down capabilities as much as you'd like. For example if you have access to make arbitrary HTTP requests, you can create an ad-hoc actor that delegates making HTTP requests only to a certain domain and pass it. A capability is just the address of another actor.With these two primitives (+ a content-addressable store underneath) a very capable and interesting system emerged IMO. You can have thousands and even millions of applications running, they hibernate automatically and only consume CPU when they receive a message. Clicks, typing, etc is all events on applications that receive it.Most OS stuff can be hidden behind special actors, and you can give capabilities by providing those addresses.THere's a pic and some more explanations at BlueSky[2][1] https://tangled.org/dzi-ban.bsky.social/KokoroOS/tree/master [2] https://bsky.app/profile/dzi-ban.bsky.social/post/3murg4lhmt...
- tontintonWhat I don't understand is how you do backpressure if sending to an actor is never blocking?I get the idea of avoiding cyclic deadlocks (A waiting on B waiting on A, or maybe in a longer chain), but crashing on OOM seems like a bad tradeoff.Apparently this is the same in Erlang.Or are you actually bounding the number of items that can live in mailbox and make "send" fail when full? Then you can do (bad) backpressure with timers, or register a "wakeup" message when the mailbox got an entry.Honestly, I would be wary of running an OS that doesn't handle backpressure well, resources get contended all the time in performance critical apps like databases.Would like to hear your thoughts on this.
- nvarsjIme with Akka and Beam, the main drawback of actor systems is debugging. Because you’ve now forced your problem into a distributed problem always. Beam is much better at least since you can execute commands in the runtime to check things. Akka is almost impossible and I don’t miss working with it at all. Unclear here if the author has thought about it as they focus on concurrency bugs which imo are generally easier to reason about in a traditional threaded system.
- vbezhenarUNIX had no threads originally. Processes are similar to actor model. You create pipe and you exchange bytes between processes.Of course there are more ways to exchange data between processes, like explicitly allocating shared memory. But "idiomatic" way seems to me pretty much similar to actors.
- aboundI'm surprised nobody has mentioned Hubris [1] yet in this thread. Hubris is Oxide's Rust-based message passing OS. Main differences are that Hubris is focused on embedded devices, has static task registration, and supports preemptive multitasking, but still interesting to compare the choices made for each.[1] https://hubris.oxide.computer/
- cestithI have a book from years ago about writing an OS, and the example OS used in it, MMURTL, used message passing heavily but IIRC not exactly the actor model. It allowed one to swap out parts of the OS the same way, though. One could spin up a new copy and have new messages go to the new version while the old cleared its queue. You could choose to stop processing the queue in the old one and let the messages queue up to let the new one start processing the input queue once the old messages were drained.https://bookfinder.com/search/?isbn=9780672306556The 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.
- KentLatriciaAn example of the actor model from the embedded world, QP, https://www.state-machine.com/
- scrootPosting about uFork [1] again! It's a ground-up design for a computing system that is actor based, and one of the most clever things I've encountered in recent years.[1] https://ufork.org/
- peter_retiefInteresting concept Tim, I borrowed some ideas from youhttps://peterretief.org/posts/actors-with-mailboxes/
- nxobjectI’m curious to see whether “no pre-emption” will hold as applications scale up. Given the aggressive enforcement of time-slicing, I’d have trouble writing, say, tasks that lends itself to a recursive call structure yet yields in a predictable amount of time.(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”.)
- halfmatthalfcatI absolutely love actors and what I really wish existed (and where Rust/Embassy/Ector get really close to and where QuantumLeaps has somewhat of a monopoly on) is a full embedded actor system toolchain.Interrupts and timers are such native embedded concepts that fit into hardware, its literally a perfect fit for an actor system.
- FindecanorReminds me of Microsoft's research OS Midori which also did not have preemption: only "green threads" with async and coroutines, albeit on multiple hardware threads.https://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
- Panzerschrek> A handler always runs to completion in a bounded amount of timeWhat 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 saveIf I have no stack, what can I use to save program state? Do I need to mess with global variables for this?
- frumiousircAn interesting project, I say as a fan of actor pattern at the application level.> 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?
- anonundefined
- hn_submitI doubt if a fully cooperative threading operating system (because that's what it is essentially) can be made useful. MMURTL, for example, is mostly a cooperative threading operating system but it does have some preemption mostly to handle high priority messages coming from interrupts.
- evmarThe OS runs Firefox (per another post on the blog), which itself uses threads. How does that work? I guess you need some sort of translation layer to run Linux binaries, which then implements threading atop this actor system?
- skilesareNeat! I've been working on generalizing the Motoko(actor based language that compiles to warm) to a general runtime at https://moxzi.ai, and I hadn't considered pushing it down to the OS level. If you are looking for a higher level actor based language motoko is worth a look.
- hollowoneplYep, it's super fun to write your own OS. Especially in the AI era to accelerate theory testing as the one attached in the blog post.If I agree with it, I don't know.. I have my OS development testing my own theories for last 6 months.. and again.. all I can say is that it's fun, thoughtful and interesting to pursue product management learning points in such project. Completely doable for a single person to have something that works and is complete and from scratch. No Temple OS bullshit for schizophrenics.. No need to be cursed by Perkele like Linus to find devil's skills to convince the community to adopt a school project and go nuts with global adoption..just for fun, real, yet homebrew OS that can run on your own hardware.. or cyberdeck that may be your next project when you get your OS running on boring mundane laptop just fine.
- signa11perhaps it is time to discuss the torvalds-vs-tannenbaum debate once again in $CURRENT era ?
- ShorelThat kinds of remind me of preemptive scheduling in Windows 3.1.There are no actual threads, all programs collaborate to share the single processor they had at the time.
- rbanffyI would love to see a Smalltalk implementation on top of this.
- thornjmIm familiar with the actor pattern but completely naive to their implementation. I’m having trouble imagining a few things and might be way off the mark. A few questions that might help others resolve my confusion:1. Are there as many processes as there are cores on the CPU?2. Is there a single message queue shared across cores?3. Presumably two networking actors or two filesystem actors could be processing different messages on different cores and hardware resources can still be contested?
- McKortyI my passion game project is my world-server an only node-process with eventloops, presence, movements, talk bubbles etc. run without threads. A challange is a chess computer, he run in an own worker_threads, they comunicate only about messages and don't share space. Max. 2 claculatons at the same time, others wait in a queue. Is this yet a Actor-Modell or stilla worker-pool?
- mosuraIs it possible this guy never ran into a UI event loop? Like winmain or the Android Handler . . .Android actually works an awful lot like this, without calling it actors.
- textlapseHow does this compare with Swift actor model?
- objectforlifeSo.. message passing? Alan Kay was right all along?
- flosslyNext: async/evented model? Just one giant event loop (per CPU)? /joke
- YesThatTom2Sounds like a great follow-on project to Amoeba OS by Andrew Tanenbaum.
- cess11"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?
- jvanveenAnother Rust OS, running (almost) on a Fairphone, https://pinnacle-os.eu/blog/fairphone-4/
- jerfThere 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.
- brcmthrowawayWhat if someone wanted to do multicore number crunching??
- bluegattyneat idea!
- arbor-group[dead]
- bearcatty[dead]
- justapie[dead]
- gqcstore[dead]
- lozyra[dead]
- gzellWhy does this feel like Groundhog Day and how did this make it to no. 2 on HN?