Repository navigation
feat(playground): run the VM on unkernel instead of arm64js - #182
Open
raphaelvigee wants to merge 3 commits into
Open
raphaelvigee wants to merge 3 commits into
raphaelvigee wants to merge 3 commits into
Conversation
unkernel runs a real Linux kernel compiled to WebAssembly, with only aarch64 user space emulated. On the playground's own setup and examples it is about 6x faster end to end than arm64js (14 s vs 91 s for the same recipe in headless Chromium), and 6-8x faster per heph build. - vm.ts: boot unkernel's Alpine image, drive setup with exec(), copy files in through 9p mounts, mount plugins read-only. - terminal.ts: xterm <-> pty bridge (arm64js shipped its own); a shell that exits is replaced. - plugins/playground-vm: at build time, copy the Alpine image out of the unkernel release and write a static subset of the Alpine mirror (the closure of the packages the VM installs, with the signed indexes) to static/playground/. The guest's apk reaches it through fetchRoutes, so the VM never touches the internet and needs no proxy changes. - Drop the snapshot logic: setup now finishes while heph downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
⚡ Cloudflare Pages preview
|
…size Cloudflare Pages previews ignore Range requests, and unkernel reads a distro URL lazily with them, so the VM failed to boot there. The image is 4 MB: fetch it once and hand unkernel an in-memory disk. The idle text said the first start downloads "about 200 MB"; the latest release alone is 290 MiB. Compute it from the selected release's asset sizes plus the VM's own ~27 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…targets The VM can now reach the internet: TCP goes over wss://anura.pro/, one of the public Wisp servers unkernel's docs list (unkernel's own only admits its own origins). Setup still installs from this site's mirror, under a host name only the page answers, so a slow or unreachable proxy can't break a start; afterwards apk points at the real mirror, so `apk add go` works. Only one server: unkernel races a list on handshake time, and wisp.mercurywork.shop handshakes faster but moved `apk add go` in 3m49 against 17s. `?wisp=<url>` overrides it, `?wisp=off` cuts the VM off. Every example target now starts with `sleep 1`, so builds last long enough to watch heph's live dashboard; the welcome text says why. Also: the deploy step's hint now says Enter opens the review before `y`, and the intro no longer claims nothing leaves the machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the playground's VM (
arm64js) with unkernel. unkernel runs a real Linux kernel compiled to WebAssembly and emulates only aarch64 user space. The playground gets much faster.Benchmark
Same recipe on both VMs: cold boot, the playground's package setup, the heph install and the example builds. Headless Chromium, 1 vCPU, no snapshots, same heph release.
apk add)hello: cold / cachedc-app: cold / cached / one changeOn the real page the VM boots and finishes setup while heph downloads. It is ready about 2 s after the last byte arrives.
What changed
vm.tsboots unkernel's Alpine image and drives setup withexec(). Files are copied in through 9p mounts, and plugins are mounted read-only.terminal.ts(new) bridges xterm and a pty; arm64js shipped its own. When the shell exits, a new one starts.plugins/playground-vm(new) runs at build time and writes tostatic/playground/(gitignored):alpine.erofs(4 MB): the root file system, taken from the unkernel release and checked against its SHA-256 index.apk/(~12 MB): a static subset of the Alpine mirror. It holds the signedAPKINDEXofmainandcommunityplus the dependency closure of the playground's packages (28 packages, 8.3 MiB). The guest'sapkreaches it throughfetchRoutes, under a host name only the page answers, and still verifies signatures and checksums. Setup never depends on the internet, and the proxy worker is unchanged.wss://anura.pro/, one of the servers unkernel's docs list; unkernel's own server rejects our origins. After setup, apk points at the real Alpine mirror, soapk add goworks (16–17 s, 4 of 5 tries succeeded; one failed mid-download). Only one server: unkernel races a list on handshake time, andwisp.mercurywork.shopwins that race but took 3m49 against 17 s for the same install.?wisp=<url>overrides the server,?wisp=offcuts the VM off.sleep 1, so heph's live dashboard has time to show. The welcome text and the examples panel say why. The c-app and monorepo steps still pass--no-tuion purpose, so they print plain logs.arm64jsand@arm64js/protocolout,unkernelin. Bindings for darwin-arm64 and linux-x64-gnu are both still present.Testing
lintandbuildare clean.docusaurus serve) in Chromium:expecttext says, with the sleeps in place. Intended failures fail,--shellworks on the pty, and deploy works both through the approval review (Enter, theny) and with--auto-approve.https://example.comand installsgoover Wisp.exit.Worth a look before merging
0.2.0-261127-3b71fa5exactly (published 2026-11-27); that is the version benchmarked here.dl-cdn.alpinelinux.organd from unkernel's GitHub release. Both are cached inwebsite/.playground-cache/.ALPINE_BRANCH(v3.24) inpackages.tsmust match the unkernel image's Alpine release. A mismatch fails loudly atapk add.🤖 Generated with Claude Code