Multiple BEAM VMs in the same OS process

It is not possible to run multiple BEAM VMs in the same OS process. Just wondering if it’s feasible to make it so or the required effort and/or technical limitations make that basically impossible.

The reason I’m asking is Livebook runs each notebook in a separate VM for isolation and so in environments where we can have just one OS process (embedded, which is understandable, and iOS which is ridiculous given how powerful the underlying hardware is) we can only have one notebook which is not ideal.

2 Likes

Without having looked very deep I imagine it would be a lot of work. There are a lot of global things in the Erlang VM (process tables, code, names, scheduling info, etc etc) and they would all have to be duplicated and split somehow.

I don’t know about impossible, but it certainly is a lot of work and even more maintaining it.

3 Likes

image

jk, that’s what I expected. Thanks @garazdawi!

4 Likes

There was work done on this very topic back in the 1990s.
There was a “Safe Erlang” project.
There was a “Safer Erlang” project by Lawrie Brown.

The goal was to have a way for a single Erlang node to
contain other (sub-) nodes that shared an OS process and
address space but were logically isolated from each other.

Lawrie Brown wanted it to run untrusted mobile code safely.
I wanted it so that different applications running on the
same node could load different versions of the ‘same’ module,
but his design served that purpose just as well.

You can’t do it with the current emulator, but there is no
fundamental reason why you couldn’t. It’s “A Small Matter of
Programming”. I’d say that it’s harder than (I imagine) adding
maps was, but definitely doable if anyone had the time and
inclination to do it.

If memory serves me correctly, Tcl came up with a ‘sandbox’
scheme back in the late 1990s too. And some Java VMs do this
too, I believe.

3 Likes