245 points ingve 9 hours ago 122 comments
signa11 8 hours ago | parent
hnlmorg 8 hours ago | parent
I remember the debates about monolithic vs microkernel designs. But it was so long ago that I can’t remember any of the specifics.
mrkeen 8 hours ago | parent
hnlmorg 7 hours ago | parent
signa11 8 hours ago | parent
message passing was the mechanism underneath the debate, and not the headline afaik.
pjmlp 7 hours ago | parent
Also running cloud software, serverless runtimes, or distroless containers, on top of type 1 hypervisors, is pretty much a microkernel like architecture.
kvuj 3 hours ago | parent
I feel like you're glossing over 80%+ of smartphones and 90%+ of all servers with that single mention, lol
pjmlp 2 hours ago | parent
frumiousirc 8 hours ago | parent
> 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?
nrdvana 5 hours ago | parent
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.
zbentley 5 hours ago | parent
tgv 5 hours ago | parent
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.
timmisiak 1 hour ago | parent
> It also uses one thread on one processor
Zero threads, and 6 processors.
dapperdrake 2 hours ago | parent
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.
MarceColl 7 hours ago | parent
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...
tancop 7 hours ago | parent
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.
dugmartin 5 hours ago | parent
ch4s3 5 hours ago | parent
timmisiak 50 minutes ago | parent
thornjm 7 hours ago | parent
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?
monocasa 7 hours ago | parent
2) It can be thought of as at least one message queue per actor.
3) Yep.
RossBencina 6 hours ago | parent
As to your final question, actors processing messages is a computation, i/o of any kind would involve sending messages to other lower-level i/o actors that multiplex or coordinate access to individual hardware resources.
mightyham 5 hours ago | parent
I won't presume this is how DbgOS works, but considering that the author mentions writing drivers as actors, I would imagine that two actors would not be allowed to represent the same underlying resource. You would have one actor for each device, then and only then can any number of other concurrent actors build functionality on top of it through message passing.
cess11 7 hours ago | parent
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?
kibwen 6 hours ago | parent
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).
pjmlp 6 hours ago | parent
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.
timmisiak 59 minutes ago | parent
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.
vbezhenar 6 hours ago | parent
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.
monocasa 6 hours ago | parent
signa11 6 hours ago | parent
dapperdrake 2 hours ago | parent
The kernel is a global lock on shared (hardware) resources and stuff like pipe buffers. It is also a library of hardware drivers. Calling the kernel just happens to be termed calling the system "syscall".
From this perspective the BEAM VM or the language run-time are also "kernel".
Panzerschrek 6 hours ago | parent
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?
dapperdrake 2 hours ago | parent
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.
timmisiak 1 hour ago | parent
There's no claim in the article that this is a superior system than threads in the general case.
timmisiak 1 hour ago | parent
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.
YesThatTom2 6 hours ago | parent
zoom6628 6 hours ago | parent
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.
DonHopkins 5 hours ago | parent
speed_spread 5 hours ago | parent
antonvs 4 hours ago | parent
One of the biggest differences is that in actor systems, there's no intermediate queue-like channel that messages are sent to. Messages are sent directly between actors, peer-to-peer. Each actor manages its own private message queue. Similarly, each actor has logically isolated state, so actors can't affect each other except by sending messages.
To achieve the kind of queue-based concurrency you mentioned, the idiomatic actor pattern is to spawn a new actor per request. In the Erlang BEAM VM for example, an actor (Erlang calls them processes) typically spawns within a few hundred nanoseconds.
If you want a shared queue, you can implement an actor to serve that purpose, and there are standard implementations of this. This is kind of the opposite of what COBOL does. The actor and its peer to peer communication are the primitives, and things like shared queues are implemented at the application level. This alone means COBOL does not follow the actor model.
Another big difference is how OS process and thread management are used. No COBOL system ever implemented what Erlang does, which is a single, reliable OS process that manages multiple strongly isolated actors with preemptive scheduling.
CICS came the closest in its early versions, running multiple tasks/units in a single address space on a single thread. But it used cooperative multitasking, not preemptive, and isolation between tasks was fragile - it was quite common for unhandled exceptions or memory overwrites to bring down the the entire CICS address space, terminating all active users. The logical isolation of actors solves for the latter issue. In Erlang, each actor has its own garbage-collected memory pool, and actors can crash without affecting the rest of the system.
The way that was solved in the COBOL world was to move to relying on OS-level concurrency. Tandem NonStop, designed for high availability, was a good example of this. In fact, Erlang inventor Joe Armstrong was influenced by it, but he took advantage of the actor model to implement a much more reliable version of what early CICS systems had - a single OS process running multiple tasks, but with preemptive scheduling and strong task isolation.
You don't have to squint too hard to see resemblances between COBOL and the actor model, but key features of actors, including peer-to-peer task messaging and either (1) strong task isolation or (2) no dependence on OS-level concurrency mechanisms like processes or threads, were never implemented in COBOL systems (afaik).
Actor model systems like Erlang allow for the possibility of running without an OS, because they already handle their own process scheduling, memory isolation, and IPC, so all that's left is drivers, networking, and a bootloader.
Several projects have done this, and the OP article is describing a non-Erlang system in that vein.
Examples of Erlang/BEAM as OS include LING (runs directly on the Xen hypervisor), GRiSP (runs on bare metal embedded systems), AtomVM (for microcontrollers with only kilobytes of RAM), and Nerves (runs on a bare minimum Linux kernel with BEAM as PID 1, to take advantage of hardware drivers.)
adrian_b 4 hours ago | parent
Such a thing cannot exist whenever more than 1 actor can be executed simultaneously.
An actor may have a single input queue, and all other actors can send messages to that unique input queue.
In this case, because there is a 1-to-1 mapping between input queues and actors you could identify the input queues with the actors.
But inside the code implementing the actor, you must have a loop that extracts messages from the input queue, so you must be aware that the input queue exists and it is not the same thing as the actor.
If you had a bad actor implementation without a unique input queue, than you would need something like a separate mailbox for every other actor, where the other actors would deposit messages and each actor would have to poll continuously all such mailboxes, to catch the arrival of any messages, which would be very inefficient.
"Spawning a new actor per request" just means that the implementation of the actor is split into 2 parts, the loop that extracts messages from its input queue and a function that is invoked upon the arrival of a new message, having the message as argument.
Such a splitting makes sense, because the loop handling the input queue could be the same for all actors (but acting on different input queues), with only the function that is invoked for a message containing the part that is different for each actor.
antonvs 4 hours ago | parent
The point is that it's not a shared message queue as in the COBOL case, or most enterprise queuing systems. An actor is a self-contained, isolated object with its own message handling and state, and it executes concurrently with all other actors.
As such, this is not quite correct:
> you must be aware that the input queue exists and it is not the same thing as the actor.
The term "actor" refers to the bundle of state, behavior (handler loop), and message queue.
You certainly must be aware of the existence of the queue though, but since you have to write a message handler loop for each actor, it would be difficult not to be.
fnordsensei 4 hours ago | parent
antonvs 3 hours ago | parent
I mentioned that in my first comment. In actor systems, the idiomatic model is just to spawn a new actor for each job.
But if you want a multi-reader message queue, you can implement an actor that provides that, and there are standard implementations of this.
Actors are the primitive mechanism on which other concurrency mechanism can be built, without all the problems of traditional threads.
adrian_b 4 hours ago | parent
I have written COBOL programs in the very distant past, but they were not concurrent programs, so I do not know how COBOL queues behave, so you are probably right.
But the input queues of actors must also be shared, i.e. they must be "many-to-one" message queues, because there are many other actors which can send messages to an actor.
There are 3 kinds of shared message queues: many-to-one, one-to-many and many-to-many. Whenever the message queues may be used by multiple threads, which is always on modern CPUs, the 3 kinds of shared message queues must use certain methods to allow concurrent accesses, which are different for the 3 kinds of queues.
Obviously, many-to-many queues have the most complex implementation, while many-to-one queues are simpler, but they must still use atomic instructions in the right way, to avoid data corruption. Only the one-to-one message queues do not need atomic instructions, but only store-release and load-acquire instructions.
antonvs 3 hours ago | parent
Each actor owns its own queue, and is the only reader. This makes it a many-to-one queue.
> Whenever the message queues may be used by multiple threads, which is always on modern CPUs, the 3 kinds of shared message queues must use certain methods to allow concurrent accesses, which are different for the 3 kinds of queues.
This is exactly what actor systems like Erlang avoid. The Erlang VM handles preemptive multitasking for the actors it manages, without using OS threads. This eliminates a lot of concurrency issues, and is a big part of why Erlang systems have such a reputation for reliability.
You can think of it like a green thread system where each thread has its own private message queue.
> but they must still use atomic instructions in the right way, to avoid data corruption.
This is only an issue because the message queues you're talking about are implemented separately from the OS, so there are no guarantees about concurrency behavior. This is exactly what the actor model solves for.
adrian_b 2 hours ago | parent
In general, in programs it does not matter much where you put artificial borders of ownership between entities, but whether the access to a resource is shared or exclusive has a crucial impact on the required code.
If threads are not visible to the programmer who writes the code for an actor, there are 2 cases. The first is when threads really do not exist, in which case the VM is single-threaded and executed on a single core of a modern CPU, so the achievable performance is modest, but there is no need for handling concurrency.
The second case is when the VM is in fact multi-threaded, which, as you say, must be the case for Erlang, but it manages the scheduling of the threads itself, and the allocation of actors to threads, in a manner transparent for the programmer.
In this case the VM must include code for managing concurrent accesses from multiple hardware threads to the message queues, so they still are shared-access queues, even if their implementation is provided by the VM.
eproxus 4 hours ago | parent
I'm guessing an OS built on the BEAM or a similar model would take a similar approach, where code executed by actors is actually run in schedulers, that can multiplex them and make the message passing efficient because they know what happens in the system.
spinningslate 4 hours ago | parent
> in actor systems, there's no intermediate queue-like channel that messages are sent to.
There are essentially two message passing models:
1. Multiple writer/single reader
2. Multiple writer/multiple reader
Where multiple/single means the number of actors/processes[/whatever] that can read or write to a queue.
Erlang and the Actor model are examples of the former. Multiple Actors can write to a given queue but only one Actor can read from it. From the writer's perspective, the queue is part of the reading Actor; the abstraction boundary encompasses the queue. Strictly speaking, the writer doesn't even know a queue exists: it just has a porthole it can push messages at.
Internally the Actor comprises 3 things: (1) the queue, (2) the read loop, and (3) the actions that get called in the read loop based on the received message. None of that is visible outside the Actor though. If you draw a diagram of an Actor system, it only shows Actors and the messages sent among them. Queues are hidden at that level.
Contrast that with the multiple reader/multiple writer scenario. This is the model used in service bus middleware like RabbitMQ. In this case the queues are external to the readers and writers. A system-level diagram would show the queues as first-class entities, alongside the components reading and writing to them.
adrian_b 3 hours ago | parent
As I have already said in another comment, I assume that the poster to which I have replied meant to say that the COBOL queues are many-to-many message queues, which are distinguished from many-to-one message queues exactly as you describe.
However the original comment was not clear, because the difference in behavior in comparison with actors is not given by the existence or non-existence of queues, which must always exist for message passing, but in the important differences both in implementation techniques and in their behavior, between many-to-one queues and many-to-many queues.
antonvs 1 hour ago | parent
The distinction is between the use of queues shared between tasks and queues that are owned, and only readable by, each individual task (actor).
Another point about all this is that actors aren't just a concurrency mechanism that you can use or not as you see fit. They're a fundamental unit out of which entire applications are built. There are no function calls between actors, only message passing. This provides useful global concurrency safety properties that other systems can't match unless they essentially reimplement some similar model throughout the system.
What I'm getting at here is it's not just the properties of the individual queues that matter, but how the model is applied and enforced system-wide.
christophilus 4 hours ago | parent
dapperdrake 2 hours ago | parent
This is the kind of knowledge and wisdom I come to HN for. Seriously.
The systems from the 60s and 70s and 80s were designed by brilliant people.
What is old is new again.
rbanffy 6 hours ago | parent
abecedarius 3 hours ago | parent
torginus 6 hours ago | parent
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.
imtringued 6 hours ago | parent
Blocking is not a threading or even OS concept. Blocking is a CPU core and programming language concept derived from sequential processing. Blocking means that instructions behind the block are not being executed while the block is in progress.
In the actor model, sending a message must never prevent the execution of instructions that follow after sending the message. The continued execution of further instructions must be guaranteed until the actor has processed the message. Responses must be received through the actor's mailbox.
Since blocking as an absolute concept may not make much sense, because all sequential processes (e.g. execution of an instruction) are blocking temporarily, the author decided instead to define a time bound, so if mail box processing takes too long, simply because the algorithm is CPU intensive, the author considers it blocked as well and schedules the next actor.
Edit: I guess the confusion comes from the fact that Rust's async facility automatically converts the code into a state machine that is compatible with actor execution semantics, but technically violates the spirit of actors.
majke 5 hours ago | parent
It just happens that in threads, there is this magical place called stack that you can SUPER fast allocate memory for new function frame. If you have a complex program that uses many deep very deep calls to functions withing functions within functions, you dont need to deal with register allocation or even "local stack frame" for local variables allocations. You just zip in and zip out of the "thread" stack all the time, millions times per second.
The disadvantage is that if for whatever reason a deeply nested thing needs to do _something_, typically I/O, then there is no easy way to yield and allow someone else to use ALU. One option is to change stack register to some other stack and continue other stream of compute. This done by OS is called a context switch.
However, for certain problems, there is an alternative - async. In async the "stack" for local variables is more explicit, very often on the heap, and is managed differently. Every time you are calling a nested function it also needs to store the local variables somewhere, so either you emulate stack somehow (in which case this is not much differnet than normal thread) or allocate the nested function local variables space using memory allocator on heap or special memory.
This is great beause it allows you to reduce the cost of a context switch - now you don't need to change the stack pointer and save context, becasue context is by definition saved in the async block. Asnc also allows you to NOT overcommit on stack size for some future deep deep nested fucntion calls that might never happen. In async you know exactly where you can yield and can plan for it.
However it's not like these two models are fundamentally different. It's the same problem of "where the local variables live" and "how to allocate this memory". We have far bigger problem - due to historical reasons "blocking" is a thing, but this is is only because we made mistakes designing operating systems (I'm looking at you fsync, open, close, or even bpf() syscalls).
zbentley 5 hours ago | parent
1. The decision of when to switch routines is more consequential than the cost of stack or context switching. Letting the OS decide results in behavior that is consistently fair for all programs, caveat scheduler bugs. Letting user code decide results in behavior that is only as fair as a given program. Writing code in the latter environment entails wrestling with the reality that it may not run to completion unless other code in the environment lets it. That applies in async programming to a much wider range of situations than kill signals/aborts, which are the only even slightly analogous things in threaded programming.
2. Async is a subset of threaded programming (it has a hardware stack, and can call typical context-switchful code if it wants to block).
adrian_b 4 hours ago | parent
On modern CPUs, which have many hardware threads, the operating system and the user programs must handle at least the number of hardware threads, e.g. 32 threads on an AMD 9950X.
Implementing more threads than the hardware threads is optional, but the hardware threads must have their own states and stacks and if they exchange messages the inter-thread messages must pass through message queues located in shared memory and using algorithms that enable concurrent accesses.
Naive implementations of message queues can use locks for mutual exclusion, but better implementations exploit the fact that message queues, like also arrays, can be dynamically partitioned using atomic fetch-and-add instructions, so that many threads can access concurrently a message queue, without using either mutual exclusion or optimistic accesses (which may need retries).
It is possible to have an operating system where there exists no shared state between threads, with the exception of the shared message queues.
Because message queues can be implemented without the need for mutual exclusion, it is possible to have an operating system where mutual exclusion (i.e. locks) is not used anywhere.
Whether an operating system without shared state between threads can have a performance comparable with e.g. Linux or Windows, is an open problem.
The lack of shared state does not mean that superfluous copies are needed. The messages may contain pointers to buffers in shared memory through which the bulk of the data is transferred between threads, but those buffers always have a current owner, i.e. the receiver of the message, and no other thread attempts to access them, including the sender of the message, which has written the buffer before sending the message.
Asmod4n 5 hours ago | parent
One is the poll model, you ask the OS when you can use something.
The other one is the completion model, where you ask the OS to do something on your behalf and ask it when it’s done.
In the former you are the mailbox yourself, in the latter the OS is the mailbox.
When you are the mailbox yourself threads are kind of needed. When the OS is the mailbox it can implement them however it wants to.
I’d guess this OS is doing Mailbox duty itself instead of letting userspace handle it.
adrian_b 5 hours ago | parent
That is "you ask the OS to do something on your behalf and you do not have to check when it is done", because you have a unique queue where you receive notifications about everything that is of interest for you, including the completions of I/O activities that you have requested previously.
"You ask the OS to do something on your behalf and ask it when it’s done" was an ancient method to perform asynchronous I/O, which survived in many operating systems much more years than it should. Continuing to use such a method today is a mistake.
The best method for asynchronous I/O is with a unique input queue, like in the Linux io_uring. The second best method, because it can be used to implement a unique input queue, is with what in DEC RSX-11M was called "Asynchronous System Trap Service Routine", i.e. a callback function to be invoked upon I/O completion, which was inherited from DEC RSX-11M into DEC VMS, from where it was inherited into Microsoft Windows NT, and then in 1994 MS Windows NT 3.5 introduced the "I/O Completion Ports", which was AFAIK the first improvement in asynchronous I/O handling after what DEC RSX-11M did 20 years earlier, in 1974 (which was again the first improvement over what IBM PL/I already had in 1964, when it had the equivalent of WaitForMultipleEvents, but in a more powerful variant than in Windows NT).
Asmod4n 3 hours ago | parent
Having your OS do the batching for you can make it twice as fast.
My new http implementation went from 3 million responses per second per thread to 6 million, just from replacing epoll and non blocking sockets with liburing and batching.
inkyoto 5 hours ago | parent
«Actors» imply «no shared state» – there is a message inbox and a message outbox, but the state is private to the actor.
Both can be asynchronous.
zbentley 5 hours ago | parent
Threads are not a programming paradigm or style, any more than a CPU is a programming paradigm or style. They’re a tool, an existential piece of the landscape which can be used to perform paradigms/styles. Like CPUs, they do have affinity for certain use cases, but the car is not the road trip.
layer8 5 hours ago | parent
nmcfarl 4 hours ago | parent
inkyoto 3 hours ago | parent
Threads are to a process what a single CPU core is to a multi-core CPU.
zelphirkalt 5 hours ago | parent
I think the very brief answer to that is: "Processes." as in the general concept of communicating processes. How those are actually implemented on another layer depends on the platform. You can also run an actor system on a machine, that can only do one thing at a time, using a single CPU core. The work the process does is not blocking, but the platform might not have the capability to do more than one thing at a time. But this is different from work being inherently sequential.
timmisiak 1 hour ago | parent
nvarsj 5 hours ago | parent
ch4s3 5 hours ago | parent
zelphirkalt 5 hours ago | parent
ch4s3 4 hours ago | parent
def handle_cast({:increment, by}, state), do: {:noreply, state + by}
Obviously you can be as loos or rigorous as you want and go all the way up to implementing a finite state machine with aggressive guards.
You can use observer to see what's happening with various processes/actors.
fpoling 5 hours ago | parent
The drawback is that one can have stack trace in prod but no time-traveling debugging. But then a typical workaround is to log explicitly state transitions. Depending on how it is done it can be sufficiently ergonomic and still gives more information than stack traces.
timmisiak 1 hour ago | parent
jghn 4 hours ago | parent
I liked it, but my takeaway was that the negatives outweighed the positives, especially when factoring in not everyone was capable of dealing with it. I'm sure there are use cases where that calculus changes, but not the ones I had.
halfmatthalfcat 3 hours ago | parent
NBJack 3 hours ago | parent
bluegatty 5 hours ago | parent
nxobject 5 hours ago | parent
(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”.)
dapperdrake 2 hours ago | parent
gzell 5 hours ago | parent
skilesare 4 hours ago | parent
hollowonepl 4 hours ago | parent
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.
notpublic 4 hours ago | parent
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).
f13f1f1f1 52 minutes ago | parent
jerf 4 hours ago | parent
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.
evmar 2 hours ago | parent
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.
timmisiak 55 minutes ago | parent
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.
torginus 4 hours ago | parent
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.
01HNNWZ0MV43FF 3 hours ago | parent
That's probably why GUI programming is so hard and every GUI sucks.
Anything that happens outside RAM requires you to respond to every possible input in the middle of any possible operation
dapperdrake 2 hours ago | parent
Thread-safety
What is old os new again.
Unix also learned this the hard way with signals and job control. Signals are still footguns.
torginus 2 hours ago | parent
torginus 2 hours ago | parent
dapperdrake 2 hours ago | parent
Fire and forget is mostly useless. One of the many counter-examples is the existence of TCP and QUIC. Raw UDP has legitimate use-cases, but falls short for many other real-world use-cases.
gwbas1c 2 hours ago | parent
Specifically, we introduced a single actor that manipulated shared state and was responsible for some critical IO. Other actors could see the shared state in a non-blocking manner, so there ended up being a lot of "refresh my shared state" or "abort if the shared state changed".
My longer-term conclusion was that the actor model wasn't correct for the product, because it obscured the procedural nature of what happened in each operation. It should have been multithreaded (or green threads) with each operation spawning a thread; and then classical read/write locks (with timeouts) on shared state. In some cases where batching happened (for some API calls), some kind of message passing would be needed, but the parent thread would need to block on the thing that does the batch.
timmisiak 2 hours ago | parent
Is it a panacea? No, certainly not. But I do think it provided some interesting capabilities and tradeoffs that are useful to think about.
jvanveen 3 hours ago | parent
halfmatthalfcat 3 hours ago | parent
Interrupts and timers are such native embedded concepts that fit into hardware, its literally a perfect fit for an actor system.
cestith 2 hours ago | parent
KentLatricia 2 hours ago | parent
hn_submit 2 hours ago | parent
timmisiak 1 hour ago | parent
So for purpose-built applications I think it can be useful. As a general purpose OS where people want to run a browser, it's probably not likely to be useful.
abound 2 hours ago | parent
cestith 2 hours ago | parent
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.
evmar 1 hour ago | parent
McKorty 1 hour ago | parent
scroot 1 hour ago | parent
Shorel 1 hour ago | parent
There are no actual threads, all programs collaborate to share the single processor they had at the time.
Findecanor 37 minutes ago | parent
https://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
tontinton 5 minutes ago | parent
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.