The slowest part is always emulating the MMU, as that adds a 2-3× overhead to every memory access. In that sense ARM Sv39 is not a great choice.
Usually emulators use a direct-mapped cache (basically a software TLB).
In this case though, since you control the kernel, it could use something like the MIPS software-managed TLB of the olden days, with bespoke paging data structures and fast-path page fault handlers, perhaps also using PowerPC Inverted Page Tables as inspiration. (and eg. changing page allocation strategies to constrain pages in the lower address space region to simplify cache look up, and something to prevent cache set conflicts).
Given that the working set is small tho in this use case, eg. just a kernel-managed direct-mapped `page_number[MAX_PAGES] → base_address` table is sufficient and fast. (with some trick for page faults; also who needs granular RWX access permissions...)
I tested this, doesn't seem to offer a speedup in real workloads, there is a speedup only in a simulated tlb thrashing microbenchmark
wasm32-jit on a ryzen 9 3900, lower ms = faster
workload baseline flat-mmu winner
------------------------ -------- -------- ------
conflict (tlb thrashing) 491 ms 39 ms flat-mmu 12.7×
chase (pointer chasing) 448 ms 116 ms flat-mmu 3.9×
stream (sequential rmw) 78 ms 80 ms baseline 1.03×
sieve (primes) 81 ms 84 ms baseline 1.04×
high-conflict (>64 mib) 484 ms 506 ms baseline 1.05×
fib (cpu) 35 ms 37 ms baseline 1.05×
mem (memory ops) 69 ms 75 ms baseline 1.08×
sha (hashing) 97 ms 106 ms baseline 1.09×
boundary (64 mib edge) 73 ms 82 ms baseline 1.13×
high (hot pages >64 mib) 27 ms 32 ms baseline 1.21×
control (hot pages) 27 ms 32 ms baseline 1.21×
If what's supposed to be just removing code and instructions from the hot path is benchmarking as slower, I think there's a problem with the implementation :)
Did you check the final compiled assembly for the memory access path?
Also measuring only the whole system in a comparison benchmark is not statistically appropriate/legible, what's desired is something like causal profiling (to isolate the slowness of the rest of the system vs. the part that's being optimized):
You are right, after more cleaning up the micro-benchmarks recovered. I still could not get it to translate to improvements in real-world tests (nix eval, sqlite, etc). The original patch put a 64 MiB range check and a second lookup in front and kept the old path as the fallback
microbenchmark flat map 8x TLB
conflict 13.7x 14.5x
chase 3.6x 3.5x
high-conflict 0.81x 16.2x
high 0.76x 1.00x
mem/sha/sieve 0.90-1.03 ~1.00
real world:
cold boot 278 -> 276 ms
nix eval 670 -> 726 ms
sqlite 10k 676 -> 724 ms
He is a mortal. You didn't write jslinux because you don't want to, didn't try, or weren't born yet. If you actually want to write jslinux, go and do it.
My test workload today was 40% slower on jslinux than unkernel, which surprised me tbh, and then some microbenchmarks were 4-40x slower - but on the plus side, all the workloads indeed worked unmodified.
Slow, but that’s expected. Otherwise ran Postgres unmodified. Not sure if this will be useful for anything serious, but demos of real Linux software have become zero friction today. Amazing.
wow, thanks for sharing that. I would not have expected Postgres to be able to run in WebAssembly. (In my other comment you can see I built and ran an ascii graphics version of Doom on this, but Postgres is a much larger project.) Do you remember what the memory usage was with Postgres running? (Listed at the bottom of the tab). With the Doom build it was at 722/4G after installing all the build tools for it.
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?
Asyncify works but no goto means no setjmp, exceptions, etc. without Emscripten tricks And mmap generally needs TLB. So you may as well do a JIT emulator.
I don't know how tightly that's sandboxed. It seems to be able to fetch any site, which would be something to keep in mind if you use it to execute untrusted code in your own project.
Wow, what a great nerd snipe for a Sunday morning.
I launched it, installed Claude CLI, had it poke around, then I installed Docker and had to poke a bit to get it running, but I got the hello-world container to work!
I doubt anything practical would come from this project*. Which is fine. Doing something for educational purposes, or even just for fun, is reason enough in my opinion.
* all the use cases people have speculated about feel more cumbersome and/or less reliable than established methods already used in the industry.
A project of this complexity essentially _would guarantee_ you an L8/9 position at any FAANG, _if_ FAANG hiring wasn't overrun by rampant nepotism and incompetence.
That's the thing, isn't it. Even if you did it manually, people would just assume it was slop.
In fact, even if you spent several years doing it manually, and then AI came along that could do a better job in mere minutes. (Not that I'd know anything about that...)
I guess it turns out we were always more impressed with the suffering than with the end result.
It depends on whether you value writing code or running code more. And how much of a backlog you have of code you want to run and problems you want to solve.
As it turns out, code is usually run millions of times more than it's written.
There was always the old trope on HN where someone would come along with something useless, and someone would ask "What's the point?", and then they'd get downvoted and swarmed with replies: "Because it's fun."
For me the act of using my knowledge, skills, and intellectual curiosity to build occasionally beautiful software artefacts out of ideas wasn't "suffering" - even when debugging could definitely involve a little suffering - it was fun.
It wasn't "suffering" we were valorizing; it was craft, artistry, inspiration, insight, creativity, intellectual pursuit. I understand why LLMs have replaced all that, but let's be brave and mature enough to acknowledge what we've lost, even as we accept it.
I think art is actually the point of life. I've felt that way for a long time.
Just now, I enjoyed an AI generated comedy animation. I would probably have enjoyed it a little more if I had known humans had spent hundreds of hours drawing and animating it by hand. That's what I was referring to. There would be a sense of awe and admiration, which is (mostly) absent now.
(Which ironically is itself unfair, I know that even doing AI art well is also a pain in the ass! There's just a couple zeroes missing at the end of the number...)
But in both cases (manual or slopswarmed), the impulse is, "this needs to exist. It bothers me that this doesn't exist, or that it's not as good as it could be."
Eventually… But I'd guess for now memory limits, the size of a dev env, and overhead when mounting in whatever files you actually need access to make that less attractive than it sounds.
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 on HN 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 ][ emulator 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 think the most interesting point this illustrates is that Korz is a great way to write Just In Time compiling emulators that run extremely efficiently in the browser, in way that can achieve much higher performance than WASM. And Korz is generally useful for a lot more than just emulators.
When I tried it a while back, Go was not very good for writing fast interpreters, even when compiled natively rather than to WebAssembly. Interpreter inner loops are a niche use case that they apparently haven’t tried to optimize, and interface values are rather inefficient union types. If I were going to write a fast interpreter using WebAssembly, I would use a different language.
It’s experimental, but it might be fun to try Zena to see what WebAssembly can do: https://zena-lang.dev/
Thank you for sharing this! Could you please add a user 'guest' pwd 'guest' login, I don't like to log in as other people for various reasons.
Also, please be aware that AI-written or AI-edited comments aren't allowed on HN at all, this sentence sounded a little like AI to me: "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."
I understand that AI can write very good technical prose but it isn't allowed here at all, you are only allowed to summarize it in your own words. Thank you.
The slowest part is always emulating the MMU, as that adds a 2-3× overhead to every memory access. In that sense ARM Sv39 is not a great choice.
Usually emulators use a direct-mapped cache (basically a software TLB).
In this case though, since you control the kernel, it could use something like the MIPS software-managed TLB of the olden days, with bespoke paging data structures and fast-path page fault handlers, perhaps also using PowerPC Inverted Page Tables as inspiration. (and eg. changing page allocation strategies to constrain pages in the lower address space region to simplify cache look up, and something to prevent cache set conflicts).
Given that the working set is small tho in this use case, eg. just a kernel-managed direct-mapped `page_number[MAX_PAGES] → base_address` table is sufficient and fast. (with some trick for page faults; also who needs granular RWX access permissions...)
I learned this from inspecting the code that TCG on QEMU generates... was very surprised when a load ballooned into tens of instructions!
Isn't Sv39 RISC-V thing?
Yeah, the project mixes the ARM ISA and the RISC-V page table format...
I tested this, doesn't seem to offer a speedup in real workloads, there is a speedup only in a simulated tlb thrashing microbenchmark
If what's supposed to be just removing code and instructions from the hot path is benchmarking as slower, I think there's a problem with the implementation :)
Did you check the final compiled assembly for the memory access path?
Also measuring only the whole system in a comparison benchmark is not statistically appropriate/legible, what's desired is something like causal profiling (to isolate the slowness of the rest of the system vs. the part that's being optimized):
https://github.com/plasma-umass/coz https://rocm.docs.amd.com/projects/rocprofiler-systems/en/la...
You are right, after more cleaning up the micro-benchmarks recovered. I still could not get it to translate to improvements in real-world tests (nix eval, sqlite, etc). The original patch put a 64 MiB range check and a second lookup in front and kept the old path as the fallback
Fabrice Bellard beat you to it, with jslinux in 2011.
http://bellard.org/jslinux
It’s hard to know which one came first really…
We don't really count that, if it's technically possible, fbellard has done it already. We care about what mere mortals do.
I know you jest but pithings used LLMs in this project
The word “real” in the title gave that away immediately. LLMs love calling things real when there’s no reason to.
fbellard has been silently updating things (if I were an LLM, I’d say “quietly”). For example:
https://bellard.org/ffasn1/
ASM.1 parser compiler, updated 10 days ago, including a Cosmopolitan build.
If I remember correctly his day-to-day involves working on cellphone infrastructure, which heavily uses ASN encoding.
He is a mortal. You didn't write jslinux because you don't want to, didn't try, or weren't born yet. If you actually want to write jslinux, go and do it.
Do you take everything literally, or is that kleptomaniacs?
My point remains valid no matter whether it offends you. The biggest barrier to doing something like that is inside your own head.
You really do then. I see.
fbellard is the neil cicierega of technology
The README mentions this and discusses differences from other approaches. JSLinux is fully emulated, the kernel is not compiled to WASM.
https://github.com/pithings/unkernel#-how-it-works
My test workload today was 40% slower on jslinux than unkernel, which surprised me tbh, and then some microbenchmarks were 4-40x slower - but on the plus side, all the workloads indeed worked unmodified.
Slow, but that’s expected. Otherwise ran Postgres unmodified. Not sure if this will be useful for anything serious, but demos of real Linux software have become zero friction today. Amazing.
wow, thanks for sharing that. I would not have expected Postgres to be able to run in WebAssembly. (In my other comment you can see I built and ran an ascii graphics version of Doom on this, but Postgres is a much larger project.) Do you remember what the memory usage was with Postgres running? (Listed at the bottom of the tab). With the Doom build it was at 722/4G after installing all the build tools for it.
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/
>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.
https://slopshare.dev/v0.1.8/wine/ chromium in progress let's see how it goes ~
You didn't have to wait long (scroll to the bottom)
https://fzakaria.com/2026/11/23/2035-came-early
https://wland.vercel.app/
WASM Wayland Compositor made by the same author
Asyncify works but no goto means no setjmp, exceptions, etc. without Emscripten tricks And mmap generally needs TLB. So you may as well do a JIT emulator.
Yeah, so, you drop V8 (or any other WASM engine) into your code, and you have a pretty tightly sandboxed Linux kernel running inside it?
I don't know how tightly that's sandboxed. It seems to be able to fetch any site, which would be something to keep in mind if you use it to execute untrusted code in your own project.
If you wire it, yes, it has internet access.
Wow, what a great nerd snipe for a Sunday morning.
I launched it, installed Claude CLI, had it poke around, then I installed Docker and had to poke a bit to get it running, but I got the hello-world container to work!
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
This sounds cool. Serious question, what are the applications?
sandboxes, throw away environments, playgrounds, clusters.. plenty I think
Looks good on a CV.
I doubt anything practical would come from this project*. Which is fine. Doing something for educational purposes, or even just for fun, is reason enough in my opinion.
* all the use cases people have speculated about feel more cumbersome and/or less reliable than established methods already used in the industry.
"Told Claude to build cool thing (2026)"
A project of this complexity essentially _would guarantee_ you an L8/9 position at any FAANG, _if_ FAANG hiring wasn't overrun by rampant nepotism and incompetence.
Finally a modern contender to "for sale: baby shoes, never worn".
Really, every single interesting project I see these days I'm completely unable to feel awe or curiosity since I just assume it was AI-made.
That's the thing, isn't it. Even if you did it manually, people would just assume it was slop.
In fact, even if you spent several years doing it manually, and then AI came along that could do a better job in mere minutes. (Not that I'd know anything about that...)
I guess it turns out we were always more impressed with the suffering than with the end result.
It depends on whether you value writing code or running code more. And how much of a backlog you have of code you want to run and problems you want to solve.
As it turns out, code is usually run millions of times more than it's written.
Cheer up Brian, you know what they say.
https://www.youtube.com/watch?v=uAzwji5Cfmk
There was always the old trope on HN where someone would come along with something useless, and someone would ask "What's the point?", and then they'd get downvoted and swarmed with replies: "Because it's fun."
For me the act of using my knowledge, skills, and intellectual curiosity to build occasionally beautiful software artefacts out of ideas wasn't "suffering" - even when debugging could definitely involve a little suffering - it was fun.
It wasn't "suffering" we were valorizing; it was craft, artistry, inspiration, insight, creativity, intellectual pursuit. I understand why LLMs have replaced all that, but let's be brave and mature enough to acknowledge what we've lost, even as we accept it.
I think art is actually the point of life. I've felt that way for a long time.
Just now, I enjoyed an AI generated comedy animation. I would probably have enjoyed it a little more if I had known humans had spent hundreds of hours drawing and animating it by hand. That's what I was referring to. There would be a sense of awe and admiration, which is (mostly) absent now.
(Which ironically is itself unfair, I know that even doing AI art well is also a pain in the ass! There's just a couple zeroes missing at the end of the number...)
But in both cases (manual or slopswarmed), the impulse is, "this needs to exist. It bothers me that this doesn't exist, or that it's not as good as it could be."
This humorous talk [1] from 2014 outlines it pretty well, skip to 18:40 in the video.
[1] https://www.destroyallsoftware.com/talks/the-birth-and-death...
Education? Essentially a linux box anyone can just bring up and use Python etc.
This is a way to run Claude code and codex purely in a browser. That could be useful.
Could this eventually be used to run isolated development envs. directly in the browser without needing a remote server for each session?
Eventually… But I'd guess for now memory limits, the size of a dev env, and overhead when mounting in whatever files you actually need access to make that less attractive than it sounds.
Sounds like you'd be interested in https://www.wasmer.sh/
Not just in the browser, wasm is also a sandbox for the server.
I was expecting the architecture to be riscv64 but it’s aarch64 which is more convenient!
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?
So we can build something like browserstack?
Why would it emulate aarch64? Because Linux supports it?
It would be interesting to fake CPU architecture that is optimal for WASM.
Packages just work.
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
Doesn't work in Safari: Failed to load webkit-masked-url://hidden/
Seems like the Noir extension was the issue. Created strange CSP violations I've never seen happening anywhere else before.
Is it possible to hide the status bar at the bottom?
Yes, we are getting close
https://www.destroyallsoftware.com/talks/the-birth-and-death...
He was even close on the timeline, putting the birth of the METAL operating system in 2028.
That's nice but can it run DOOM
>can it run DOOM
Yes! I tried it, and you can too, I give the steps below or you can just see the following video :)
https://youtu.be/Tn0zzS-kUoY
it's a 2 minute 17 second video, if you're impatient here is the timestamp of the playthrough, it starts at 1m29s:
https://www.youtube.com/watch?v=Tn0zzS-kUoY&t=1m29s
My build walkthrough (steps I followed) is here:
https://pastebin.com/zXRJqSqG
let me know if you were able to follow it, I built it on the latest Safari on Mac but the same steps might work in Chrome or Firefox.
Can’t wait for someone to replace an emulator of iSH with this and publish the result to the App Store. I suppose it should be much faster than iSH.
Heavy kernel in a browser, and we've just buried electron because it was a heavy kernel in a browser.
Finally we can have native software again ;)
That was supposed to be comedy, but they did it in real
https://slopshare.dev https://slopshare.dev/v0.1.8/agents/
shameless plug for my slop project going down a different route
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 on HN 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 ][ emulator 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 think the most interesting point this illustrates is that Korz is a great way to write Just In Time compiling emulators that run extremely efficiently in the browser, in way that can achieve much higher performance than WASM. And Korz is generally useful for a lot more than just emulators.
Korz dispatch for emulators, in TypeScript:
https://github.com/SimHacker/WillWrightShowForFood/blob/main...
What Korz is:
https://github.com/SimHacker/moollm/blob/main/designs/korz/R...
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
When I tried it a while back, Go was not very good for writing fast interpreters, even when compiled natively rather than to WebAssembly. Interpreter inner loops are a niche use case that they apparently haven’t tried to optimize, and interface values are rather inefficient union types. If I were going to write a fast interpreter using WebAssembly, I would use a different language.
It’s experimental, but it might be fun to try Zena to see what WebAssembly can do: https://zena-lang.dev/
Thank you for sharing this! Could you please add a user 'guest' pwd 'guest' login, I don't like to log in as other people for various reasons.
Also, please be aware that AI-written or AI-edited comments aren't allowed on HN at all, this sentence sounded a little like AI to me: "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."
I understand that AI can write very good technical prose but it isn't allowed here at all, you are only allowed to summarize it in your own words. Thank you.
how you managed to get this done ?
Good to try
Nice commit titles in the last couple days
LGTM
Nice