Wefti

How to speed up CMake configure

Use wefti in native mode to reuse verified compiler checks across build directories. The synthetic warm-probe test ran 7.30x as fast as CMake 4.5.1. Across DuckDB, OpenCV, Protobuf, Qt Base, and LLVM, the geometric mean speedups were 1.31x cold, 2.21x with a warm probe cache, and 2.24x after a leaf edit.

Use the slow configure guide to identify the slow step. Compare v0.4.0 measurements in the benchmark report.

To speed up configure for an existing CMake project, test the native wefti command in a separate build directory. On an Apple M1, the geometric mean speedups for five large C++ projects were 1.31x for cold configure, 2.21x with a warm probe cache, and 2.24x after a leaf edit.

Configure benchmark results

Wefti was faster than CMake 4.5.1 in 37 of 40 matched workloads. The ratios ranged from 0.97x to 138.17x. Cold configure was slower for the 100-target project (0.99x), nlohmann/json (0.97x), and Protobuf (0.99x). The string(JSON) script ran 2.42x as fast. See the benchmark report for the test conditions.

Wefti v0.4.0 configure speed on Apple M1 against CMake 4.5.1
ProjectColdWarm probe cacheLeaf edit
DuckDB1.52x2.37x5.44x
OpenCV1.74x3.85x1.13x
Protobuf0.99x2.17x1.95x
Qt Base1.24x1.58x2.47x
LLVM1.20x1.69x1.90x

Each large project used three runs per phase. The Wefti median for LLVM was 12.35 s with a warm probe cache and 3.16 s after a leaf edit. Across those projects, the highest peak resident set size (RSS) was 341.05 MiB for Wefti and 391.14 MiB for CMake. The highest peak RSS for the configure process alone was 273.89 MiB for Wefti and 325.74 MiB for CMake.

Cold configure on small projects
Workloadwefti (ms)CMake 4.5.1 (ms)Speedupwefti peak RSS (MiB)CMake peak RSS (MiB)
corpus zlib 1.3.1 (cold)746.251011.601.36x41.535.9
corpus fmt 11.2.0 (cold)744.43804.491.08x38.037.9
corpus nlohmann/json 3.12.0 (cold)448.22435.270.97x37.837.9
Synthetic and local FetchContent configure scenarios
Workloadwefti (ms)CMake 4.5.1 (ms)Speedupwefti peak RSS (MiB)CMake peak RSS (MiB)
configure 100 targets (cold)449.38445.230.99x36.035.9
configure 100 targets (warm)13.99159.1111.37x10.322.6
configure 500 targets (cold)1865.902676.511.43x146.2112.8
configure 500 targets (warm)17.202376.55138.17x10.5113.3
synthetic (cold configure)2896.723539.581.22x36.8636.23
synthetic (warm probe-cache configure)468.313417.557.30x35.8436.09
synthetic (incremental-leaf)58.26136.052.34x21.0921.11
Local FetchContent (cold FetchContent configure)294.55353.171.20x27.0527.05
Local FetchContent (warm-fetch)148.50254.951.72x19.2715.73

The warm 500-target test reused an unchanged build directory. A separate warm probe-cache test used a new build directory. In the synthetic leaf-edit test, the Wefti median was 58.26 ms. The slowest of five runs took 58.60 ms, which the benchmark reports as the 95th percentile.

In the peer benchmark, each tool reconfigured five times after an edit to a compile definition. The median for 100 targets was 62.1 ms with Wefti and 159.2 ms with CMake. For 500 targets, it was 219.6 ms with Wefti, 565.6 ms with CMake, and 210.8 ms with Muon. In the 500-target cold runs, peak RSS was 66.7 MiB for Wefti and 82.3 MiB for CMake.

Measure configure on your project

Use a new build directory for each cold run. On the same machine, run both tools with the same generator and toolchain.

cmake -S . -B build-cmake-check -G Ninja
wefti -S . -B build-wefti-check -G Ninja

Record elapsed configure time for each command. For a leaf-edit test, change one source directory and repeat the commands in their original build directories. Use a separate timed build if you need to measure compile and link time. After configure, run wefti build build-wefti-check to compile and link with the built-in Ninja 1.13.2 executor.

When you create a build directory, CMake runs compiler and linker checks such as try_compile(). These checks can run in sequence and repeat for each new directory. When CMake configures an existing tree, it can reuse results in CMakeCache.txt, but it still evaluates the directory scripts.

Wefti checks recorded probe inputs with SHA-256, including the compiler binary. With a vcpkg toolchain or a preset, Wefti runs setup and checks that setup inputs and state match before it uses replay.

Four ways Wefti saves configure time

Parallel compiler checks
Wefti runs independent literal compile probes in parallel. The default limit is up to 16, subject to the processor count and available memory.
Shared probe cache
Fresh build trees reuse checks after SHA-256 verification of recorded inputs. wefti cache export and import move the cache between CI runners.
Incremental replay
Wefti records configure results in a compact binary journal. A later configure can replay unchanged directories after it checks their recorded inputs.
Ninja generation
Wefti skips generation when the recorded inputs match. For eligible single-configuration Ninja builds, partial generation (F2) and the Ninja fragment cache (F3) are on by default in native mode. Wefti updates the affected parts of the manifest when its checks pass. If the partial generation checks fail, Wefti runs full generation.

All four apply to the native wefti command.

Reuse compiler probes locally and in CI

  1. Install Wefti. Install the same Wefti release on the producer and consumer. Use the same compiler and toolchain paths. See the installation guide.
  2. Fill the probe cache. Set WEFTI_PROBE_CACHE_DIR and configure once with wefti to record verified compiler probes.
  3. Reuse verified results. Configure a fresh build tree with the same probe cache. On another runner, import an archive with the SHA-256 digest from a trusted producer.
export WEFTI_PROBE_CACHE=readwrite
export WEFTI_PROBE_CACHE_DIR="$HOME/.cache/wefti-probes"
wefti -S . -B build-first -G Ninja
wefti -S . -B build-second -G Ninja
wefti cache export probes.tar.gz

In continuous integration (CI), run this Bash step once the trusted job's artifact is available. The file probes.sha256 must contain only the digest from the producer job. The complete workflow shows both jobs.

export WEFTI_PROBE_CACHE=readwrite
export WEFTI_PROBE_CACHE_DIR="$RUNNER_TEMP/wefti-probes"
wefti cache import probes.tar.gz --sha256 "$(cat probes.sha256)"
wefti -S . -B build -G Ninja

Use wefti cache remote to check the remote cache connection. Use wefti cache pull to restore and verify a pack. Use wefti cache push to upload eligible probe and configure entries. See the CI cache guide for setup.

Reuse the same compiler and toolchain paths on both runners. If a recorded input changes, wefti runs the check again.

Frequently asked questions

Why is my CMake configure slow?

A fresh build directory can repeat compiler and linker probes. Reconfiguring can also spend time re-evaluating directory scripts. The time depends on the project, compiler, and dependency setup.

How much faster is warm configure with Wefti?

In v0.4.0, the synthetic warm-probe configure ran 7.30x as fast as CMake 4.5.1. The geometric mean for the five large projects was 2.21x.

Can I share the probe cache between CI runners?

Yes. Export it with wefti cache export and import it with wefti cache import --sha256. Get the digest from a trusted producer and keep compiler and toolchain paths consistent.

Does the cmake alias turn on the shared probe cache?

Use the wefti command for the native defaults. The cmake alias selects compatibility mode.

Does Wefti run compiler checks in parallel?

Yes. In native mode, Wefti runs up to 16 independent literal compile probes at once by default, capped by CPU count and available memory. Set WEFTI_PROBE_JOBS to change the limit up to 32. try_run and execute_process do not run in parallel.

Can Wefti skip Ninja generation when nothing changed?

Yes. From version 0.3.0, native mode records the inputs of a Ninja generation. A later configure skips generation when the configure state and the recorded files still match. Set WEFTI_SKIP_GENERATION=0 to turn the skip off.