Repository navigation
perf: let the daemon's zccache run one compiler per core - #1546
Conversation
zccache caps concurrent compilers at cores-1 unless it sees a CI marker, and the CLI spawns the daemon with a scrubbed environment that never carries one. Every build, CI included, therefore ran 3 compilers on a 4-core runner. The daemon now exports ZCCACHE_MAX_PARALLEL_COMPILES as every core before the embedded service starts (overridable via FBUILD_MAX_PARALLEL_COMPILES; an explicit ZCCACHE_ value is left alone). That cap is the single global governor across concurrent builds.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: FastLED/fbuild/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe build engine now selects an embedded zccache compile cap from environment values and available CPU parallelism. The daemon applies the selected cap before embedded zccache starts, while preserving an explicitly configured zccache value. ChangesEmbedded compile cap
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to This change raises the daemon's default compiler concurrency to use all available cores instead of one fewer, with tests covering the override and fallback logic. The change appears safe to merge based on the supplied evidence. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new limit is set when the daemon starts and can be overridden by the launcher. No build-request path to change it was identified. The implications for deployments that share a daemon remain uncertain. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CI benchmark on this branch (run 36460654491, 4-core ubuntu-24.04, median of 3,
|
Part of #1537 (the "oversubscription" item) and #1469.
Problem
zccache's daemon core gates every compiler spawn behind one global semaphore (
compile_concurrency.rs). Unset, its size iscores - 1on hosts it doesn't recognise as CI. The CLI spawnsfbuild-daemonwith a scrubbed environment (daemon_client.rs,env_clear()plus a user baseline plusFBUILD_*), so the daemon never seesCIorGITHUB_ACTIONS. Every build, CI included, runs at mostcores - 1compilers.Evidence on
bench/blink -e esp32s3, pinned to 4 cores:compile concurrency capped at 3 via in-process semaphore./procevery ~25 ms during a cold build shows exactly 3xtensa-esp32s3-elf-g++drivers and 3cc1/cc1plusprocesses the whole time, even though fbuild hands out 8 permits.compile-core-varianttakes 4.99 s against a raw compiler floor of 4.02 s. Three-way parallelism predicts about 4.0 × 4/3 ≈ 5.3 s.Fix
Before the embedded service starts, the daemon exports
ZCCACHE_MAX_PARALLEL_COMPILES = available_parallelism().ZCCACHE_MAX_PARALLEL_COMPILESalready in the daemon's environment is left alone.FBUILD_MAX_PARALLEL_COMPILESoverrides the default, becauseFBUILD_*survives the scrubbed spawn. It accepts a number,0, orunlimited; anything invalid falls back to every core.compile_cap_env_value, covered by unit tests.It defaults to every core, not
cores - 1, because zccache already runs compiles at low priority on interactive hosts, so the desktop stays responsive. Holding a core back on top of that only costs throughput.Oversubscription
That zccache gate is the one process-wide governor. It covers every concurrent build and every library compile the daemon runs, so the box never runs more than
corescompilers, whatever--jobseach build asks for. fbuild's per-builddefault_jobs = cores*2stays as is: the extra permits act as a prefetch queue, so the next TU is already waiting at the gate when a compiler exits.Numbers
Before (CI, main
417f5f43, 4-core ubuntu-24.04): fbuild cold 6.61 s,compile-core-variant4.99 s, raw floor 4.02 s, PlatformIO 7.08 s.After: benchmark dispatched on this branch, results to follow in a comment.
Local A/B timings aren't usable: the shared box is at load average ~29 from other builds. The mechanism was verified by process sampling instead.
Summary by CodeRabbit
unlimited.