Awesome! I'd love to see userspace work in wasm too though. Someone once did a PoC, but scheduling processes was a pain - AFAIK noone knows how to force preemption?
Another way to run whole operating systems in the browser is to put a second JIT on top of the browser's: an instruction set emulator that compiles guest code to JavaScript, which V8 then compiles to native code.
Here is the original PDP-7 Unix running that way. Log in as dmr password dmr and type ls and cat the source code to his PDP-7 assembler in PDP-7 assembler and B compiler in B. The b_readme tells how to build, assemble, and run B code.
The higher level JavaScript targeting JIT speculates and inlines based on the code that's actually running, so if you generate JavaScript it can optimize well, it does a lot of the work for you. Drag the speed slider all the way to the right to MAX and in the upper right corner it shows the performance, which is over 250x real time on my M4 Mac.
Vanessa Freudenberg made this argument for the SqueakJS JIT here in 2023: "That would potentially give us more speed than even WASM." and "My plan is to do as little as necessary to leverage the enormous engineering achievements in modern JS runtimes." (https://news.ycombinator.com/item?id=38774277)
The emulator's CPU is built on the design of Korz, David Ungar's successor to Self (with Harold Ossher and Doug Kimelman at IBM Research). Self's adaptive compilation is where V8's techniques came from, so the lower JIT gets fed what it was built for. Click on the SLOTS and KORZ buttons to inspect the JS code it's generating and running.
The same PDP-7 runs Mitch Bradley's PDP-7 Forth, PIXIE from 1971, and Unix. There's also a Korz Apple ][ running Little Computer People, and I measured it against microM8, a good Apple ][ emulator written in Go, compiled to WebAssembly. In multiples of a real Apple ][+:
That's 15 to 52 times faster, but most of the gap isn't WASM itself. microM8 builds the picture inside every instruction, calls memory and devices through Go interfaces, and carries the Go runtime, scheduler and garbage collector on the same thread as the CPU loop, in a 41 MB module. A plain switch emulator written so V8 can optimize it already runs at 130 million cycles a second, and it beats my JIT on the DOS boot and on Applesoft. The JIT wins when a block of guest code stays put and repeats: it turns that block into a JavaScript function, and V8 specializes it. A WASM optimizer can't do that step for you, because to it the guest's opcodes are just data.
I could see this being useful if there was a TUN/TAP device that talks to a backend server over websockets.
EDIT: Looks like there is some networking support https://github.com/pithings/unkernel#add-a-network
Is it possible to hide the status bar at the bottom?
Awesome! I'd love to see userspace work in wasm too though. Someone once did a PoC, but scheduling processes was a pain - AFAIK noone knows how to force preemption?
https://joelseverin.github.io/linux-wasm/
https://wland.vercel.app/
WASM Wayland Compositor made by the same author
>Awesome! I'd love to see userspace work in wasm too though.
Totally! So we can run a browser inside Linux that runs in a browser.
teri aisi ki taisi
That's nice but can it run DOOM
This sounds cool. Serious question, what are the applications?
sandboxes, throw away environments, playgrounds, clusters.. plenty I think
If I write any app name, it will automatically start apt-get install that app. Ctrl + C doesn't stop it. Are there different shortcuts?
Seems to me that Replit should be using something like this rather than running your app remotely.
you need more than a Linux kernel to host a web app that can run all the software web developers want
Another way to run whole operating systems in the browser is to put a second JIT on top of the browser's: an instruction set emulator that compiles guest code to JavaScript, which V8 then compiles to native code.
Here is the original PDP-7 Unix running that way. Log in as dmr password dmr and type ls and cat the source code to his PDP-7 assembler in PDP-7 assembler and B compiler in B. The b_readme tells how to build, assemble, and run B code.
https://hyperties.org/cabinet/systems/pdp-7-unix/
The higher level JavaScript targeting JIT speculates and inlines based on the code that's actually running, so if you generate JavaScript it can optimize well, it does a lot of the work for you. Drag the speed slider all the way to the right to MAX and in the upper right corner it shows the performance, which is over 250x real time on my M4 Mac.
Vanessa Freudenberg made this argument for the SqueakJS JIT here in 2023: "That would potentially give us more speed than even WASM." and "My plan is to do as little as necessary to leverage the enormous engineering achievements in modern JS runtimes." (https://news.ycombinator.com/item?id=38774277)
The emulator's CPU is built on the design of Korz, David Ungar's successor to Self (with Harold Ossher and Doug Kimelman at IBM Research). Self's adaptive compilation is where V8's techniques came from, so the lower JIT gets fed what it was built for. Click on the SLOTS and KORZ buttons to inspect the JS code it's generating and running.
The same PDP-7 runs Mitch Bradley's PDP-7 Forth, PIXIE from 1971, and Unix. There's also a Korz Apple ][ running Little Computer People, and I measured it against microM8, a good Apple ][ emulator written in Go, compiled to WebAssembly. In multiples of a real Apple ][+:
That's 15 to 52 times faster, but most of the gap isn't WASM itself. microM8 builds the picture inside every instruction, calls memory and devices through Go interfaces, and carries the Go runtime, scheduler and garbage collector on the same thread as the CPU loop, in a 41 MB module. A plain switch emulator written so V8 can optimize it already runs at 130 million cycles a second, and it beats my JIT on the DOS boot and on Applesoft. The JIT wins when a block of guest code stays put and repeats: it turns that block into a JavaScript function, and V8 specializes it. A WASM optimizer can't do that step for you, because to it the guest's opcodes are just data.Benchmarks:
https://github.com/SimHacker/WillWrightShowForFood/blob/main...
Go and TypeScript: The Wasm build waits:
https://github.com/SimHacker/WillWrightShowForFood/blob/main...
The demo that goes with the talk:
https://www.youtube.com/watch?v=I-Rf3XP_D0g
Forth Day talks, Mitch Bradley on PDP-7 Forth and me on the PDP-7 and Apple ][ emulators:
https://www.youtube.com/watch?v=k2pwJ294r8o
PIXIE and FORTH on PDP-7 Cabinet Emulator with Type 340 Vector Graphics Display:
https://www.youtube.com/watch?v=lo8kdY-5i6c
More about PDP-7 Forth:
https://github.com/SimHacker/WillWrightShowForFood/blob/main...
More about Korz:
https://github.com/SimHacker/moollm/blob/main/designs/korz
Thank your, Mr. Claude.