Skip to content

meta: cold builds 50% faster than PlatformIO (performance audit) #1469

Open
8 of 8 issues completed
Open

Description

@zackees

Goal

fbuild's cold build is at least 50% faster than PlatformIO's on the nightly Blink benchmark (SVG, benchmark-build-comparison.yml, ubuntu-24.04). Put simply: fbuild_cold_median ≤ 0.5 × platformio_cold_median, sustained for 7 consecutive nightly runs, with the benchmark's cold definition unchanged or changed equally for every tool.

Baseline (2026-09-25, sha 0433e96)

cold warm
PlatformIO 745 ms 551 ms
fbuild 2111 ms (2.8× PIO) 46 ms
target ≤ ~372 ms —

Root cause of today's gap (#1464): the embedded zccache's post-miss include scan uses ~85% of CPU during a cold build, against ~11% for the compiler. LTO and flags match PlatformIO's.

Plan (order matters)

Phase 0: measure

Phase 1: zccache (fix upstream first)

Phase 2: fbuild adoption

Phase 3: beat PlatformIO by 50%

Expectations

Phases 1–2 should remove about 1–1.5 s and bring fbuild to roughly PlatformIO parity. Measured locally at 4 cores, the raw avr-gcc floor is already ~340 ms, close to the 372 ms target, so Phase 3 is required and Phase 0's data decides which Phase 3 items are worth doing.

Performance-audit rules

  • Every PR in this effort includes before/after benchmark numbers (median of 3, 4 cores).
  • Profile with a symbolized release build: CARGO_PROFILE_RELEASE_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_STRIP=none, plus perf record --call-graph dwarf.
  • No regressions to warm builds (currently 46 ms).

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Activity

  1. zackees commented on Sep 26, 2026

    @zackees
    MemberAuthor

    Progress: forge-ci/zccache#1670 landed (forge-ci/zccache#1701: 8.4× faster single-pass include lexer, plus a per-TU miss-overhead bench and CI budget). #1464 landed (#1474, zccache repinned to 8475316). CI Blink benchmark (4 vCPU, 3 trials): fbuild cold 451 ms vs PlatformIO 868 ms (0.52×), warm 46.3 ms (no regression); the baseline was 2111 ms (2.8×). Next: #1466 (forge-ci/zccache#1708 single-flights the probes), #1467, #1468.

  2. zackees commented on Sep 26, 2026

    @zackees
    MemberAuthor

    All sub-issues have landed:

    sub-issue PR
    forge-ci/zccache#1670 forge-ci/zccache#1701: single-pass include lexer (8.4× on avr-libc + ArduinoCore), per-TU miss-overhead bench, and a CI budget
    #1464 #1474: zccache repinned to the fast miss path
    #1466 forge-ci/zccache#1708 + #1475: one toolchain probe of each kind per compiler (was 25 -v -E / ~14 --version / 3 -dumpversion)
    #1467 #1477: compile_commands.raw.json with the real toolchain commands; the raw-compiler floor now reports a number
    #1468 #1478: compile phases share one job budget and overlap; objcopy and size run together

    CI Blink benchmark (4 vCPU, median of 3), latest clean run on #1478:

    • fbuild cold is 427 ms vs PlatformIO 890 ms, which is 0.48×. The baseline was 2111 ms, or 2.8×.
    • Warm is 46 ms, unchanged.
    • The raw avr-gcc floor is 236 ms.

    Still open before this meta issue can close:

  3. zackees commented on Nov 19, 2026

    @zackees
    MemberAuthor

    Steward measurement: the remaining cell (7 consecutive nights at ≤ 0.5×) is failing on uno, and the current benchmark definition cannot produce a build-speed ratio

    Ladder check first: no actionable PRs (ready=0, needs_work=0), no non-deferred bugs. So I took this issue's only open cell and measured it from the published data instead of re-reading the plan.

    What the published history says

    I parsed benchmark-stats:history.jsonl — all rows since the cold-definition boundary of 2026-11-06 (COLD_TRIAL_SIGNATURE = "first-time-install/1", documented at bench/fastled-examples/src/build_comparison.rs L44-56). 32 rows.

    board runs ≤ 0.5× min median max trailing streak
    uno (comparison_board) 1 / 32 0.473 0.896 0.912 0
    esp32s3 31 / 32 0.301 0.3075 0.945 30

    The single UNO row at 0.473 is 2026-11-07T11:57Z — the definition transition itself, not a measurement of the new metric; the issue's own #2002-era note records that excursion as "a cold-trial semantics change". Every other UNO row sits in 0.877–0.912. So on the board that defines the criterion, the target has never been met and the streak is zero, not "thin".

    Why uno cannot reach 0.5× under this definition

    Latest run (44495824783, sha 400faf6, latest.json), shaped link = 10 Mbit/s = 1.25 MB/s:

    tool cold payload effective
    PlatformIO 61,660 ms 59.4 MB 0.963 MB/s
    fbuild 54,553 ms 64.5 MB 1.183 MB/s
    • fbuild already transfers at 95% of the line rate, so its floor is 64.5 MB / 1.25 = 51.6 s → best achievable ratio 0.837.
    • 0.5× would require fbuild's whole first install to fit in ≤ 38.5 MB, i.e. a 40% payload cut from today's 64.5 MB — while PlatformIO ships 59.4 MB for the same board.
    • fbuild's entire 7.1 s advantage is downloader efficiency: its payload is 8.7% larger than PlatformIO's. Give both tools a perfect downloader and fbuild is 64.5/59.4 = 1.087× slower on UNO.

    So the residual 13 points to 0.837 are not headroom — they are link physics. The metric that is failing is install throughput, not compile speed.

    The measurement gap

    This issue's own baseline table (PlatformIO 745 ms cold, fbuild 2111 ms cold) is a compile-only cold build. CI stopped recording that on 2026-11-06, when cold was redefined to first-time install so all downloads land inside the timed window. The last compile-only figure (#1478, 2026-09-26) was 427 ms vs 890 ms = 0.48× — the target was met in the terms it was written in, and then the terms changed. Compile cost is now invisible in the nightly: warm is 48 ms and the raw avr-gcc floor is 254 ms against a 54.5 s cold.

    Cross-environment rows are deliberately excluded by the regression gate, so the old compile-only rows cannot satisfy the criterion either. No published series can show "7 consecutive nights ≤ 0.5×" today.

    Resolution options (needs a maintainer ruling, not a steward pick)

    1. Additive compile-only cold — keep first-install cold exactly as published, and add a second metric per tool (toolchains retained, only project outputs and the compile content cache cleared), with its own env signature so the regression gate keeps them separate. Restores observability of the number this issue targets; costs a history-schema bump and doubles the per-trial work.
    2. Restate the target for the current definition — accept 0.837 as the UNO structural floor (fbuild at line rate), keep 0.5× as the esp32s3 criterion it already meets at 0.306, and treat UNO payload as a separate install-size problem: cutting 26 MB off a 64.5 MB payload would be required to pass as written.

    I am not choosing between them, and I have not touched the benchmark: changing a published metric definition is a design decision. #1469 stays open; recording the block with this evidence so the next tick nominates real work instead of re-deriving it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions