r/javascript • u/alexp_lt • 21h ago
TabBench: benchmarking Linux-in-browser implementations - Unkernel vs. WebVM vs. BrowserPod
https://github.com/leaningtech/tabbenchTabBench is a reproducible benchmark suite for libraries that run Linux programs in a browser tab. It runs the same commands natively and in each runtime on the same machine, and reports each result as a ratio to native. Only the commands are timed, after everything has booted.
It currently support three runtimes:
- [unkernel](https://github.com/pithings/unkernel): the Linux kernel compiled to WebAssembly, running arm64 binaries on an emulated CPU
- [CheerpX](https://cheerpx.io): an x86-to-WebAssembly JIT, the engine behind WebVM
- [BrowserPod](https://browserpod.io): programs compiled to WebAssembly ahead of time, with JavaScript on the browser's own engine
The workloads are shell tools (sort, gzip, sha256sum, find and a shell loop) and Node tools (npm ci, ESLint, the acorn parser and a CPU benchmark from unkernel's tests).Results, as a ratio to native (lower is faster):
- Shell tools: BrowserPod 1.4–5.8×, CheerpX 3.6–8.9×, unkernel 4.1–22×
- JavaScript: BrowserPod 1.4–5.1×, CheerpX 32–58×, unkernel 33–49×
- npm ci: BrowserPod 9.6×, unkernel 31×
We plan to add other runtimes, such as v86, JSLinux, container2wasm and WebContainers.
Disclosure: I am the lead engineer and CTO of Leaning Technologies, we make BrowserPod and CheerpX. The test suite is public and can be replicated, and PRs from maintainers of other runtimes are welcome.
Full description and results: https://github.com/leaningtech/tabbench
•
u/hyoahn 13h ago
Really cool benchmark suite! While testing tabbench locally, I reproduced a server crash and found two small null-guard bugs:
lib/server.mjs:26(URIError: URI malformedserver crash) &:18(prefixguard) A malformed URL likeGET /%E0%A4%AcausesdecodeURIComponent(new URL(req.url, "http://x").pathname)to throw an uncaughtURIErrorand terminate the Node server. WrappingdecodeURIComponentintry/catchand guarding!prefixkeeps the server up cleanly:
function resolve(urlPath) {
const prefix = Object.keys(ROOTS).find((p) => urlPath.startsWith(p));
if (!prefix) return null;
...
}
// inside createServer:
let pathname;
try {
pathname = decodeURIComponent(new URL(req.url ?? "/", "http://x").pathname);
} catch {
return res.writeHead(400).end("Bad Request");
}2. targets/native.mjs:32 (TypeError when /BENCH (\d+) (\d+)\n$/.exec(stdout) returns null) If a workload exits without printing the trailing timing marker, destructuring .exec(stdout) throws a generic TypeError instead of surfacing stdout context:
const match = /BENCH (\d+) (\d+)\n$/.exec(stdout);
if (!match) throw new Error(`benchmark command exited without timing marker: ${stdout.slice(-200)}`);
const [marker, code, us] = match;Verified locally against lib/server.mjs (GET / → 200, GET /%E0%A4%A → 400, GET /../package.json → 404). Happy to open a tiny PR if you'd like!
(P.S. Found these in a couple of seconds with XapBug — npx xapbug / https://xapbug.com — a local, zero-telemetry AST bug/leak checker for JS/TS/Python. Handy to run locally whenever you want to catch unguarded nulls or resource leaks fast before a run.)
•
u/na-6381989 11h ago
For the JavaScript row, are Node version and build held constant across runtimes, or is that part of each port? That distinction would help interpret the gap.
•
u/makisever4 4m ago
Does the JavaScript range exclude npm ci and cover the other Node workloads? Since npm ci gets its own row, spelling out the split would make the ratios easier to interpret.
•
u/Opposite_Sector2145 21h ago
If you want to replicate these TabBench results, make sure you use the exact commands listed in the README and run them after everything has finished booting. Timing before all initialization completes will give totally different numbers.