examples/benchmark-suite exists to make the figure a thing you can rerun, on your own daemon, and compare.
It is a TypeScript program on the published sandkiln npm package, so it measures what an SDK caller feels. That is a different layer from the VMM-level numbers, and the difference is the subject of the last section.
What it is for
Three jobs, in order of importance.- Run the same measurement against any daemon you can reach over HTTP, not only the one on the development box.
- Write a result file with the environment recorded, so a number carries its date, daemon version, guest kernel, host kernel and CPU.
- Compare two result files and say whether something regressed, with an exit code a script can gate on.
Structure
The split follows one rule: anything that does not need a daemon is a pure module and is unit tested without one.stats.ts (percentiles and the summary), format.ts, compare.ts and args.ts take values and return values. The five test files under test/ cover them and run with npm test and no daemon. The parts that need a daemon, context.ts, run.ts, env.ts, status.ts and the benchmarks, are thin on logic and are exercised by running the suite itself.
A benchmark is a small object with a name, a one-line description and a run(ctx). Adding one is a new file under src/benchmarks/ and one line in index.ts. The registration order is the run order.
The context
Every benchmark receives aBenchContext. It owns three things.
- A metric sink:
ctx.record(name, value)appends one sample. The unit defaults to milliseconds, and throughput metrics passops/sand a flag saying that higher is better, whichcompareneeds to know which way is a regression. - Creation:
ctx.create()is the only way to make a sandbox, and it stamps every one with the tagbenchmark_run=<unique id>. The id is a base-36 timestamp plus six random hex characters, so two runs never share one. - Cleanup:
ctx.cleanup()finds exactly what carries this run’s tag and removes it.
Cleanup of tagged resources
A benchmark that leaves sandboxes, snapshots and checkpoints behind distorts the next run and fills a disk.cleanup deletes three kinds of thing, each matched by this run’s tag and nothing else:
- live sandboxes, stopped with
keep: false; - held snapshots, by id;
- retired checkpoints in snapshot history, because
resumeretains the checkpoint by default and each one is a full memory dump plus a rootfs copy.
finally, and on SIGINT or SIGTERM, where the process exits with code 130 after it finishes. It never throws, so it is safe inside a finally block, and each deletion is settled independently: one failure does not stop the rest. If the sweep itself fails, it says so and names the tag to look for. Because the match is on the tag, it never touches anyone else’s sandboxes, which is what lets the suite run next to real work without destroying it.
Refusing a busy daemon
Before anything runs,run.ts asks GET /status. If the daemon reports live sandboxes, the suite stops with an error that says how many and how to proceed, unless --allow-busy is passed. Other sandboxes compete for the same CPU, disk and tap devices, and every number would be skewed in a way nothing in the output reveals. The check happens only at the start, so something that begins creating sandboxes mid-run is still noise. The README says so.
The refusal also paid for itself. When the init-mode image was measured, another job held a live sandbox and the suite refused to run the parallel benchmark. Running it with --allow-busy would have produced a number that looked fine. That result is recorded in docs/benchmarks.md as not measured, which is the correct state for it.
What it measures
Two design decisions are worth stating, because they are why the numbers mean something.
It counts to a real command.
create() returning only means the VM started. The create benchmark records the call, the first command and their sum separately, so you can see that the call is about 21 ms while the wait for the agent is about 213 ms. What a start-latency number means explains the gap.
The snapshot benchmark warms the sandbox first. It runs a command before snapshotting, so the guest agent is known to be live. Then the fork’s and the resume’s first command measure restore cost and not agent startup. The fork is stopped before the resume because only one live fork per snapshot is allowed.
Statistics, and how to read the output
Each metric is summarized from its sorted samples: countn, min, max, mean, median, p95 and p99. Percentiles use linear interpolation, the same definition as numpy and most spreadsheets, and summarize throws on an empty sample set rather than inventing a value.
With --iterations 20 the p95 and p99 sit between the second largest and the largest sample. They are nearly the max and say little. Treat the median and the min as the stable figures, and read p95 as “the slow end seen in this run”.
The environment block comes first in the output. It records the daemon version from GET /status, the guest kernel from running uname -r inside a throwaway sandbox, the count of rootfs clones by method, and the live-sandbox count at start. It records the host kernel and CPU only when the daemon is on loopback, because only then does the machine running the suite know about the host. For a remote daemon, --hardware takes a label. The clone counts matter: a result where the copy count rose during the run was timing byte copies of a rootfs and not reflinks, which is what the rootfs clone post taught.
Compare mode
compare reads two result files, checks that each is a result file of schema 1, and compares medians. A latency is a regression when it is worse by more than --threshold percent and by more than --min-delta-ms, so a 40 microsecond wobble on a 245 microsecond metric is not reported as a 16 percent regression. A throughput metric regresses when it drops. A metric present in only one file is listed as such, and the command exits 1 when anything regressed, so it can gate a script. Usage errors exit 2.
Sample results
The committed run isexamples/benchmark-suite/results/2026-11-24-i9-13900K.md: an i9-13900K with 32 threads, host kernel 6.8, guest kernel 5.10.223, Firecracker v1.16.1, reflink rootfs on XFS, 20 iterations (200 for exec), an idle daemon at the start.
A second identical run agreed to within a few percent except for snapshot take, per
docs/benchmarks.md. The parallel row has n of 160 because eight creates per round over 20 rounds each contribute a sample.
What it found
The suite was run against the published figures to see whether the two sets agree. Where they measure the same thing, they do: create to first command (214.5 ms mean published, 213.1 ms median measured after create returned) and resumed first exec (8.4 ms against 6.3 ms). Two disagreements are the real findings.Layer differences that are not regressions
Neither is a regression and neither is wrong. They are different intervals with similar names, which is the whole argument of the previous post. The published VMM rows remain the right figures for the cost of the VMM itself. The suite is the better figure for what an SDK caller experiences, because it has a stated method, a recorded environment and the raw samples.
Snapshot take: unexplained
This one is not explained by the layer difference, and the repository says so.
The suite times the full
snapshot() call and the published figure is VMM-level, so some gap is expected. The size of the gap, roughly 1.7 to 2.5 times the published range, is more than a layer would obviously explain, and snapshot take is the most load-sensitive figure the project has, since it synchronously writes all of guest memory to a disk shared with a desktop. docs/benchmarks.md marks it open until a VMM-level rerun on a quiet box reads the same. The honest summary is that two measurements disagree and the cause is not known, and nothing on this page should be quoted as the snapshot cost without that caveat.
Using it for A/B comparisons
The--image option boots every sandbox from a registered image, and the id is recorded in the result. That is how the init-mode image was compared with the systemd image: alternating runs back to back on an idle daemon, 30 sequential creates each. Median create to first command was 225.5 to 234.6 ms on the systemd image across four runs and 144.6 to 149.7 ms on init mode across two valid runs. Two further init runs were discarded after the result showed create_call at 98 ms instead of 22 ms, a sign that every create had copied a 300 MB image because the image directory was on a filesystem that cannot reflink. The clone counts in the environment block are how that would be caught.
What it cost or risks
- Small samples on a shared machine. A sample result is a data point and not a guarantee. Rerun before concluding anything.
- The suite pins the published 0.12.0 SDK. It calls
GET /statusdirectly because the SDK’s owngetStatusis newer than that. A future SDK bump removes that duplication. - Cleanup depends on the tag. A sandbox created outside
ctx.create()is not tracked. ASIGKILLof the suite cannot run cleanup, and the tag in the log line is how leftovers are found.
How to reproduce
From the repository root, on a machine with the daemon running:scripts/remote.sh run. The suite needs Node 22.18 or newer and no build step, since TypeScript runs directly. Run it on an idle daemon, and check GET /status yourself if a result looks noisy. To compare two runs, use scripts/dev.sh bench-suite compare before.json after.json, or npm run compare from examples/benchmark-suite as shown above, and report any metric that moved that you did not expect.