Skip to content

ci: switch ./compile to fbuild compile-many for faster example builds on CI #2470

Closed

Description

@zackees

Summary

FastLED's ./compile wrapper (via ci/ci-compile.py) currently invokes fbuild deploy once per example in a loop. On GitHub Actions the loop is forced serial by ci/util/cpu_count.py:7-8:

def cpu_count() -> int:
    if "GITHUB_ACTIONS" in os.environ:
        return 1
    ...

That short-circuit dates back to PlatformIO, where each pio run cost hundreds of MB and two concurrent invocations on a 2-core runner risked OOM. Under fbuild's daemon model that constraint no longer applies, but the loop itself is still single-threaded — and it pays the per-invocation fbuild startup cost (toolchain load, LDF process startup) ~80 times per board.

A new fbuild primitive (fbuild compile-many, tracked in FastLED/fbuild#238) folds the entire "build framework once, fan sketches out in parallel" pipeline into a single process:

fbuild compile-many --board <board> \
    --framework-jobs 1 \
    --sketch-jobs 2 \
    <sketch1> <sketch2> ...

This issue tracks switching FastLED's ./compile to consume that primitive when it ships, so the CI matrix gets the speedup automatically.

Why this is a separate ticket from the fbuild work

fbuild is upstream of FastLED. FastLED/fbuild#238 builds the primitive in fbuild and proves it on the upstream benchmark workflow (FastLED/fbuild's bench/fastled-examples branch). Once that primitive lands and a fbuild release ships, this ticket is the downstream consumer change — small, local to ci/, and unblocks the same speedup for FastLED's own CI.

Expected savings on build_*.yml workflows

Based on FastLED/fbuild#112 iter7 measurements (board=uno, ~80 examples):

current state with compile-many 2-wide stage 2 with compile-many 4-wide
compile phase ≈ 136 s ~73 s (-46 %) ~42 s (-69 %) on bigger runners

Every build_* workflow that compiles the example set benefits proportionally. On 2-core ubuntu-latest the realistic gain is ~60 s per board × ~20 boards = ~20 minutes of total CI time saved per push to master.

Plan

  1. Wait for feat(cli): two-stage compile-many primitive — framework once, sketches in parallel (#112) fbuild#238 to land + a fbuild release that exposes compile-many.
  2. Bump the pinned fbuild version in pyproject.toml.
  3. In ci/ci-compile.py, replace the per-example loop with a single fbuild compile-many call. Wire --framework-jobs and --sketch-jobs to env vars (FASTLED_FRAMEWORK_JOBS, FASTLED_SKETCH_JOBS) with sensible defaults: framework-jobs = 1, sketch-jobs = min(cpu_count, 2) on Actions, full cpu_count elsewhere.
  4. Delete the GITHUB_ACTIONS → 1 short-circuit in ci/util/cpu_count.py. The new path uses fbuild's own scheduler; the wrapper no longer needs to police per-job memory pressure.
  5. Run all build_*.yml workflows to confirm no regression in pass/fail or per-example output. Record before/after timings on build_uno.yml as the canonical comparison.

Acceptance

  • ./compile <board> <examples> works end-to-end via compile-many, no behavioral change vs the old loop.
  • build_uno.yml compile phase drops by ≥ 40 % on ubuntu-latest (per [META] Fastest possible FastLED examples CI rebuild — profile + benchmark fbuild#112 iter7 expectations).
  • No new flakiness in board CI (per-board success rate on master matches pre-switch baseline over 10 consecutive runs).
  • ci/util/cpu_count.py no longer has the GITHUB_ACTIONS short-circuit, or has it gated behind a different (justified) constraint.

Out of scope

Related

Activity

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions