Skip to content

ci: flip FASTLED_USE_FBUILD_CI to default-on (compile-many is the default) - #2672

Closed
zackees wants to merge 3 commits into
masterfrom
chore/enable-fbuild-compile-many-by-default
Closed

zackees wants to merge 3 commits into
masterfrom
chore/enable-fbuild-compile-many-by-default

Conversation

@zackees

@zackees zackees commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

With #2671 on master, FastLED is now on fbuild 2.2.13 — which ships the compile-many stage-2 framework-archive share (FastLED/fbuild#337). That fix is what closes the gap that originally forced the gate to default-off in #2662: stage-2 sketches used to rebuild the framework from scratch in their own per-sketch project dirs, which on uno took ~7 min vs ~3.5 min serial and on teensy41/esp32s3 blew past the 30 min batch timeout. With the share in place, locally that's a ~19× cold-cache speedup on uno (200ms per stage-2 sketch vs ~3.7s prior).

Polarity flip

Before After
Default legacy serial loop compile-many (or `fbuild ci` when supported)
To select compile-many `FASTLED_USE_FBUILD_CI=1` unset / any non-falsy value
To select legacy serial unset / falsy `FASTLED_USE_FBUILD_CI={0,false,no,off}`

The env var name and its truthy values (`1`/`true`/`yes`/`on`) are preserved — anyone who has the opt-in baked into a wrapper script keeps working.

Safety / rollback

If anything goes sideways post-merge, set `FASTLED_USE_FBUILD_CI=0` in the affected workflow's env block — that immediately puts the path back on the legacy serial loop without touching code. The whole gate-flip is a polarity change in one method (`PioCompiler._build_fbuild`) plus a clarifying comment in the existing test; nothing else changes.

Risk evaluation

The original #2662 break happened because compile-many with the framework-rebuild-per-sketch regression was unconditionally enabled — there was no escape valve. This PR has two key differences:

  1. Stage-2 framework rebuild is fixed upstream in fbuild 2.2.13 (#337); locally verified 19× speedup on uno via #342 (real-toolchain regression test).
  2. The env var still exists as an opt-out — if a board-specific CI run hits something we didn't anticipate, flipping it back is a one-line workflow env change, not a code revert.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Performance

    • Batched compilation is now enabled by default for faster builds; it can be disabled via build configuration.
    • Batch execution timeout increased to 3600s and is now configurable.
    • Increased default parallelism for framework build jobs to better utilize available CPU cores.
  • Documentation

    • Updated build configuration guidance and environment-setting instructions to reflect the new defaults.

…ault)

fbuild 2.2.13 ships the compile-many stage-2 framework-archive share
(FastLED/fbuild#337). That fix is what closes the gap that originally
forced the gate to default-off in #2662 — stage-2 sketches used to
rebuild the framework from scratch in their own per-sketch project
dirs, which on uno took ~7 min vs ~3.5 min serial and on
teensy41/esp32s3 blew past the 30 min batch timeout. With the share
in place, locally that's a ~19x cold-cache speedup on uno (200ms
per stage-2 sketch vs ~3.7s prior).

Flip the polarity:

  Before: opt-in via FASTLED_USE_FBUILD_CI=1; default = legacy serial.
  After:  default = compile-many (or 'fbuild ci' when supported);
          opt-out via FASTLED_USE_FBUILD_CI in {0,false,no,off}.

Any non-falsy value (including unset) selects compile-many. Existing
opt-in setters (=1/true/yes/on) keep working — the env-var name and
its truthy values are preserved.

Test update: existing test_pio_compiler_build_prefers_ci_results still
sets FASTLED_USE_FBUILD_CI=1 explicitly. Under the new logic that's
redundant but harmless, and it guards against a future regression that
flips the polarity back — a CI environment that inherits
FASTLED_USE_FBUILD_CI=0 from a parent shell would otherwise silently
disable the path the test means to exercise.

Refs FastLED/fbuild#337, #2662
@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

fbuild selection in PioCompiler._build_fbuild now prefers fbuild ci / compile-many by default (opt-out via explicit false-like FASTLED_USE_FBUILD_CI), the docstring and fallback message are updated, a test comment is clarified, and framework-job defaulting now uses min(cpu_count(), 2).

Changes

fbuild compile-many default behavior

Layer / File(s) Summary
Default compile-many behavior and docstring
ci/compiler/pio.py
Docstring updates clarify that fbuild "ci"/"compile-many" are now default in _build_fbuild, with FASTLED_USE_FBUILD_CI serving only as an opt-out when set to disabling values (0, false, no, off). Environment parsing logic changes from opt-in (truthy check) to opt-out (explicit false-like value check).
Batched run timeout configuration
ci/compiler/pio.py
_build_fbuild_batch timeout switched from fixed 1800s to a configurable batch_timeout from FASTLED_FBUILD_BATCH_TIMEOUT_SECS, defaulting to 3600s.
Fallback message generalization
ci/compiler/pio.py
The fallback message printed when fbuild cannot support "ci"/"compile-many" is generalized to remove explicit reference to the environment variable, making it purely descriptive of unavailability.
Test documentation and expectation update
ci/tests/test_fbuild_compile_many.py
Test comment is updated to document that compile-many is now default in _build_fbuild, and the batch-timeout expectation is changed from 1800s to 3600s with a note about FASTLED_FBUILD_BATCH_TIMEOUT_SECS.
Framework jobs defaulting
ci/util/fbuild_runner.py
default_fbuild_framework_jobs() now defaults framework job parallelism to min(cpu_count(), 2) when FASTLED_FRAMEWORK_JOBS is unset, while preserving the explicit env override path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I nudged the build to hop and run,
Compile-many waking with the sun.
Timeouts stretched and jobs spread wide,
Tests now nod and middleware’s tried.
Hooray — the CI garden grows with pride!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: flipping FASTLED_USE_FBUILD_CI to default-on with compile-many as the default behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/enable-fbuild-compile-many-by-default

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/compiler/pio.py`:
- Around line 451-453: The env parsing for FASTLED_USE_FBUILD_CI uses
raw.lower() but doesn't strip whitespace, so values like "0 " won't match;
update the parsing to strip whitespace before lowercasing (e.g., use
raw.strip().lower()) and keep the existing opt_out check (opt_out = raw in ("0",
"false", "no", "off")) so that raw is normalized for comparison; ensure you
update the variable `raw` or apply strip when computing `opt_out` where
`FASTLED_USE_FBUILD_CI`, `raw`, and `opt_out` are referenced in
ci/compiler/pio.py.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 92ecee0d-66a7-4cd0-9281-b1315f87cad6

📥 Commits

Reviewing files that changed from the base of the PR and between 4b6ede3 and ec1a5bb.

📒 Files selected for processing (2)
  • ci/compiler/pio.py
  • ci/tests/test_fbuild_compile_many.py

Comment thread ci/compiler/pio.py
Comment on lines +451 to +453
raw = os.environ.get("FASTLED_USE_FBUILD_CI", "").lower()
opt_out = raw in ("0", "false", "no", "off")
if not opt_out:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Strip whitespace before matching the opt-out values.

The raw value is lowercased but not stripped, so an inherited env value with surrounding whitespace (e.g. FASTLED_USE_FBUILD_CI="0 ") would not match the opt-out set and would silently enable compile-many — defeating the very "hostile inherited environment value" scenario the companion test comment cites as the rollback safety lever.

🛡️ Proposed fix
-        raw = os.environ.get("FASTLED_USE_FBUILD_CI", "").lower()
+        raw = os.environ.get("FASTLED_USE_FBUILD_CI", "").strip().lower()
         opt_out = raw in ("0", "false", "no", "off")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/compiler/pio.py` around lines 451 - 453, The env parsing for
FASTLED_USE_FBUILD_CI uses raw.lower() but doesn't strip whitespace, so values
like "0 " won't match; update the parsing to strip whitespace before lowercasing
(e.g., use raw.strip().lower()) and keep the existing opt_out check (opt_out =
raw in ("0", "false", "no", "off")) so that raw is normalized for comparison;
ensure you update the variable `raw` or apply strip when computing `opt_out`
where `FASTLED_USE_FBUILD_CI`, `raw`, and `opt_out` are referenced in
ci/compiler/pio.py.

The first esp32s3 / teensy41 CI runs on #2672 (gate flip merge candidate)
all timed out at the 1800s batch deadline. The log shows zero "stage2"
or "[stage" mentions — `fbuild ci` ran past 30 min while still in
stage 1. Root cause: default_fbuild_framework_jobs returned a hardcoded
1, so `--framework-jobs 1` made stage-1 framework compilation
single-threaded on the 2-core GitHub Actions runners. With ~150
framework files for esp32-arduino at a few seconds each on a single
core, stage 1 alone outlasts the batch timeout — the framework-archive
seed from FastLED/fbuild#337 never gets a chance to fan stage 2 out
across multiple sketches.

Switch to the same shape as default_fbuild_sketch_jobs: respect the
FASTLED_FRAMEWORK_JOBS env override when set; otherwise use
min(cpu_count, 2). The cap at 2 mirrors the fbuild orchestrator's own
default in crates/fbuild-build/src/compile_many.rs because framework
compilation is memory-heavy and we don't want to OOM a 2-core runner
trying to compile 16 framework objects in parallel.

This is intended to unblock the gate-flip in this branch by letting
stage 1 finish within the batch timeout on the platforms that
originally timed out.

Refs FastLED/fbuild#337
@zackees

zackees commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

Pushed a follow-up commit (b71843c) — default_fbuild_framework_jobs now mirrors the shape of default_fbuild_sketch_jobs and caps at min(cpu_count, 2) instead of the previous hardcoded 1.

Why: the first esp32s3 / teensy41 runs on this branch timed out at the 1800s batch deadline. The log has zero stage2 or [stage mentions — fbuild ci ran past 30 min still in stage 1. Root cause was --framework-jobs 1 making stage-1 framework compilation single-threaded on 2-core runners. With ~150 framework files for esp32-arduino at a few seconds each on a single core, stage 1 alone outlasts the timeout before #337's framework-share seed gets to fan stage 2 out.

Cap at 2 mirrors the fbuild orchestrator's own default_framework_jobs policy (framework compile is memory-heavy on small runners).

Re-running CI.

After bumping framework_jobs to 2 in b71843c, esp32s3 / teensy41 still
timed out at 1800s on this branch. The previous timeout was sized for
the per-sketch serial path; for the batched compile-many path the same
number has to cover stage-1 framework build + stage-2 fanout of every
sketch, which on 2-core GitHub Actions runners with a cold
esp32-arduino framework cache outlasts 30 min even with
framework_jobs=2.

Switch to a 60 min default, tunable via
FASTLED_FBUILD_BATCH_TIMEOUT_SECS for workflows that need to override
either direction (CI runner with frozen caches → lower it; fresh
runner on a beefier board → raise it).

Updated the timeout assertion in test_pio_compiler_build_prefers_ci_results
to match the new default with a comment explaining the rationale.

Refs FastLED/fbuild#337
@zackees

zackees commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

Pushed third commit d313f48 — batch timeout default raised from 1800s → 3600s, env-tunable via FASTLED_FBUILD_BATCH_TIMEOUT_SECS.

Where the previous one fell short: even with framework_jobs=2 (commit b71843c), the esp32s3 / teensy41 jobs still hit the timeout after 30 min with zero stage transitions logged — stage 1 alone outlasted 1800s on the 2-core GHA runners for a cold esp32-arduino framework cache. framework_jobs=2 halved the parallelism deficit but didn't recover the rest. The wrapper's 1800s timeout was sized for the legacy per-sketch serial path; the compile-many batched path now has to fit stage-1 framework + stage-2 fanout of every sketch into the same budget.

60 min should be plenty for any board's cold-cache batch. Workflows that get faster (warm cache after first save, or once we figure out a way to keep the daemon's framework artifacts across runs) can tune it lower.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
ci/compiler/pio.py (1)

451-453: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Strip whitespace before matching opt-out values.

The past review comment on these lines is still valid: the raw value is lowercased but not stripped, so an inherited env value with surrounding whitespace (e.g., FASTLED_USE_FBUILD_CI="0 ") would not match the opt-out set and would silently enable compile-many.

🛡️ Proposed fix
-        raw = os.environ.get("FASTLED_USE_FBUILD_CI", "").lower()
+        raw = os.environ.get("FASTLED_USE_FBUILD_CI", "").strip().lower()
         opt_out = raw in ("0", "false", "no", "off")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/compiler/pio.py` around lines 451 - 453, The opt-out check uses raw =
os.environ.get("FASTLED_USE_FBUILD_CI", "").lower() but doesn't strip
surrounding whitespace, so values like "0 " won't match; update the handling of
FASTLED_USE_FBUILD_CI (the raw variable and opt_out logic) to strip whitespace
before lowercasing (e.g., call .strip() then .lower() or strip raw before
membership test) so opt_out = raw in ("0","false","no","off") reliably detects
opt-out values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/compiler/pio.py`:
- Around line 575-577: The batch_timeout assignment converts
FASTLED_FBUILD_BATCH_TIMEOUT_SECS to float without validation; wrap the
conversion of os.environ.get("FASTLED_FBUILD_BATCH_TIMEOUT_SECS", "3600") in a
try/except around float() for the variable batch_timeout and raise a clear
ValueError if parsing fails (include the env var name and the invalid value in
the message) so failures are descriptive and fail fast instead of propagating a
generic exception.
- Around line 562-563: Remove the local imports "import os" and "import time"
from the middle of the module and instead ensure "os" (and not a duplicate
"time") is present in the file's top-level imports with the standard ordering
(standard library first, then third-party, then local); also remove any
duplicate top-level "time" import if it already exists and eliminate the
redundant local import at the later location (the other occurrence of a local
"os" import should be consolidated to the single top-level "os").

---

Duplicate comments:
In `@ci/compiler/pio.py`:
- Around line 451-453: The opt-out check uses raw =
os.environ.get("FASTLED_USE_FBUILD_CI", "").lower() but doesn't strip
surrounding whitespace, so values like "0 " won't match; update the handling of
FASTLED_USE_FBUILD_CI (the raw variable and opt_out logic) to strip whitespace
before lowercasing (e.g., call .strip() then .lower() or strip raw before
membership test) so opt_out = raw in ("0","false","no","off") reliably detects
opt-out values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3975258e-86c1-440e-b628-20f6fa0b1f1b

📥 Commits

Reviewing files that changed from the base of the PR and between b71843c and d313f48.

📒 Files selected for processing (2)
  • ci/compiler/pio.py
  • ci/tests/test_fbuild_compile_many.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • ci/tests/test_fbuild_compile_many.py

Comment thread ci/compiler/pio.py
Comment on lines +562 to 563
import os
import time

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Move imports to the top of the file.

These imports violate the coding guideline requiring all system imports to be at the top of the file in proper order (standard library, then third-party, then local). The time module is already imported at line 18, and os should be moved to the top-level imports as well (it's also locally imported at line 444).

♻️ Proposed fix

Remove the local imports here:

-        import os
-        import time
-
         from ci.util.fbuild_runner import _parse_size_info_from_log

And ensure os is added to the top-level imports (around line 11-23) if not already present.

As per coding guidelines: "All system imports must be at the top of the file in proper order: standard library, third-party, local".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/compiler/pio.py` around lines 562 - 563, Remove the local imports "import
os" and "import time" from the middle of the module and instead ensure "os" (and
not a duplicate "time") is present in the file's top-level imports with the
standard ordering (standard library first, then third-party, then local); also
remove any duplicate top-level "time" import if it already exists and eliminate
the redundant local import at the later location (the other occurrence of a
local "os" import should be consolidated to the single top-level "os").

Comment thread ci/compiler/pio.py
Comment on lines +575 to +577
batch_timeout = float(
os.environ.get("FASTLED_FBUILD_BATCH_TIMEOUT_SECS", "3600")
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate environment variable before float conversion.

The code converts FASTLED_FBUILD_BATCH_TIMEOUT_SECS to float without validation. If the environment contains an invalid value (e.g., "abc", "30.5.2"), float() will raise a generic ValueError at runtime. As per coding guidelines, critical configuration should fail fast with descriptive errors rather than silently propagating exceptions.

🛡️ Proposed fix
-        batch_timeout = float(
-            os.environ.get("FASTLED_FBUILD_BATCH_TIMEOUT_SECS", "3600")
-        )
+        batch_timeout_str = os.environ.get("FASTLED_FBUILD_BATCH_TIMEOUT_SECS", "3600")
+        try:
+            batch_timeout = float(batch_timeout_str)
+            if batch_timeout <= 0:
+                raise ValueError("Timeout must be positive")
+        except ValueError as e:
+            raise RuntimeError(
+                f"Invalid FASTLED_FBUILD_BATCH_TIMEOUT_SECS='{batch_timeout_str}': "
+                f"must be a positive number. {e}"
+            ) from e

As per coding guidelines: "Never use silent fallbacks for missing critical resources - always fail fast with descriptive errors".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/compiler/pio.py` around lines 575 - 577, The batch_timeout assignment
converts FASTLED_FBUILD_BATCH_TIMEOUT_SECS to float without validation; wrap the
conversion of os.environ.get("FASTLED_FBUILD_BATCH_TIMEOUT_SECS", "3600") in a
try/except around float() for the variable batch_timeout and raise a clear
ValueError if parsing fails (include the env var name and the invalid value in
the message) so failures are descriptive and fail fast instead of propagating a
generic exception.

@zackees

zackees commented Jun 1, 2026 •

Copy link
Copy Markdown
Member Author

Closing without merge — the compile-many gate flip is a net regression on the big-framework boards.

What we observed

Three CI attempts on this branch (with FASTLED_FRAMEWORK_JOBS defaulting to 1, then 2, with 1800s then 3600s wrapper timeout):

  • uno, wasm, unit/example tests: PASS (small-framework boards)
  • esp32s3: hit 30-min then 60-min timeout, never finished
  • teensy41: same pattern

Comparison against master (serial loop, FASTLED_USE_FBUILD_CI=0 default):

  • master esp32s3: ~24 min consistently across last 5 runs (24/24/27/47/24)
  • this PR esp32s3: still in_progress at 59 min → ~2.5× slower

uno finishes in ~2 min on this PR via compile-many vs ~5 min serial, so the framework-share seed (FastLED/fbuild#337) does work on small-framework boards. The regression is specific to ESP32-arduino and Teensy-arduino frameworks where stage-2 work dominates.

What didn't help

What needs to ship before re-trying this gate flip

Two follow-up fbuild issues filed:

Once #361 and #362 ship, we can re-attempt this gate with confidence on all boards.

@zackees zackees closed this Jun 1, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 1, 2026
@zackees
zackees deleted the chore/enable-fbuild-compile-many-by-default branch November 17, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant