3 ms·
> it should be kept in memory, in the same process as the code that's using it how do you do that in a polyglot Environment? Also note, that Erlang processes
by weatherlight 4y ago
> it should be kept in memory, in the same process as the code that's using it
how do you do that in a polyglot Environment?
Also note, that Erlang processes are not the same as OS processes and are much lighter.
- derefr 4y ago> how do you do that in a polyglot Environment? Cloudflare Workers does it by using a WebAssembly runtime (https://developers.cloudflare.com/workers/platform/languages/ https://developers.cloudflare.com/workers/platform/languages...). You compile your C/Go/Rust/whatever code to WASM, and the embedded WASM runtime executes them at "almost native" speed. Whichever runtime they use (probably WAVM?), it has support for "isolates" in the V8 sense (https://v8docs.nodesource.com/node-0.8/d5/dda/classv8_1_1_isolate.html https://v8docs.nodesource.com/node-0.8/d5/dda/classv8_1_1_is...), which work effectively as sandboxes without requiring host:guest process isolation. The strong guarantee of isolation for WebAssembly in particular (stronger than that of isolates for Node.js code) comes from the WASM runtime's use of bytecode with no "escape hatch" to native code (no loading of native modules); and the WASM abstract machine's isolated memory model. Technically, though, I don't think this gets Cloudflare much in latency terms over doing efficient concurrent binary IPC over local Unix sockets, ala the Erlang "C node" model (https://www.erlang.org/doc/tutorial/overview.html#c-nodes https://www.erlang.org/doc/tutorial/overview.html#c-nodes). Due to the aforementioned isolated memory model, even a process-embedded WASM isolate will still require a memcpy(2) to exchange data into and out of the isolate. Unless Cloudflare have hacked up something custom, there's no way to do zero-copy SHM messaging with a WASM program.