Skip to content
Skip to Content

Benchmarks

Measure isolated and concurrent builds with cold and warm caches

CI coverage

The Perf gate measures hk, eza and aube on PRs. Each subject runs Kache from the PR and its merge base, and mbx, sequentially on one runner. sccache runs weekly.

TriggerSubjectsIsolated samples per toolContention samples per tool
Same-repository PR, ready for reviewhk, eza, aubeKache head and base, each: 2 cold, 6 same-checkout warm, 6 cross-checkout warm. mbx: 1 cold, 1 same-checkout warm, 1 cross-checkout warm1 cold + 1 warm batch
PR with the bench label or [bench] in its titlehk, eza, aube2 cold, 6 same-checkout warm, 6 cross-checkout warm2 cold + 6 warm batches
Nightly, 03:37 Europe/Zurichhk, eza, aubeKache: 2 cold, 6 same-checkout warm, 6 cross-checkout warm. mbx: 1 cold, 3 same-checkout warm, 3 cross-checkout warm1 cold + 3 warm batches
Weekly, Sundayhk, eza, aubeAs the nightly, plus sccache: 1 of each1 cold + 3 warm batches
NightlyLance, OpenDALKache and mbx, each: 1 cold, 3 same-checkout warm, 3 cross-checkout warm—
NightlyLLVMKache: 1 cold, 3 same-checkout warm, 3 cross-checkout warm—
NightlyFirefox Linux/Windows, SurrealDB, cuda-oxide, kobeOne measurement per configured phase—

The opt-in also runs on same-repository draft PRs. Adding either trigger or pushing a new commit starts a measurement; a newer run cancels the older one. Fork PRs cannot use the self-hosted benchmark runner.

Firefox Linux/Windows, including the next-commit variants, run only on the nightly schedule. Manual all excludes Firefox. Substrate is no longer a benchmark subject.

The two Firefox/Windows arms run in their own workflow on the same nightly cron. Each takes five to six hours. A workflow run finishes only when its slowest job does, so while they shared a workflow with the Linux matrix, every other arm's telemetry waited for them.

SubjectKachesccachembx
hk, eza, aubeyesweeklyyes
Firefox LinuxyesyesC and C++ only
Firefox Windows, LLVM, cuda-oxide, kobeyes——
SurrealDB, Lance, OpenDALyes—yes

The sccache arms have their own workflow and their own schedule: weekly, and again whenever the pinned sccache version changes. That covers Firefox and the hk, eza and aube suites. sccache is pinned in mise.toml, so a nightly arm would measure the same sccache binary every night while only Kache changed. The per-PR perf gate already compares Kache with itself. Running it separately also keeps its 75 minutes off the nightly's critical path, so nightly results reach the collector sooner. mbx tracks its latest release, so it stays nightly.

The Firefox mbx arm is the exception. A Firefox build is too long for the nightly, so it runs weekly from the same workflow. It builds with mbx exec ./mach build, which caches C and C++ compiles. Cargo calls inside that session are not cached, so the arm's Rust crates compile in every phase and its hit rate counts C and C++ only.

hk retains its prediction-disabled and next-commit scenarios. The next-commit Kache variants separate exhaustive prediction verification from timing.

Cold CI prefetch qualification

The Prefetch cold CI qualification workflow compares three prefetch on/off pairs using a pinned eza revision, Rust 1.90.0 and two Cargo jobs. A protected main push produces one immutable seed containing Kache, cached artifacts, manifests and namespace shards. Every consumer starts with empty local and target directories. The harness sets KACHE_EVENT_ROOT to the workload root so Rust, build scripts and native compiles share one session even when Cargo creates no directory tag.

Consumers read that seed through a loopback S3 fixture with a 50 ms delay before each response. The fixture records requests and rejects writes. This measures prefetch under controlled request latency; it does not model cloud bandwidth, packet loss or variable service latency. Remote key listing is enabled in both arms. The ordinary S3 default leaves listing disabled.

The collector requires matching executable hashes, drained telemetry, complete GET-body precision accounting and matching latency controls. It reports full GitHub job durations separately from the build phases. HTTP logs and transport profiles are included in each consumer artifact. Startup downloads carry no session ID. In this isolated runtime, the collector joins them to the sole demand session only after the daemon has drained all prefetch tasks. Multiple demand sessions or incomplete receipts fail admission.

A manual workflow run reuses the binary in its selected seed. To qualify a new Kache revision, use a new seed produced by a main push. Reusing an old seed does not test newly merged fixes.

For a Linux sandbox experiment before merging the workflow, build Kache from the revision under test, install Rust 1.90.0, then run:

python3 scripts/prefetch-qualification.py experiment \
  --root /tmp/prefetch-experiment \
  --output /tmp/prefetch-results \
  --binary "$PWD/target/release/kache" \
  --revision "$(git rev-parse HEAD)" \
  --response-delay-ms 50

Use a fresh root for each experiment. The result contains three alternating on/off pairs and build durations. A local experiment seed is rejected by CI; its timings are not GitHub job durations. Use --response-delay-ms 0 for an HTTP baseline without an injected delay. Pass --archive /path/to/seed.tar.gz to repeat an experiment with the same local seed. Its recorded revision must match --revision; the bundled binary is used.

Phases

Phase in JSONCache before the buildBuild directory
coldEmptyEmpty
warm_same_treeSnapshot populated by coldEmpty, original checkout
warmSame cold snapshotEmpty, different checkout at the same revision
pullPopulated at commit AEmpty, original checkout moved to commit B

hk and eza run the first three phases through all three tools. Other clone scenarios run cold and cross-checkout warm. The separate pull scenarios measure cold followed by the next-commit rebuild; they do not measure an incremental build with existing artifacts.

Cold uses the cache tool with an empty store. It is not an uncached build without a wrapper. The operating system's page cache is not flushed.

The short suite fetches dependencies before timing. It alternates arm order, keeps each arm's store and paths separate, and measures a new cold seed every third sample. The other samples run with --retry, which restores the saved cold seed instead of building it. That reused cold value is left out of the cold sample count and duration telemetry. Each warm phase restores that seed and clears its build artifacts before starting.

Reading a PR result

The PR comment opens with one table: Kache base and head for each subject, as median times per build with the paired change. Timings for every tool, contention counters, disk use and the paired test sit in folded sections below it. With more than one sample, each time shows its range. summary.json carries the statistics; samples.json retains raw measurements, source/tool versions, arm order, and the head/base/instrument identities. Build logs and engine reports are retained for each sample.

Only Kache head versus base decides the PR verdict. Increased warm misses or passthroughs fail independently of elapsed time. Timing tests compare against zero change; there is no automatic percentage or duration allowance.

Before measuring, the harness records a randomized base/head order for each cold-cache seed. Even numbers of seeds use balanced AB/BA assignments; odd numbers use independent assignments. The same order holds for that seed's warm repeats. Those repeats form one statistical block. The report shows geometric paired changes, exact two-sided randomization probabilities and simultaneous 95% family intervals. Intervals assume a constant proportional effect and condition on this run's measurement slots. They do not describe variation across machines or nights.

Declare the timing and cold-count family before running with --comparison-family-size. The three-subject PR suite declares 18 comparisons and uses Bonferroni correction, which allows dependence between phases. A detected positive change fails; a detected negative change is an improvement. Other results are inconclusive, including legacy data without a recorded randomization. Nonsignificance does not establish parity.

The default six isolated samples reuse two cold seeds. They provide only two randomized blocks, so timing remains inconclusive. Six fresh contention seeds also cannot resolve a two-sided test at this suite's corrected level. Sample counts and runtime remain unchanged. For a focused comparison, use --samples 12 --cold-every 1 --skip-contention; predeclare a larger family when combining workloads. Repeat on another lease before generalizing the result. Other tools provide context and never decide the verdict.

The method follows randomized blocks, exact paired permutation tests and Bonferroni intervals. A successful measurement job means its validity and regression checks passed; an INCONCLUSIVE report is not a performance approval.

Missing phases, zero restores, cache errors, or invalid Kache verdicts produce INVALID MEASUREMENT. A fast build that did not exercise the cache is not a performance result. Competitor timings provide context and never fail a PR because another tool is faster.

The engine, scenarios, installer, and comparison policy come from the default branch. Only the two Kache binaries vary with the PR. Changes to the measuring instrument therefore take effect after they merge. perf-gate/warm remains an optional status; this workflow does not change branch protection.

Local commands

just bench                 # list Kache scenarios
just bench hk --warm-same-tree
just bench eza --warm-same-tree
just bench-pr              # one Kache side of hk and eza
just bench-short hk        # three tools, six warm samples each
just bench-short eza
just bench-sccache hk --warm-same-tree
just bench-sccache eza --warm-same-tree
just bench-mbx hk --warm-same-tree
just bench-mbx eza --warm-same-tree
just bench-mbx hk-pull
just perf-gate-local       # HEAD against its merge base, with the gate's verdict

The complete short suite runs on Linux. It measures mbx and sccache only when given --mbx <binary> or --sccache <binary>. On macOS, pass --skip-contention to run its isolated builds. It refuses to overwrite its output directory; pass --output <fresh-path> after the sample count for another run. Run builds on an otherwise quiet host. A CI job takes much longer than its build phases: tool installation, compiling Kache, preparing the subject, and repetitions all add to its elapsed time.

Individual benchmark runs keep reports under tmp/bench/<scenario>/ and archive completed runs in runs/. The short suite keeps samples.json, summary.json, perf-gate.md, metrics.otlp.json, and per-sample logs/ in its output directory.

See the scenario format when adding a subject. For choosing a cache, see Kache or sccache?.

Contention on one runner

bench-contention.py runs six Cargo commands for hk or eza: check, Clippy, and test compilation, each with default features and a second feature set. hk uses all features/targets; eza uses no default features and all targets. Every command owns a separate checkout and target directory. Commands share one store of the selected tool within an arm; arms and cold seeds have separate stores. Cold starts empty. Warm clears all six targets and restores the completed cold store. Both phases use the debug profile without Cargo incremental state. These are batch measurements; eza's isolated release build remains a separate case.

just bench-contention --project hk --samples 3 --jobs-per-build 4 \
  --output /tmp/hk-contention

# Compare two release binaries with identical settings and alternating order.
python3 scripts/bench-contention.py --project hk --samples 3 \
  --arm base=/path/to/base/kache,1 --arm head=/path/to/head/kache,1 \
  --jobs-per-build 4 --output /tmp/hk-contention-comparison

eza's --all-features graph enables vendored OpenSSL and exceeds the short case's budget. --full-features retains that stress workload for standalone runs and exports it as bench-eza-contention-full-features. On the validation runner, sccache 0.15.0 failed OpenSSL's assembler generation in that variant; those results are invalid and excluded from the normal comparison.

The number after the comma in each --arm value enables (1) or disables (0) Kache's scheduler. Use --parallelism 1, 3, or 6 to vary overlap while retaining the same six commands and independent targets. --jobs-per-build sets Cargo's parallelism inside each command; it does not change the scheduler's permit pool.

Run this Linux-only benchmark on a quiet runner. The report retains CPU affinity, cgroup CPU/memory limits, CPU throttling, sampled real compiler counts, and cgroup memory usage, including filesystem page cache. Compiler peaks exclude wrapper processes and include native compiler/preprocessor frontends. Sampling can miss short-lived processes. Cgroup measurements include other work inside that container, so compiling Kache or running tests alongside the measurement invalidates comparisons.

The export includes samples.json, summary.json, report.md and metrics.otlp.json. Each phase adds its Cargo logs, raw Kache events, mbx session streams, Perfetto traces, and process samples in result.json. The export records binary hashes, toolchain, source revision, and instrument hash. It reports compiler invocations, duplicate compilations of a cache key, and time spent computing keys, waiting for peers, and waiting for permits. Summed wait times overlap; they are not elapsed-time savings. Event logs use a larger retention budget for the six-job batch, and detected rotation invalidates the measurement.

After each cold and warm batch, the runner measures storage outside the timer. samples.json and OTLP include logical bytes, bytes counted once per inode, and allocated blocks for the cache, targets, and their combined footprint. Cache components distinguish blobs, the SQLite index, mbx session logs, and other metadata. The report shows mean allocated GiB. Hardlinks count once; shared reflink extents are unresolved, so allocated blocks are not exclusive physical disk usage. Sources, Cargo home, runtime logs, and cold snapshots are excluded. Cache-resident session logs remain included.

bench-short includes contention for hk and eza in PRs and nightly. The same three tools run identical commands; Kache head and base also run on PRs. Contention appears as its own report section and as bench-hk-contention or bench-eza-contention in the existing OTLP metrics. The suite archives raw results under contention/ and includes the statistics in summary.json. Missing backend reports or failed builds invalidate the suite.

PRs measure six fresh cold contention seeds and six warm batches per Kache arm. Cold duplicate counts use the recorded order randomization and the same predeclared family as timings. Warm increases in duplicate compilations, misses or passthroughs fail immediately. Nightly runs without a base arm report descriptive counts and timings.

Use --contention-samples 12 --contention-cold-every 1 with bench-short for twelve fresh paired seeds in a focused comparison, or --skip-contention to focus on isolated builds. To run only contention with all three tools, add --sccache /path/to/sccache --mbx /path/to/mbx to the standalone command. Compiler invocation and internal wait counters come from Kache events. Other tools report their own cache statistics, and fields they do not report show as unknown. mbx's wrapper_phases_ns holds exclusive phase durations, while Kache's key timer includes dependency discovery, so the two timers measure different work.

Detailed phase tracing

For a diagnostic run, add --trace-phases to bench-contention.py. Kache then records real monotonic intervals under each phase's kache-phases/ directory and merges them into kache.trace.json, which Perfetto can open. The trace marks prediction decisions and measures prediction reads and validation, dependency discovery, file hashing, scheduler waits, compiler execution, local lookups, and Rust artifact restoration. Nested spans include their children; summing them double-counts that work.

Outside the benchmark, set KACHE_PHASE_TRACE_DIR=/tmp/kache-phases when running Cargo through Kache. Each wrapper writes its own trace on return. The trace covers the wrapper's calling thread only: it leaves out CLI startup and work in child processes or other threads. Trace writing adds overhead, so compare performance on untraced runs. The benchmark marks traced runs as diagnostic and rejects missing or truncated traces.

On Windows, a daemon started with the same trace directory also records native runtime hash preparation on its worker thread. Those files have a worker-thread scope; wrapper files retain wrapper-thread. Existing daemons keep their startup environment.

kache stats --format perfetto remains the compact event-based view: its phase offsets are reconstructed from millisecond totals. The opt-in files above record actual interval placement and retain sub-millisecond work.

Memory-pressure admission qualification

scripts/bench-pressure.py compares real Rust builds under measured Linux cgroup pressure. It generates an offline workspace with independent crate graphs, starts background Cargo builds at nice 10, and starts small foreground builds at nice 0. Each arm has a fresh store, runtime and target directories. No external source, build script or dependency is downloaded or executed.

Run it on a disposable, dedicated Linux machine with delegated cgroup v2 memory, cpu and pids controllers and cgroup.kill. Eight visible CPUs are needed to exercise a sustained warning ceiling above one slot: reserve_for(pool) is max(pool / 4, 1). Smaller machines can qualify safety and accounting, but their warning floor cannot demonstrate that throughput benefit. The hard memory cap must leave at least 40% of host memory outside the workload. The supervisor stays outside the task cgroup.

Build both arms from the same source revision with the same toolchain and build settings. Generate a control patch before building the base arm:

python3 scripts/bench/legacy-pressure-control.py "$PWD" > /tmp/kache-pressure-control.patch
git worktree add --detach /tmp/kache-pressure-control "$(git rev-parse HEAD)"
git -C /tmp/kache-pressure-control apply /tmp/kache-pressure-control.patch

The control restores the previous ordinary-admission policy: warning or critical pressure requests the whole pool and retains those slots until the compile ends. It keeps the current pressure observation and persistence costs in both arms and leaves bounded recovery unchanged. This isolates admission policy; it is not a binary from the historical release. The patch generator refuses unfamiliar source so a later refactor needs review.

Build both the frontend and its sibling engine in each checkout before measurement. Use a separate target directory for each checkout:

CARGO_TARGET_DIR="$PWD/target" RUSTC_WRAPPER= CARGO_BUILD_RUSTC_WRAPPER= \
  cargo build --locked --release --bin kache --bin kache-engine

Keep each arm's kache and kache-engine together. Do not compile Kache or run another workload during measurement. With both pairs prepared and a delegated parent at /sys/fs/cgroup/kache-pressure, run:

python3 scripts/bench-pressure.py \
  --base /tmp/kache-pressure-control/target/release/kache \
  --head "$PWD/target/release/kache" \
  --base-revision "$(git rev-parse HEAD)" \
  --head-revision "$(git rev-parse HEAD)" \
  --control-patch /tmp/kache-pressure-control.patch \
  --cargo /absolute/path/to/toolchain/bin/cargo \
  --rustc /absolute/path/to/toolchain/bin/rustc \
  --output /tmp/kache-pressure-results \
  --cgroup-parent /sys/fs/cgroup/kache-pressure \
  --dedicated-host --cpus 8 --memory-max-mib 3072 --memory-high-mib 512

Start with --scenario sustained --samples 1 as a pilot. Choose the workload size and memory.high from that pilot, freeze them, then run fresh paired measurements. The scenario names describe the limit schedule, not an observed kernel state. A run without warning or critical PSI samples does not qualify pressure behavior. The default schedules are unrestricted memory.high, sustained low memory.high, and alternating 15-second intervals. The latter must produce alternating kernel samples to qualify recovery behavior.

--second-memory-max-mib places half the jobs in a tighter child cgroup while both children share one store and permit pool. Each sample retains both children's usage, limits and PSI. This exposes differing resource domains; it does not establish a headroom-based admission policy. The production controller still uses PSI and recorded compiler RSS weights. Available cgroup headroom remains diagnostic input.

The harness records the resolved frontend and sibling engine paths and hashes for each arm. It checks both files before creating workload state and at batch boundaries, outside the batch's elapsed time. Hashes identify the measured files; retain build receipts to tie them to the supplied source revision labels. Identical engine bytes are recorded explicitly and remain useful for smoke tests or negative controls.

The receipt also records the patch hash, source revision labels, toolchain, CPU affinity, arm order and raw 200 ms samples. Its results distinguish:

  • Sampled aggregate compiler RSS, which can double-count shared pages, from kernel cgroup peak memory, which includes filesystem page cache.
  • Foreground build completion latency from total completed-build throughput. Completion is polled at the sampling interval, so reported latency can overestimate exit time by up to that interval. Small foreground sample counts do not support a stable tail estimate. Check the foreground/background overlap count before interpreting the latency as contention.
  • Observed OOM counters from prevented OOMs. Swap is disabled inside every task cgroup, so zero swap is a configured condition, not evidence about systems with swap enabled.

Each batch stops on its wall-clock deadline, an OOM event, low host available memory, a child reaching 90% of its cap, or a Cargo failure. Cleanup kills only the newly created task cgroup and retains logs, generated sources and JSON evidence. Sampling cannot guarantee that it sees a short memory spike before the kernel acts; memory.max remains the containment boundary. Limit changes run in separate helper processes with a five-second deadline, so synchronous reclaim on older kernels cannot block the supervisor's checks.

Default paired runs are exploratory. Report per-pair results and uncertainty; do not infer parity or choose new defaults from two pairs. Real macOS pressure, swap-enabled Linux workloads, sustained warning without critical pressure, and the cross-cgroup case need separate evidence before closing #1773. The simulation in PR #1782 and the ordinary CI perf gate do not cover those gates.

Available for:
Apple macOS logomacOSMicrosoft Windows logoWindowsLinux logoLinux
Download Kunobi