Wado

Fuel Benchmarks

Context

The Benchmark workflow timed each benchmark's throughput on a GitHub-hosted runner and compared it with the history on gh-pages. A hosted runner is a different machine from one run to the next, so the history mixed machines. A pull request was warned at 2x and failed at 4x, since anything finer was noise. No regression short of 2x could show.

Wall clock is still the only measure that compares Wado with C, Rust and JavaScript. That comparison needs a quiet machine, not a shared runner.

Decision

CI measures fuel, not time. Fuel is wasmtime's count of the Wasm instructions the guest ran, each priced near the time it takes. It does not depend on the host, so one run on any machine gives the figure that only a change to the program, to the prices or to wasmtime moves.

Fuel prices each operator near its time

wasmtime's default prices every operator at one, so an integer division, a call and an allocation each cost what an i32.add does. wado-host/src/fuel.rs gives Config::operator_cost a table instead, and every metered engine takes it: --report-fuel, Kiln generators, core:eval and the e2e harness. A fuel budget then bounds time, which is what the harness and core:eval use one for.

The Benchmark workflow stores the series under a suite name that changes with the prices, since figures under two price lists do not compare. Each list starts a history of its own on the page, and the older ones stay in its data.

core:fuel measures a region of a test

measure(label, f) runs f and reports the fuel it spent as region label of the running test. f's result passes through builtin::black_box, so its work stays in the region. The setup around the call is left out.

wado test --report-fuel shows each region on its test's line and writes every metered test to build/fuel.json. Without --report-fuel, measure just runs f, so the block stays an ordinary test.

The host interface is core:fuel/fuel-host: spent answers the fuel the running test has spent, and report records a region. wasmtime writes its fuel counter back to the store before every call, so spent is exact at the call. Only wado test links the interface. A program for any other world that reaches core:fuel does not compile, as with core:eval (TEST_WORLD_ONLY_IMPORT).

A test's insecure randomness is fixed

Under wado test, wasi:random/insecure and insecure-seed answer the same on every run, as Kiln generators and core:eval programs get. HashMap::new hashes under insecure-seed, and the seed changes how far its probes go, so without this a program using one spent different fuel on each run. First only a metered or coverage run fixed them; every test run now does, which also lets wado test cache a pass that drew them. wasi:random/random stays unpredictable.

Only a test gets this. insecure-seed exists to seed a hash map's DoS protection, so wado run and wado serve keep the host's seed under --report-fuel, and their fuel can vary with it.

The benchmarks keep both measures

Each benchmark program keeps export fn run(), timed by core:benchmark against the other implementations, and gains a test "fuel" block that measures the same phases once. The block reads its input with #include_bytes, since a test reaches no file.

benchmark/fuel.ts runs the blocks at -O1, -O2 and -O3, as the wall-clock series did, with --allocator freelist, the allocator a shipped program gets. It names each series <label> (<level>). A label is a path that starts with the benchmark's category, so the series of one category sort together: serde/ (serde/cbor/twitter/ser), gale/, codec/, compute/ and ml/.

CI holds fuel exactly and records it

benchmark/fuel.json is the baseline, -O2 alone. CI's test-fuel step, a test like any other, fails on any difference from it, either way, and names each series that moved. -O2 is the level a performance change answers for; -O1 and -O3 are for reference, so the Benchmark workflow records them and nothing holds them.

The Benchmark workflow only records: a push to main stores the series on gh-pages under benchmarks/fuel, beside the wasm sizes. It no longer runs on a pull request. An exact test leaves a threshold nothing to catch for fuel, and the wasm-size threshold, which failed a pull request at 130%, goes with it.

mise run update-baselines rewrites it together with the stdlib coverage baseline, since a change to the compiler or the stdlib moves either.

The wall-clock series on gh-pages stops. Its history stays where it is.

Known gaps