‹ Post details

An OS with no threads: The Actor Model

  • timdbg.com
  • By ingve
  • 219 points
  • 107 comments

Discussion

Source links

Showing up to 12 top-level comments in Hacker News order.

  1. zoom6628
    OLd(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.
  2. torginus
    I 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.
  3. evmar
    The 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?
  4. notpublic
    May 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 Hewitt https://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).
  5. cestith
    I 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=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.
  6. tancop
    You 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.
  7. torginus
    The 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.
  8. KentLatricia
    An example of the actor model from the embedded world, QP, https://www.state-machine.com/
  9. MarceColl
    I 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...
  10. abound
    I'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/
  11. nvarsj
    Ime 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.
  12. vbezhenar
    UNIX 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.

Source links