mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-02 13:59:43 +08:00
web: make the launcher demos right for the aarch64 guest
The demos' texts called the guest riscv64 (and its CPU a RISC-V emulator); they now say aarch64. The SQLite demo read the riscv ISA string from /proc/cpuinfo; it now loads the Features line and groups it (FP and SIMD, crypto, CRC, LSE atomics). Doom's first run builds in under a minute, which its README and tile say. Every visible demo's run.sh was run on the aarch64 guest through the SDK (2026-11-18): .agents/web.md lists the first-run times. The stand-ins and qemu-user (x86_64, riscv64, i386, arm) were rechecked too.
This commit is contained in:
@@ -592,14 +592,14 @@ for aarch64 (11.0.3); the demo has not been run on the aarch64 guest.
|
||||
sums the PCM chunks 300 ms after glimmer's "test sound done" and then
|
||||
misses the last one (65966 or 65919 of 66150 frames), while
|
||||
`test/glimmer-check.mjs --run` gets all 66150, sample exact (3 of 3).
|
||||
- **aarch64 image: not yet rerun.** The Ubuntu arm64 disk, x86_64, i386
|
||||
and arm binaries through qemu-user (riscv64 works: a static riscv64
|
||||
program installed qemu-riscv64 and its library root on first run, 60 s,
|
||||
and then ran in 0.4 s, 2026-11-17), and the page. The page's fx,
|
||||
claude and opencode stand-ins (web.md, Stand-ins) are checked through
|
||||
the SDK only; in a browser, writing claude's 357 MB and opencode's
|
||||
248 MB to the IndexedDB data disk has not been timed. The ubuntu and
|
||||
sqlite demos are still written for riscv64.
|
||||
- **aarch64 page: not yet opened in a browser.** The launcher demos (web.md,
|
||||
Launcher), the stand-ins (web.md, Stand-ins) and qemu-user are checked
|
||||
through the Node SDK only (2026-11-18): static busybox binaries of
|
||||
x86_64, riscv64, i386 and armv7 each installed their qemu and library
|
||||
root on first run in 8-9 s and then ran in 0.2-0.3 s. In a browser,
|
||||
writing claude's 357 MB and opencode's 248 MB to the IndexedDB data disk
|
||||
has not been timed, and every demo's first run there waits on Wisp
|
||||
instead of the host's network.
|
||||
- **GNU ld binaries exec slower.** Alpine links everything with GNU ld,
|
||||
whose one R+X segment for code and read-only data cost about 0.5 ms per
|
||||
exec under riscv64 kwemu against lld's layout; on aarch64 about 0.07
|
||||
|
||||
@@ -536,7 +536,9 @@ both files describe the rest at their top:
|
||||
4.5 MB download, 6.9 MB, first call 2.5 s, later ones 0.01 s; claude
|
||||
2.1.327 127 MB (`.zst`), 357 MB, 23 s, then `--version` 0.2 s, `--help`
|
||||
6 s; opencode 2.3.2 120 MB, 248 MB, 22 s, then `--version` 6 s (its own
|
||||
startup). All three also run at 256 MiB. Without a data disk the root is
|
||||
startup); rechecked the same day on a fresh data disk (fx 0.0.17, claude
|
||||
2.1.327, opencode 2.3.2): first calls 2.2, 16.9 and 20.9 s, then 0.0,
|
||||
0.1 and 4.3 s. All three also run at 256 MiB. Without a data disk the root is
|
||||
in RAM (230 MiB free at 512 MiB): fx installs, claude and opencode refuse
|
||||
with a message; at 1 GiB claude fits.
|
||||
- claude's own auto-updater is left on: it may download a newer version
|
||||
@@ -615,6 +617,28 @@ window (or its shell exiting) removes `?demo=`; the kernel stopping does
|
||||
not.
|
||||
Failures are toasts. Checked by hand only.
|
||||
|
||||
Every demo's run.sh, as the launcher writes it, was run on the aarch64
|
||||
guest through the Node SDK on 2026-11-18: a fresh data disk per demo, 512
|
||||
MiB, the files written with `vm.exec()` and run.sh in a pty session (the
|
||||
window's command without the wrapper), the host's network instead of Wisp,
|
||||
a display or sound card where the demo needs one, and the Ubuntu tarball
|
||||
pushed as `downloads` does (a scratch harness, not in the repository).
|
||||
Each reached its working state: the
|
||||
servers answered over `vm.fetch()` (nitro's echo POST, python's note
|
||||
POST), postgres's `select version()` said aarch64, glimmer and Doom drew
|
||||
frames, radio and speak played sound, sshfs mounted Rebex's server.
|
||||
Seconds from run.sh's start, the `apk add` step (indexes and packages
|
||||
over the host's network) first, then the time to the working state:
|
||||
htop 1.6/1.7, tmux 1.8/2.6, mc 2.6/3.0, Neovim 6.8/7.7 (community), Git
|
||||
2.8/4.9 (clone 1.6 s), sshfs 2.9/4.6 (mounted, tour done), nginx
|
||||
1.8/2.1, Node.js 5.3/10.5, Nitro 5.9/39.4 (upm install 16 s, `nitro dev`
|
||||
14 s), Python 4.3/6.2, PostgreSQL 5.7/19.6 (initdb and start 13 s),
|
||||
SQLite 1.7/2.9, Valkey 2.1/3.3, radio 1.7 (sound about 1 s after a
|
||||
station is picked), speak 2.4 (the introduction starts at once),
|
||||
asciiquarium 6.7/6.8 (community), glimmer 0.1 (no packages), Ubuntu 28
|
||||
(extracting the pushed tarball; 0.2 later, `apt-get update` 28 s in the
|
||||
chroot), Doom 22 (tcc install, downloads and a 6 s build; 0.2 later).
|
||||
|
||||
`?showcase` (or `?demo=-`) runs `src/showcase.ts` once the guest is up: a
|
||||
fast, hands-off tour of the demos, leaving out the web servers (described at its top).
|
||||
Each step shows a caption and launches its demo without touching `?demo=`.
|
||||
|
||||
@@ -827,8 +827,9 @@ from source). Everything is self-hosted except the Wisp fallback.
|
||||
`?simulate=nojspi|oom|lowmem` (documented in `web/src/config.ts`).
|
||||
* **Launcher:** ❯ at the left of the status line (or ⌘K on Apple devices,
|
||||
Ctrl-Shift-O, Ctrl-A o) opens a full-page grid of demos: glimmer, tmux,
|
||||
htop, Midnight Commander, Neovim, sshfs over FUSE, nginx, Node.js, Python,
|
||||
PostgreSQL, SQLite, Valkey, internet radio, asciiquarium and Doom. Each
|
||||
htop, Midnight Commander, Neovim, Git, Ubuntu in a chroot, sshfs over
|
||||
FUSE, nginx, Node.js, Nitro, Python, PostgreSQL, SQLite, Valkey, internet
|
||||
radio, speech, asciiquarium and Doom. Each
|
||||
runs in a new terminal window: the page writes its files into the guest,
|
||||
installs its Alpine packages with apk and runs its commands
|
||||
(`web/src/demos/`, one file each); web servers open in the preview. The
|
||||
|
||||
@@ -19,7 +19,7 @@ export default {
|
||||
colors: ["#38bdf8", "#1e3a8a"],
|
||||
community: true,
|
||||
files: {
|
||||
"README": "asciiquarium: an aquarium animation in perl (Term::Animation), the riscv64\n" +
|
||||
"README": "asciiquarium: an aquarium animation in perl (Term::Animation), the aarch64\n" +
|
||||
"build from Alpine, running on Linux in this browser tab.\n\n" +
|
||||
" q quits p pauses r redraws (new fish, and the window's new size)\n\n" +
|
||||
"Ctrl-C quits too.\n",
|
||||
|
||||
@@ -25,7 +25,7 @@ keyboard input through evdev and sound effects on /dev/dsp.
|
||||
|
||||
The first run builds the game here, in the guest: it installs tcc with apk
|
||||
(about 8 MiB), downloads fbDOOM's source and Freedoom (about 24 MiB) and
|
||||
compiles 81 files, which takes from half a minute to a few minutes. Later
|
||||
compiles 81 files, which takes under a minute, mostly the downloads. Later
|
||||
runs start at once. With the data disk the game is kept in /data/fbdoom.
|
||||
|
||||
arrows move Ctrl fire Space open doors
|
||||
@@ -41,7 +41,7 @@ fbdoom --remove-compiler removes tcc.
|
||||
export default {
|
||||
id: "doom",
|
||||
title: "Doom",
|
||||
desc: "fbDOOM with Freedoom on the framebuffer; the first run builds it in the guest (a few minutes)",
|
||||
desc: "fbDOOM with Freedoom on the framebuffer; the first run builds it in the guest (under a minute)",
|
||||
// A horned skull (not id Software's logo).
|
||||
icon: { svg: '<path fill-rule="evenodd" d="M12 3.5c5 0 8.5 3.4 8.5 7.9 0 2.5-1 4.3-2.8 5.4v1.7H6.3v-1.7c-1.8-1.1-2.8-2.9-2.8-5.4C3.5 6.9 7 3.5 12 3.5ZM5.6 10.4l5 1.4-.4 2.2c-.2 1.1-1.2 1.9-2.4 1.9-1.4 0-2.4-1.1-2.4-2.5Zm12.8 0-5 1.4.4 2.2c.2 1.1 1.2 1.9 2.4 1.9 1.4 0 2.4-1.1 2.4-2.5ZM12 14.8l-1.3 2.3h2.6Z"/><path d="M6.6 19.2h3v3H7.6a1 1 0 0 1-1-1Zm3.9 0h3v3h-3Zm3.9 0h3v2a1 1 0 0 1-1 1h-2ZM5.4 6.6C3.6 5.2 3 3.3 3.4 1.2 4.6 2.9 6 3.8 7.8 4.3Zm13.2 0c1.8-1.4 2.4-3.3 2-5.4-1.2 1.7-2.6 2.6-4.4 3.1Z"/>' },
|
||||
colors: ["#dc2626", "#451a03"],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// DOS: FreeDOS 1.2 booting on a PC emulated by qemu-system-i386, a riscv64
|
||||
// DOS: FreeDOS 1.2 booting on a PC emulated by qemu-system-i386, an aarch64
|
||||
// program on the guest, drawn in the terminal by qemu's curses display
|
||||
// (VGA text mode; a program that switches to graphics shows nothing).
|
||||
// qemu-system-i386 and qemu-ui-curses are in community: about 25 MB to
|
||||
@@ -16,7 +16,7 @@
|
||||
// costs seconds under two layers of emulation: as shipped, qemu took 6.5 s
|
||||
// to reach the FreeDOS kernel, 19 s more to the shell (the F5/F8 wait,
|
||||
// HIMEMX) and 45 s more for AUTOEXEC.BAT (CD-ROM drivers, LBACACHE, the
|
||||
// welcome text) (CLI, 2026-11-15). Only FDAPM APMDOS stays: it halts the
|
||||
// welcome text) (riscv64 guest, CLI, 2026-11-15). Only FDAPM APMDOS stays: it halts the
|
||||
// CPU while DOS waits for a key, so an idle prompt does not keep qemu, and
|
||||
// the tab, at full speed. qemu runs with -nodefaults (no CD-ROM for the
|
||||
// BIOS to probe, no parallel port) and 4 MB of memory. The
|
||||
@@ -44,7 +44,7 @@
|
||||
import type { Demo } from "../launcher.ts";
|
||||
|
||||
const DOS = String.raw`#!/bin/sh
|
||||
# FreeDOS on an emulated PC: qemu-system-i386 (a riscv64 program) boots the
|
||||
# FreeDOS on an emulated PC: qemu-system-i386 (an aarch64 program) boots the
|
||||
# FreeDOS 1.2 boot floppy, with its installer removed, to an A:\> prompt.
|
||||
set -e
|
||||
IMG=fdos12.img
|
||||
@@ -81,7 +81,7 @@ FDAPM APMDOS >NUL
|
||||
alias halt=fdapm poweroff
|
||||
alias shutdown=fdapm poweroff
|
||||
cls
|
||||
echo FreeDOS 1.2, on a PC emulated by qemu-system-i386, a riscv64 program,
|
||||
echo FreeDOS 1.2, on a PC emulated by qemu-system-i386, an aarch64 program,
|
||||
echo on Linux compiled to WebAssembly, running in your browser.
|
||||
echo.
|
||||
echo Try DIR /W, VER, MEM, or EDIT NOTES.TXT (A: is writable and kept).
|
||||
@@ -147,7 +147,7 @@ export default {
|
||||
// Hidden: too slow for the launcher, even stripped (status.md).
|
||||
hidden: true,
|
||||
title: "FreeDOS",
|
||||
desc: "FreeDOS 1.2 booting on a PC emulated by qemu-system-i386, inside the riscv64 Linux in your browser",
|
||||
desc: "FreeDOS 1.2 booting on a PC emulated by qemu-system-i386, inside the aarch64 Linux in your browser",
|
||||
// A floppy disk.
|
||||
icon: { svg: '<path fill-rule="evenodd" d="M4 2h13l5 5v13a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2Zm3 1.5v5.5h9V3.5Zm5.5 1h2v3.5h-2ZM5.5 13v7.5h13V13Z"/><path opacity=".55" d="M7.5 15h9v1.2h-9Zm0 2.5h6.5v1.2H7.5Z"/>' },
|
||||
colors: ["#2563eb", "#0b1d4d"],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// replacement, cloned with git, toured, then browsed with tig. Its whole
|
||||
// history, 163 commits since 2010, is about 224 KB packed (2026-11-15), so
|
||||
// the clone takes a moment even over the page's Wisp connection. git and
|
||||
// tig are Alpine's riscv64 packages from main (about 6.6 MB to download
|
||||
// tig are Alpine's aarch64 packages from main (about 6.6 MB to download
|
||||
// with their libraries); git talks HTTPS to GitHub with its own libcurl,
|
||||
// not the image's curl shim.
|
||||
//
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// archive VFS: Enter on it browses it like a directory.
|
||||
import type { Demo } from "../launcher.ts";
|
||||
|
||||
const README = `Midnight Commander in unkernel: the riscv64 build of mc from Alpine,
|
||||
const README = `Midnight Commander in unkernel: the aarch64 build of mc from Alpine,
|
||||
running on Linux, compiled to WebAssembly, in this browser tab.
|
||||
|
||||
The left panel is this directory, the right one is /proc: the kernel's
|
||||
@@ -63,8 +63,8 @@ const UNKERNEL = `unkernel, layer by layer
|
||||
|
||||
your browser runs one WebAssembly module
|
||||
the kernel Linux, built for arch/wasm with an MMU
|
||||
user space unmodified riscv64 Alpine Linux binaries
|
||||
kwemu the RISC-V emulator inside the kernel, with a JIT
|
||||
user space unmodified aarch64 Alpine Linux binaries
|
||||
kwemu the aarch64 CPU inside the kernel, with a JIT
|
||||
that turns hot guest code into WebAssembly
|
||||
|
||||
mc, the shell and everything in /proc come from that stack. Nothing
|
||||
|
||||
@@ -43,7 +43,7 @@ const PAGE = `<!doctype html>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Hello from nginx</h1>
|
||||
<p>This page is served by nginx, running on Linux in this browser tab. The kernel is WebAssembly, nginx is the riscv64 binary from Alpine, and this request went from the page to the guest over vsock.</p>
|
||||
<p>This page is served by nginx, running on Linux in this browser tab. The kernel is WebAssembly, nginx is the aarch64 binary from Alpine, and this request went from the page to the guest over vsock.</p>
|
||||
<dl>
|
||||
<dt>nginx</dt><dd><!--# echo var="nginx_version" --></dd>
|
||||
<dt>Guest time</dt><dd><!--# echo var="date_local" --></dd>
|
||||
|
||||
@@ -86,7 +86,7 @@ export default defineHandler(() => {
|
||||
const RUNTIME = `import os from "node:os";
|
||||
import { defineHandler } from "nitro";
|
||||
|
||||
// The guest's own numbers: Node on riscv64 Linux, compiled to WebAssembly.
|
||||
// The guest's own numbers: Node on aarch64 Linux, compiled to WebAssembly.
|
||||
export default defineHandler(() => {
|
||||
return {
|
||||
node: process.version,
|
||||
@@ -207,7 +207,7 @@ const PAGE = `<!doctype html>
|
||||
</nav>
|
||||
<main>
|
||||
<h1>Nitro, running in your browser.</h1>
|
||||
<p class="lead">A standalone Nitro v3 server. <code>nitro dev</code> runs the ES modules in <code>server/</code> with no build step, on Alpine's riscv64 Node, on a Linux kernel compiled to WebAssembly.</p>
|
||||
<p class="lead">A standalone Nitro v3 server. <code>nitro dev</code> runs the ES modules in <code>server/</code> with no build step, on Alpine's aarch64 Node, on a Linux kernel compiled to WebAssembly.</p>
|
||||
<div class="mono" id="who">connecting...</div>
|
||||
|
||||
<div class="card stats">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// Node.js: Alpine's riscv64 nodejs (main, about 25 MB) serving a live
|
||||
// Node.js: Alpine's aarch64 nodejs (main, about 25 MB) serving a live
|
||||
// dashboard on port 3000 with node:http alone, so no npm install.
|
||||
//
|
||||
// The page polls api/stats every 2 s with fetch: the preview relays plain
|
||||
@@ -54,7 +54,7 @@ function stats() {
|
||||
release: os.release(),
|
||||
hostname: os.hostname(),
|
||||
cpus: cpus.length,
|
||||
cpuModel: cpus[0] && cpus[0].model !== "unknown" ? cpus[0].model : "", // unknown on riscv64
|
||||
cpuModel: cpus[0] && cpus[0].model !== "unknown" ? cpus[0].model : "", // unknown where /proc/cpuinfo names no model (as here)
|
||||
loadavg: os.loadavg(),
|
||||
totalmem: os.totalmem(),
|
||||
freemem: os.freemem(),
|
||||
@@ -75,7 +75,7 @@ function stats() {
|
||||
|
||||
function bench() {
|
||||
// SHA-256 through OpenSSL for 300 ms, then a sieve in plain JavaScript,
|
||||
// which V8 compiles to riscv64 code.
|
||||
// which V8 compiles to arm64 code.
|
||||
const buf = crypto.randomBytes(64 * 1024);
|
||||
let bytes = 0;
|
||||
const t0 = performance.now();
|
||||
@@ -189,7 +189,7 @@ const PAGE = `<!doctype html>
|
||||
</div>
|
||||
<span class="live" id="live"><i></i><span id="livetext">waiting</span></span>
|
||||
</header>
|
||||
<p>This page comes from <code>node:http</code> in <code>server.mjs</code>. Node is Alpine's riscv64 build, unmodified, on a Linux kernel compiled to WebAssembly, in your browser. Every number below is the guest's own, polled every 2 seconds.</p>
|
||||
<p>This page comes from <code>node:http</code> in <code>server.mjs</code>. Node is Alpine's aarch64 build, unmodified, on a Linux kernel compiled to WebAssembly, in your browser. Every number below is the guest's own, polled every 2 seconds.</p>
|
||||
|
||||
<div class="hero">
|
||||
<div><span>process.version</span><b id="h-version">-</b></div>
|
||||
@@ -248,7 +248,7 @@ const PAGE = `<!doctype html>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Benchmark</h2>
|
||||
<p style="margin-top:0">SHA-256 through Node's OpenSSL for 300 ms, then a sieve of Eratosthenes in plain JavaScript, which V8 compiles to riscv64 code for the emulator to run.</p>
|
||||
<p style="margin-top:0">SHA-256 through Node's OpenSSL for 300 ms, then a sieve of Eratosthenes in plain JavaScript, which V8 compiles to arm64 code for the emulated CPU to run.</p>
|
||||
<button id="bench">Run</button>
|
||||
<dl style="margin-top:.75rem">
|
||||
<dt>sha256</dt><dd id="sha">-</dd>
|
||||
|
||||
@@ -315,7 +315,7 @@ vim.keymap.set("n", "<Esc>", "<Cmd>nohlsearch<CR>")
|
||||
|
||||
const README = `# Neovim on unkernel
|
||||
|
||||
Neovim 0.12, the riscv64 build from Alpine, on Linux compiled to
|
||||
Neovim 0.12, the aarch64 build from Alpine, on Linux compiled to
|
||||
WebAssembly, in this browser tab. The setup is one file with no plugins:
|
||||
config/nvim/init.lua (Space s opens it).
|
||||
|
||||
@@ -333,7 +333,7 @@ Open hello.c or the config: the highlighting is tree-sitter's.
|
||||
const HELLO = `#include <stdio.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
/* Compiled for riscv64, run by the kernel in this tab. */
|
||||
/* Compiled for aarch64, run by the kernel in this tab. */
|
||||
int main(void)
|
||||
{
|
||||
struct utsname u;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// PostgreSQL: Alpine's riscv64 postgresql18 (main, about 13 MB to download
|
||||
// PostgreSQL: Alpine's aarch64 postgresql18 (main, about 13 MB to download
|
||||
// with what it pulls in), a real server in the tab: a small seeded database,
|
||||
// a few showcase queries, then an interactive psql. No ports: there is no
|
||||
// HTTP UI, psql is the interface.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// Python: Alpine's riscv64 python3 (main, 3.14, about 8.5 MB to download, a
|
||||
// Python: Alpine's aarch64 python3 (main, 3.14, about 8.5 MB to download, a
|
||||
// little more with the libraries it pulls in) serving a notes wall on port
|
||||
// 8000 from the standard library alone: http.server, sqlite3 and html, so no
|
||||
// pip and no virtualenv.
|
||||
@@ -61,7 +61,7 @@ else:
|
||||
MAX_NAME, MAX_MESSAGE, MAX_BODY, SHOWN = 40, 280, 16384, 100
|
||||
SEED = [
|
||||
("unkernel", "Welcome! This wall is a Python program: http.server and sqlite3 "
|
||||
"from the standard library, on riscv64 Linux, in your browser tab."),
|
||||
"from the standard library, on aarch64 Linux, in your browser tab."),
|
||||
("app.py", "Leave a note below. It goes into SQLite, and the page you get back "
|
||||
"after the redirect lists it here, newest first."),
|
||||
]
|
||||
@@ -309,7 +309,7 @@ PAGE = string.Template("""<!doctype html>
|
||||
</div>
|
||||
<span class="pill">$count</span>
|
||||
</div>
|
||||
<p>This page comes from <code>app.py</code>: <code>http.server</code>, <code>sqlite3</code> and <code>html</code> from the standard library, no pip. Python is Alpine's riscv64 build, unmodified, on a Linux kernel compiled to WebAssembly, in your browser. Notes are stored in SQLite; times are the guest's clock.</p>
|
||||
<p>This page comes from <code>app.py</code>: <code>http.server</code>, <code>sqlite3</code> and <code>html</code> from the standard library, no pip. Python is Alpine's aarch64 build, unmodified, on a Linux kernel compiled to WebAssembly, in your browser. Notes are stored in SQLite; times are the guest's clock.</p>
|
||||
|
||||
<form method="post" action="./">
|
||||
<textarea name="message" maxlength="$max_message" placeholder="Leave a note..." required></textarea>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// Radio: SomaFM's listener-supported internet radio played by mpg123 on the
|
||||
// guest's sound card. Alpine's riscv64 mpg123 from main pulls in
|
||||
// guest's sound card. Alpine's aarch64 mpg123 from main pulls in
|
||||
// mpg123-libs and alsa-lib (about 0.8 MB to download). It has the ALSA and
|
||||
// OSS output modules built in (no separate subpackage), and both play on
|
||||
// kwsnd; radio.sh uses ALSA, the card's own interface (OSS is the kernel's
|
||||
@@ -10,8 +10,10 @@
|
||||
// SomaFM's MP3 streams are 128 kbit/s, 44.1 kHz stereo; everything lower is
|
||||
// AAC, which mpg123 does not decode. That is cheap enough as it is: under
|
||||
// the JIT, mpg123 takes about 5% of the guest's CPU and the whole emulator
|
||||
// about 6% of a host core (CLI over Wisp, 2026-11-15), so there is no --mono or -2
|
||||
// downsampling, and no underruns over Wisp in the runs measured. Each
|
||||
// about 6% of a host core (riscv64 guest, CLI over Wisp, 2026-11-15), so there
|
||||
// is no --mono or -2 downsampling; on the aarch64 guest Groove Salad
|
||||
// started about 1 s after it was picked and played with no underrun (CLI,
|
||||
// 2026-11-18). Each
|
||||
// station is SomaFM's plain-http playlist (somafm.com/nossl/<id>.pls), the
|
||||
// link SomaFM asks players to use since it does not change. radio.sh fetches
|
||||
// it with wget, since mpg123 -@ exits 0 when the playlist cannot be had, and
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// Speak: the guest talks through its sound card. eSpeak 1.48 (Alpine's
|
||||
// riscv64 espeak from main) is a formant synthesizer: no recorded voices,
|
||||
// aarch64 espeak from main) is a formant synthesizer: no recorded voices,
|
||||
// about 70 languages in its 1.2 MB package. With portaudio, alsa-lib and
|
||||
// the JACK client library it pulls in, the download is about 4.9 MB, all
|
||||
// from main, so community stays off.
|
||||
@@ -20,7 +20,8 @@
|
||||
// they go to /tmp/speak.log, shown only when espeak fails, and
|
||||
// JACK_NO_START_SERVER keeps the JACK client from trying to start one. That
|
||||
// probing is most of espeak's start-up: a sentence plays about 0.45 s
|
||||
// after espeak starts (CLI, 2026-11-15). Text goes in on stdin, so a line
|
||||
// after espeak starts (riscv64 guest, CLI, 2026-11-15; on aarch64 a
|
||||
// one-word espeak call, playback included, takes about 1.0 s, 2026-11-18). Text goes in on stdin, so a line
|
||||
// that starts with a dash is not taken as an option.
|
||||
//
|
||||
// The INT trap (a handler, reset in children) makes Ctrl-C cut espeak off
|
||||
@@ -29,7 +30,7 @@
|
||||
import type { Demo } from "../launcher.ts";
|
||||
|
||||
const SPEAK = String.raw`#!/bin/sh
|
||||
# The machine speaks: eSpeak, a speech synthesizer, running on riscv64 Linux
|
||||
# The machine speaks: eSpeak, a speech synthesizer, running on aarch64 Linux
|
||||
# in the browser and playing through the guest's sound card.
|
||||
export JACK_NO_START_SERVER=1
|
||||
LOG=/tmp/speak.log
|
||||
@@ -65,8 +66,8 @@ intro() {
|
||||
procs=$(ls -d /proc/[0-9]* | wc -l)
|
||||
|
||||
say "Hello! I am Linux $kver, running in your browser."
|
||||
whisper "(psst: on an emulated RISC-V processor, inside WebAssembly)" \
|
||||
"psst. on an emulated risk five processor, inside WebAssembly."
|
||||
whisper "(psst: on an emulated Arm processor, inside WebAssembly)" \
|
||||
"psst. on an emulated arm processor, inside WebAssembly."
|
||||
say "I have been up for $up, with $procs processes running."
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// SQLite: Alpine's riscv64 sqlite (the sqlite3 shell, main, about 1.4 MB to
|
||||
// SQLite: Alpine's aarch64 sqlite (the sqlite3 shell, main, about 1.4 MB to
|
||||
// download with readline and ncurses), querying the running guest itself:
|
||||
// SQL over the live Linux in the browser, where the postgres demo has a seeded
|
||||
// dataset. No server and no ports: sqlite3 is the interface.
|
||||
@@ -9,7 +9,7 @@
|
||||
// installed packages from apk's database (/lib/apk/db/installed: P:, V:, T:,
|
||||
// L:, o:, I:, D:, p:, i: and R: lines, records separated by blank lines;
|
||||
// /etc/apk/world), the processes (/proc/<pid>/status and cmdline), the mounts
|
||||
// (/proc/mounts) and a few facts (uname, /proc/cpuinfo's ISA string,
|
||||
// (/proc/mounts) and a few facts (uname, /proc/cpuinfo's feature list,
|
||||
// /proc/meminfo). busybox awk turns each into INSERT statements, quoting with
|
||||
// a q variable since the programs sit in single quotes. The snapshot tables
|
||||
// are dropped and made again, so a rerun sees packages installed meanwhile;
|
||||
@@ -18,7 +18,7 @@
|
||||
// reboots), with a system.db symlink to it in the demo's directory, else
|
||||
// system.db there itself.
|
||||
//
|
||||
// Dependencies are kept as written (so:libc.musl-riscv64.so.1, cmd:sh,
|
||||
// Dependencies are kept as written (so:libc.musl-aarch64.so.1, cmd:sh,
|
||||
// /bin/sh), and the needs view resolves them through provides (each package's
|
||||
// own name plus its p: names) to package-to-package edges. tree.sql walks
|
||||
// them down from a package; apk-del.sql works out what apk del would remove:
|
||||
@@ -139,7 +139,7 @@ facts() {
|
||||
printf 'kernel\t%s\n' "$(uname -sr)"
|
||||
printf 'machine\t%s\n' "$(uname -m)"
|
||||
awk -F': *' '{ k = $1; sub(/[ \t]+$/, "", k) }
|
||||
(k == "isa" || k == "mmu") && !(k in seen) { seen[k] = 1; print toupper(k) "\t" $2 }' /proc/cpuinfo
|
||||
k == "Features" && !(k in seen) { seen[k] = 1; print "features\t" $2 }' /proc/cpuinfo
|
||||
awk '/^MemTotal:/ { print "memory\t" int($2 / 1024) " MiB" }' /proc/meminfo
|
||||
awk '{ printf "uptime\t%d min %d s\n", $1 / 60, $1 % 60 }' /proc/uptime
|
||||
printf 'database\t%s\n' "$db"
|
||||
@@ -292,23 +292,20 @@ const SHOWCASE = String.raw`-- Queries over the snapshot snapshot.sh just took,
|
||||
|
||||
.print
|
||||
.print '── This system: the system table'
|
||||
SELECT fact, value FROM system WHERE fact <> 'ISA' ORDER BY rowid;
|
||||
SELECT fact, value FROM system WHERE fact <> 'features' ORDER BY rowid;
|
||||
|
||||
.print
|
||||
.print "── The CPU's ISA string from /proc/cpuinfo, split into extensions by a recursive CTE"
|
||||
.print "── The CPU's features from /proc/cpuinfo, split into a list by a recursive CTE"
|
||||
WITH RECURSIVE split(i, ext, rest) AS (
|
||||
SELECT 0, NULL, (SELECT value FROM system WHERE fact = 'ISA') || '_'
|
||||
SELECT 0, NULL, (SELECT value FROM system WHERE fact = 'features') || ' '
|
||||
UNION ALL
|
||||
SELECT i + 1, substr(rest, 1, instr(rest, '_') - 1), substr(rest, instr(rest, '_') + 1) FROM split WHERE rest <> ''
|
||||
SELECT i + 1, substr(rest, 1, instr(rest, ' ') - 1), substr(rest, instr(rest, ' ') + 1) FROM split WHERE rest <> ''
|
||||
)
|
||||
SELECT CASE
|
||||
WHEN ext GLOB 'rv*' THEN 'base and single letters'
|
||||
WHEN ext GLOB 'zi*' THEN 'CSRs, counters, cache ops, hints'
|
||||
WHEN ext GLOB 'zb*' THEN 'bit manipulation'
|
||||
WHEN ext GLOB 'zk*' THEN 'scalar crypto'
|
||||
WHEN ext GLOB 'za*' THEN 'atomics'
|
||||
WHEN ext GLOB 'z[fd]*' THEN 'floating point'
|
||||
WHEN ext GLOB 'zc*' THEN 'compressed'
|
||||
WHEN ext IN ('fp', 'asimd') THEN 'floating point and SIMD'
|
||||
WHEN ext IN ('aes', 'pmull', 'sha1', 'sha2', 'sha3', 'sha512') THEN 'crypto'
|
||||
WHEN ext = 'crc32' THEN 'checksums'
|
||||
WHEN ext = 'atomics' THEN 'atomics (LSE)'
|
||||
ELSE 'other'
|
||||
END AS kind,
|
||||
count(*) AS n, group_concat(ext, ' ' ORDER BY i) AS extensions
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// openssh-client and glib) and tree, about 4.3 MB to download, and mc
|
||||
// (about 1.7 MB more, since it shares glib) to browse the mount after.
|
||||
// httpdirfs, the other idea (an HTTP directory listing as a file system),
|
||||
// has no riscv64 build in Alpine v3.24, and rclone's http backend is a
|
||||
// is not in Alpine v3.24, and rclone's http backend is a
|
||||
// 37 MB download.
|
||||
//
|
||||
// The guest's TCP goes through the page's Wisp server, which lets port 22
|
||||
|
||||
@@ -52,7 +52,7 @@ while :; do
|
||||
done
|
||||
`;
|
||||
|
||||
const README = `tmux in unkernel: a terminal multiplexer, the riscv64 build from Alpine,
|
||||
const README = `tmux in unkernel: a terminal multiplexer, the aarch64 build from Alpine,
|
||||
running on Linux in this browser tab.
|
||||
|
||||
Ctrl-B % split left and right Ctrl-B " split top and bottom
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
// Valkey: the BSD-licensed, Redis-compatible key/value server, Alpine's
|
||||
// riscv64 valkey and valkey-cli from main (about 1.7 MB to download; the
|
||||
// aarch64 valkey and valkey-cli from main (about 1.7 MB to download; the
|
||||
// libssl3 and libcrypto3 they link are already in the image). Alpine's redis
|
||||
// (about 2.1 MB, AGPL/SSPL) works the same way but is in community, and
|
||||
// enabling community makes every later apk command in the guest about 2 s
|
||||
@@ -150,7 +150,7 @@ cmd() {
|
||||
}
|
||||
section() { printf '\n\033[1m── %s\033[0m\n' "$1"; }
|
||||
|
||||
section "The server: INFO server, on riscv64 Linux in your browser"
|
||||
section "The server: INFO server, on aarch64 Linux in your browser"
|
||||
printf "$P %s\n" "INFO server (some of its lines)"
|
||||
valkey-cli INFO server | tr -d '\r' |
|
||||
grep -E '^(valkey_version|os|arch_bits|process_id|tcp_port|uptime_in_seconds|multiplexing_api|config_file):'
|
||||
|
||||
@@ -57,7 +57,7 @@ machine in the page's other terminal windows.
|
||||
- Each command runs in a fresh \`/bin/sh -lc\` and must finish within your
|
||||
tool's time limit (30 s at most). Start longer work in the background
|
||||
(\`nohup cmd > /tmp/cmd.log 2>&1 &\`) and check on it.
|
||||
- The CPU is emulated (an aarch64 interpreter, in the browser),
|
||||
- The CPU is emulated (an aarch64 interpreter with a JIT, in the browser),
|
||||
so builds and installs are slow. Prefer prebuilt packages.
|
||||
- Install software with \`apk add <package>\`; run \`/etc/kw-apk-enable\`
|
||||
first to enable the community repository. The network, when the page has
|
||||
|
||||
Reference in New Issue
Block a user