notes

Benchmarks with teeth

(Milestone 21 (performance measurement). script/bench, kernel/src/bench.rs, bench/baseline-<arch>.txt. This page carries the current numbers. The dated history is in the appendices, whose names calef ratified on 2026-09-24 (the naming record).)

Why two instruments

One tool cannot both gate commits and tell the truth about magnitudes.

icount (default) HVF (--real)
what runs TCG translation, -icount shift=0,sleep=off the kernel, natively on the M-series core
build release, as it ships (nife#4132) dev, or --release
virtual time a deterministic function of instructions executed the hardware counter, 24 MHz
numbers are exact and reproducible per binary real: the host's caches, TLBs and predictors
numbers mean path length; magnitudes are fiction nanoseconds; determinism is gone
job regression gating: --check fails on drift past 10% knowing what a path costs
architectures aarch64, riscv64, x86_64 aarch64 only (Hypervisor.framework runs the host ISA)

The committed baseline is the performance record.

Running it

script/bench                    # aarch64 icount counts
script/bench --check            # diff against bench/baseline-aarch64.txt; fails past the tripwire
script/bench --riscv64 --check    # the same for riscv64
script/bench --x86 --check      # the same for x86_64
script/bench --save --why "<reason>"   # re-record, in the commit that moved the numbers
script/bench --real             # HVF, one hart: per-core magnitudes, never gates
script/bench --real --release   # optimized kernel and userspace; the build every comparison uses
script/bench --real --smp       # HVF, four harts: smp_* and, with a disk, the fs_* benches

CI runs all three --check legs on every pull request (script/ci-build's bench row). notes/bench-runbook.md says which board to spend an evening on and in what order.

The rules a baseline save follows

What is measured

Kernel-side benches call scheduler and IPC functions directly. EL0 benches are userspace programs making real traps, as lmbench and seL4 do, so they are the cross-OS numbers.

bench plane one iteration
yield_switch kernel one voluntary yield in a two-thread ping-pong: two switches
ipc_rtt kernel send and receive round trip: two rendezvous, one address space, no trap
call_reply kernel the service shape: mint a one-shot Reply cap, rendezvous, reply
relay_rtt kernel client, relay, backend and back: one confined intermediary
broker_rtt kernel call_reply with the queue broker interposed
spawn_reap kernel spawn a thread, let it exit, reap it
map_new kernel retype a fresh page from a region, walk, write the leaf (interrupts masked)
coremark EL0 pure compute; the control that must never move
null_system_call EL0 one svc the kernel rejects at once
ctx_switch EL0 SYSTEM_CALL_YIELD to a peer process and back
ipc_rtt_el0 EL0 SEND and RECEIVE between two processes: four traps
map_el0 EL0 MAP_INTO of an aliased frame: the mapping mechanism with no zeroing
spawn_el0 EL0 build a child from nothing, run it to exit, reap, reclaim its region

Also: sink_throughput (a byte stream), rfence_self (riscv64's SBI fence), tss_iomap_* (x86_64's I/O bitmap), and on --smp only, smp_* and fs_*.

The current numbers

Against Linux and macOS, on one core (HVF, release)

Linux runs as a static musl /init under QEMU-HVF on the same M-series core, nife's tier. Native macOS is the bare-metal ceiling. The host side is bench/host/.

metric nife date Linux (HVF) macOS (native)
null system call 27 ns 2026-08-04 ~139 ns ~76 ns
context switch, per switch, derived ~29 ns 2026-07-29 ~415 ns ~818 ns
IPC round trip, EL0 350 ns 2026-08-04 ~1,723 ns ~2,620 ns
provision and map a fresh page ~500 ns (map_new + one trap) 2026-07-29 ~534 ns ~556 ns
map mechanism only ~92 ns (map_el0) 2026-07-29 n/a n/a
spawn, build to reap ~4.4 us (spawn_el0) 2026-07-29 ~19.7 us (fork+exit) ~291 us

The Linux and macOS columns date from 2026-07-25 (spawn 2026-07-26); the nife column is the latest release reading of each row, and the 2026-08-04 figures are a median of five boots.

nife wins four rows and ties one. The null system call and the IPC round trip are about 5x faster than Linux at the same tier. Page provisioning is a three-way tie near 500 ns, because zeroing 4 KiB is bandwidth-bound on all three. The 92 ns mechanism is not a page a program can use, so it is no win. Cross-OS primitives has the methods and the debug-build history.

Against seL4's published cycles

On one core, under the same QEMU-HVF machine, seL4's Call plus ReplyRecv between two address spaces costs a median of 96 ns and nife's ipc_rtt_el0 442 ns: about 4.6 times (2026-10-21, eight boots each). How much of the ARM plan runs under HVF has the method and its caveats. seL4 needed one patched line for the guest's 8-bit ASIDs. The instrument is a loop averaged against the generic timer, because the guest's PMU is synthetic.

seL4 publishes, for the same-core different-address-space path, 413 cycles for the IPC call and 426 for the IPC reply, one-way each. The machine is a Jetson TX1 (Cortex-A57, 1.9 GHz). Converting 350 ns at an assumed 2.75 to 4.05 GHz gave ~960 to ~1,420 cycles. So the corrected figure is roughly 1.1x to 1.7x an L4-lineage round trip, not 4 to 7 times. The same-silicon ratio above is the one to quote. sel4bench's own PMU method needs a real PMU, which xenon and argon (milestone 127 (the seL4 machine)) have. Calibration against seL4 has the build recipe.

The regression floors (icount, release, nightly-2026-11-25, QEMU 11.1.2)

Ticks per iteration from bench/baseline-<arch>.txt on 2026-11-26. Ticks are not comparable across architectures: aarch64 counts at 62.5 MHz (16 instructions a tick), riscv64 at 10 MHz (about 100), x86_64 at 1 GHz (one). Icount tick scales measures them.

bench aarch64 riscv64 x86_64
ipc_rtt 75.6 12.7 1,181
call_reply 78.9 13.2 1,219
relay_rtt 151 25.4 2,361
broker_rtt 158 26.3 2,437
yield_switch 35.8 6.3 607
spawn_reap 982 166 7,972
map_new 115 18.7 804
null_system_call 6.6 1.8 (EL0 plane not in this leg)
ctx_switch 49.6 10.0
ipc_rtt_el0 192 35.1
spawn_el0 3,114 502

What a userspace server costs

The confined-server tax is one intermediary: relay_rtt minus ipc_rtt, about 75 ticks on aarch64, or two extra switches and two extra rendezvous. The queue broker costs the same shape again, broker_rtt at 2.0x call_reply on both ISAs, which is why it is opt-in per channel. A live service swap adds nothing to the steady state. The service path has the derivation.

Scaling across four harts (HVF, --smp)

Independent compute scales 3.5x on four cores, 89% of the ceiling. Sixteen synchronous IPC pairs go backwards (0.18x). A pair split across cores wakes a vCPU the host has descheduled, the hypervisor's cost. Real silicon is where pipelines should scale. Per-core and multi-hart has both workloads and why --real boots one hart.

Filesystem throughput (HVF, --smp, 2026-08-19)

nife after milestone 138 (close the read gap) milestone 38 (filesystem throughput), where it started
sequential read, 64 KiB request 329,168 ns, 189.9 MiB/s 2.68 MiB/s at 4 KiB
sequential write, 64 KiB request 936,583 ns, about 67 MiB/s 1.52 MiB/s at 4 KiB

That is 70.9x on sequential read. The block path is at parity with Linux: 39.0 us marginal per block through a confined userspace block server, against 38.7 to 53.3 us for a raw virtio read at the same tier. Buffered Linux reads at about 7,141 MiB/s, because it has a page cache and nife does not. Closing that is out of milestone 138's scope. Five appendices hold the history, starting at milestone 38's.

A directory walk (HVF, --release)

Walk costs, milestone 606 (a directory walk costs what it does on Linux).

The IPC fastpath's footprint

script/fastpath-footprint walks the call graph out of the disassembly and sums the bytes an IPC round trip can fetch. It fails on 5% growth against bench/fastpath-<arch>.txt, whose figures milestone 188 (the IPC fastpath) recorded.

aarch64 riscv64 x86_64
ipc_call_reply, stored 2026-09-04 7,028 5,936 8,122
ipc_call_reply, measured 2026-09-21 on nightly-2026-09-20 7,104 6,038 8,234
system_call_entry, stored 1,508 1,828 1,637

The target is under 4 KiB, about an eighth of the smallest L1i we run on (radon's U74, 32 KB). The shape the system runs is 1.47x to 2.01x that target. calef ruled on 2026-09-21 that the target is printed and not gated. Kernel footprint and caches derives the target from Liedtke's argument, and the gate has the method and its limits.

x86_64

There is no HVF or KVM for x86_64 on this host, so --real there is plain TCG, whose magnitudes mean nothing. The icount leg works and gates. The I/O-bitmap write that §121 (x86 port I/O) priced costs +216 ticks per iteration when nothing holds a port, against +2,373 for the naive 8 KiB write (x86 TSS I/O bitmap). CR4.PGE and CR4.PCIDE cannot be measured under TCG (x86 instruments).

What the instruments cannot see

icount models no caches, no TLB and no branch predictor. So:

HVF sees real magnitudes on one machine only: no PMU, a 41 ns counter grain, a desktop OS underneath, an L1 hiding any footprint effect. argon's PMU is where that changes.

What is not apples to apples

Where a new finding goes

A dated finding goes in the appendix for its theme, or a new one under notes/benchmarks/, linked from the table below. If it changes a current number, update that number here with its date in the same commit. The prose budget, ratified by calef on 2026-09-23, caps this page and every appendix at 3,000 words.

Appendices

The third column lists the dated entries each holds, so a citation like "the 2026-08-24 section" resolves here.

appendix what it verifies holds
calibration-against-sel4 the seL4 comparison first numbers (2026-07-23); calibration (2026-08-04); the PMU wall
sel4bench-on-xenon the method 2026-10-21
cross-os-primitives the cross-OS table and its caveats milestone 19e (run a real workload); first EL0 and cross-OS numbers
icount-drift-and-provenance the tripwire, the stamps, one-hart pinning drift across builds; 2026-07-28; stamps (2026-09-21)
per-core-and-multi-hart the smp_* numbers, single-hart --real §28 (SMP placement); 2026-07-29 refresh
service-path the confined-server tax service path; 2026-07-29 and 2026-08-04 re-saves
riscv-map-new-and-the-rfence-probe never re-save an unexplained move 2026-08-15; 2026-08-17
kernel-footprint-and-caches the 4 KiB target 2026-08-17; 2026-08-18; the target
fastpath-footprint-gate the footprint numbers 2026-08-18; 2026-08-27; 2026-09-04; 2026-09-21
filesystem-throughput ext4 and APFS milestone 38 (2026-08-18)
record-level-sweep the 39.0 us block 2026-08-18 sweep
five-blocks-per-request the five repeated reads the 208 us; option 2; the workload
read-path-record-and-request-size 8 KiB record, 64 KiB request 2026-08-18; 2026-08-19
read-path-block-contract-and-metadata-cache 189.9 MiB/s, the cache 2026-08-19; controlled comparisons
x86-tss-iomap +216 and +2,373 ticks 2026-08-24; 2026-09-15
x86-instruments what x86_64 can measure 2026-08-25; 2026-09-19; 2026-09-23
spawn-el0 spawn since the HVF reading 2026-08-27; 2026-09-21
drift-decomposition the shipping-feature rule milestone 300 (decompose the icount baseline drift)
baseline-save-audit drift accumulates 2026-09-15 audit
counter-frequency-and-calibration rates come from the machine 2026-09-21 (two)
icount-tick-scales a tick is not an instruction 2026-09-30
swish-check-x86-leg the x86_64 shell leg was paced by ticks 2026-10-03
rfence-self-row the open rfence_self row 2026-09-21; 2026-09-23
preemption-in-the-window the masked map_new window 2026-09-21 (three)
host-reordering-under-tcg arm64 CI hosts 2026-10-24
drift-since-the-2026-09-26-floors drift on main on all three ISAs 2026-10-02
drift-since-the-2026-10-10-floor four merges, and a tick that doubles one 2026-10-19
riscv64-spawn-reap-drift the double copy 2026-10-22
riscv64-unexplained-drift the riscv64 chart line, a false compiler term 2026-11-03
x86_64-unexplained-drift the x86_64 chart line, the tick's phase 2026-11-04
aarch64-unexplained-drift the aarch64 chart line, an unclaimed gain 2026-11-05

BUGS