High-Performance CI Playbook

Every millisecond in CI comes from five bottlenecks: unnecessary serial dependencies, process-spawn overhead, cache misses, heavy link/test thrashing, and expensive Windows/macOS runners. Here is how to eliminate all five with FastCi.

View llms-full.txt Manifest Schema

1. Design Shallow, Critical-Path DAGs

FastCi's scheduler ranks ready jobs by longest critical path (weight + downstream dependency chain). A flat graph with explicit weight lets slow compilation start on millisecond 0 while linters and generators fill remaining CPU cores.

2. Prefer Direct-Spawn cmd Over shell

cmd invokes posix_spawn / CreateProcessW directly with an argv array. shell spawns /bin/sh -c or cmd.exe /c on every invocation.

Aspect"cmd": [...] (Recommended)"shell": "..."
Windows process overheadSingle CreateProcessW (~2–4 ms)Extra cmd.exe + AV scan overhead (~15–40 ms)
PortabilityIdentical across Linux, macOS, WindowsDiverges between POSIX sh and Windows cmd.exe
Injection safetyNo shell expansion / quoting bugsMust carefully escape paths and spaces

Reserve shell strictly for genuine pipes, redirects, or shell-builtin chains.

3. Cache-Key Hygiene & Deterministic Inputs

A build cache is only fast when its keys are both sound and stable:

4. Tune verify_inputs for Your Repo Size

ModeBehaviorWhen to Use
"fast" Trusts statcache (mtime_ns, size, inode) + NTFS USN journal with zero re-hashing on metadata match. Local developer workstations and large monorepos (10k+ files).
"sample" Uses statcache for normal inputs, verifies a deterministic 64-file sample by content, and strictly hashes every critical_inputs entry. Recommended CI default — near-fast speed with strong tamper/clock-skew protection.
"strict" Re-hashes every input byte on every run. Release signing pipelines, reproducible build verification, and untrusted workspaces.

5. Resource-Aware Scheduling (cpu_slots & mem_mb)

Blindly running N linkers or Rust crates in parallel causes OOM kills and swap thrashing on 4-core / 7 GB GitHub-hosted runners. FastCi tracks both CPU slots and RAM budget (max_ram_mb):

{
  "$schema": "https://seregonwar.github.io/FastCi/schema/fastci.schema.json",
  "name": "cpp-service",
  "verify_inputs": "sample",
  "max_ram_mb": 6144,
  "jobs": [
    {
      "id": "compile-core",
      "cmd": ["cmake", "--build", "build", "--target", "core", "--parallel"],
      "cpu_slots": 2,
      "mem_mb": 2048,
      "weight": 120,
      "critical_inputs": ["CMakeLists.txt"],
      "scan_deps": ["src/core/engine.c"],
      "include_dirs": ["include"],
      "outputs": ["build/libcore.a"]
    },
    {
      "id": "link-release",
      "needs": ["compile-core"],
      "cmd": ["cmake", "--build", "build", "--target", "app"],
      "cpu_slots": 2,
      "mem_mb": 3072,
      "weight": 80,
      "inputs": ["build/libcore.a"],
      "outputs": ["build/app"]
    }
  ]
}

6. Cutting Windows (2×) & macOS (10×) CI Costs

GitHub Actions bills Windows minutes at 2× and macOS minutes at 10× relative to Linux. Apply these rules to minimize minutes on expensive runners:

  1. Gate Windows & macOS behind a fast Linux pre-check: Run formatting, static analysis, and unit tests on ubuntu-latest first; skip Windows/macOS jobs on broken commits.
  2. Always use Ninja + MSVC /Z7 on Windows: Never use MSBuild solution builds when Ninja works, and never pass /Zi (shared PDB locks kill cache hits).
  3. Exclude cache & build dirs from Windows Defender on self-hosted runners: Add FASTCI_CACHE_DIR and build/ to Defender exclusions to avoid real-time scanning on every restored .obj.
  4. Use fastci wrap + CMAKE_*_LINKER_LAUNCHER: Caching final static libs and binaries avoids re-linking unchanged executables on macOS and Windows.
  5. Use FASTCI_PP_CACHE=1 on Windows: Caches preprocessed output in direct-mode misses to eliminate redundant cl.exe /P invocations.
  6. Warm a shared Remote CAS on main: Let branch pushes populate the remote cache while PRs read from it with FASTCI_REMOTE_READ_ONLY=1.

7. Profile & Optimize with Chrome Trace

Stop guessing where build time goes. Export a Chrome Trace Event file and structured JSON report on every CI run:

fastci run -f fastci.json --trace trace.json --report report.json
fastci stats

Open trace.json in ui.perfetto.dev or chrome://tracing to spot: