roadmap

Cycle counters: the riscv64 half as built and measured

An appendix to milestone 74 (cycle counters), under ยง212 (a prose budget). This appendix holds what the riscv64 lane built and left out, the emulator finding it carried out, and the working behind radon's measurement with the rows it converts.

What the riscv64 half built, and what it deliberately did not

Built 2026-09-03, lane milestone/74-cycle-counters-riscv.

Deliberately not built, and each is the block's scope note rather than an oversight:

SBI_REQUIRED, the one thing it forced

The one thing the SBI PMU extension forced was not the ecall. SBI_REQUIRED was every row of SBI_TABLE by construction, because every extension the kernel had ever called was one it could not boot without. PMU is the first that is an instrument. A kernel that refused to boot without an instrument would have confused the measurement with the thing measured. So SbiRow grew the required field Row already carried one source over. The existing accumulation test failed on the first run, which is what it was for.

The emulator was more misleading than predicted

The emulator was more misleading than the block's prediction allowed for. This is the one finding worth carrying out of the riscv64 half. Under -icount the cycle CSR and the time CSR are driven off the same virtual clock. So the probe reads cycles_per_tick 100.00, exactly the ratio between the two declared rates, with a rounding wobble and nothing else.

That is not a number that looks wrong. It looks like a clean measurement of a 1 GHz core, and a reader who did not know what TCG does to these two registers would have every reason to write it down. The defense is that the probe line prints its inputs (10000029 cycles over 100000 ticks at cntfrq 10000000) rather than only the ratio, so the arithmetic is visible. And notes/riscv-cycle-counters.md's outcome table names an exact round ratio as the tell rather than as the answer.

Why radon's 250.00 is real

A round number is exactly what milestone 16a warned would be an artifact, so the reason it is real is recorded rather than assumed. 16a's block says QEMU-TCG yields "an implausibly exact 100.00" because one virtual clock drives both the cycle and time CSRs, and an exact ratio is the tell.

This one is 250 for a physical reason. cntfrq is 4 MHz, the core is running at 1.0 GHz, and both derive from the same PLL. So the ratio is an integer by construction of the silicon rather than of the emulator. The evidence that two independent counters are being read is that the measurement is not exact. 25,000,940 over 100,002 ticks is 250.0044, and a single clock feeding both would give 250.0000 every time. The 0.0044 is the drift an emulator cannot produce.

What it converts

Every tick-denominated row of a board bench becomes cycles and wall time at 250 cycles per tick. These are from the same boot, single-hart. --bench parks the secondaries, so these are uncontended costs.

row cycles time
null_system_call 322 0.32 us
yield_switch 571 0.57 us
ipc_rtt 1,046 1.05 us
call_reply 1,256 1.26 us
map_el0 1,477 1.48 us
ctx_switch 1,980 1.98 us
relay_rtt 2,306 2.31 us
broker_rtt 2,512 2.51 us
ipc_rtt_el0 6,222 6.22 us
spawn_reap 17,086 17.09 us
spawn_el0 64,820 64.82 us

These are not comparable to bench/baseline-riscv64.txt, and the reason is the unit rather than the machine. That file records QEMU icount, which counts guest instructions, while these are real cycles on silicon. The icount baseline remains what the tripwire checks; this table is what the hardware costs. Putting them in one table would be the apples-to-apples failure notes/benchmarks.md exists to prevent.

The aarch64 half was untouched by this when it was measured. It was built three days later and has not met silicon.