Skip to content

feat(bloat): capture per-config build logs in measure_esp32s3_opt_ins.py - #2939

Merged
zackees merged 2 commits into
masterfrom
feat/2938-measure-log-capture
Jun 7, 2026
Merged

zackees merged 2 commits into
masterfrom
feat/2938-measure-log-capture

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

Closes #2938 (partial). Adds .build/measure-logs/-{compile,bloat}.log capture so future measurement crashes are diagnosable. Refs #2886.

Summary by CodeRabbit

  • Documentation

    • Updated ESP32-S3 flash-size documentation with new measured results for baseline and optimized configurations
  • Tests

    • Enhanced measurement script with improved logging and per-configuration diagnostic files for better troubleshooting

zackees added 2 commits June 7, 2026 04:17
Closes #2935 (partial — 4 configs failed silently during the
measurement; the 6 successful configs flip the rows below).

Ran `tests/measure_esp32s3_opt_ins.py --config all` end-to-end against
`master @ f43f767`. The script's comparison table:

| Config | SLIM row | total_flash | Δ vs baseline |
|---|:---:|---:|---:|
| baseline | 1 | 339,962 B | +0 B |
| stage3 (sdkconfig overlay) | 2 | **280,738 B** | **−59,224 B** |
| stage4 (FASTLED_RMT_STATIC_ALLOCATION) | 3 | 339,054 B | −908 B |
| disable_ucs7604 | 7 | 336,158 B | **−3,804 B** |
| disable_dyndriver | 8 | 339,025 B | −937 B |
| disable_events | 9 | 331,928 B | **−8,034 B** |

## Headlines

- **Stage 3 alone hits the #2886 end-goal.** The
  `tools/sdkconfig_for_smallest_fastled.defaults` overlay drops
  total_flash to 280,738 B — within 738 B of the 280,000 B target.
  Adding `CONFIG_NEWLIB_NANO_FORMAT=y` to the overlay in #2916 was
  the dominant lever (~30-45 KB of the saving).
- **Three opt-in flags vastly exceeded projection** — `disable_events`
  delivered 4-8× projection (−8,034 B vs ~1-2 KB), `disable_ucs7604`
  delivered 6-9× (−3,804 B vs ~400-600 B). The dead-strip cascade
  pattern (see #2918 / #2925 / #2929 precedents) consistently
  delivers above projection when collapsing template-heavy machinery.

## What flipped 📊 → ✅

- Row 2 (overlay): −59,224 B measured. **Hits end-goal.**
- Row 3 (FASTLED_RMT_STATIC_ALLOCATION): −908 B measured (well
  below projection — the static-allocation path is mostly
  already-optimal post-Stage-1).
- Row 7 (FASTLED_DISABLE_UCS7604): −3,804 B measured.
- Row 8 (FASTLED_DISABLE_DYNAMIC_DRIVER): −937 B measured.
- Row 9 (FASTLED_DISABLE_CHANNEL_EVENTS): −8,034 B measured.

## What's still 📊

- Row 4 (FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT): the config
  failed silently during the measurement run — see follow-up.
- Row 5 (CONFIG_BT_ENABLED=n): no opt-in path in the current overlay
  (it's commented out per the user-side opt-in design).
- Row 6 (FASTLED_DISABLE_SPI_CHIPSETS): also failed silently.

The 4 missing configs (`stage2`, `stack`, `disable_spi`,
`max_savings`) need a separate troubleshooting pass. The output
redirection in the original measurement command discarded the
per-build error messages so the failure cause isn't visible. A
follow-up issue will rerun those with full output capture.

## Files

- docs/SLIM_ESP32S3.md:
  - Baseline table updated with the new measured default-flag number
    (339,962 B) and a callout that Stage 3 alone hits the end-goal.
  - Rows 2 / 3 / 7 / 8 / 9 flip 📊 → ✅ with measured deltas inline.

## Verification

- bash lint --cpp -> all C++ linting checks pass.
- The measured numbers in the doc are word-for-word the script's
  table output.

Refs #2886, #2935, #2906, #2934, #2916.
Closes #2938 (partial — script side).

Pre-#2938 the script ran `bash compile` / `bash bloat` for each config
and discarded the per-build stdout/stderr. When a config crashed
(see #2935 — 4 of 10 configs crashed on Windows with `extras+.cpp.o`
exit 3221225794), the failure cause was invisible. Without that
information, debugging required manual single-config reruns.

This PR routes every config's compile and bloat output through a
new `_run_with_log()` helper that writes to `.build/measure-logs/
<config>-{compile,bloat}.log` while tee'ing the same stream to the
operator's terminal. On any future crash the log file is the
diagnosable artifact.

## Files

- tests/measure_esp32s3_opt_ins.py:
  - New `_LOG_DIR` constant (`.build/measure-logs`).
  - New `_run_with_log(cmd, log_name)` helper that does combined
    stdout+stderr capture via subprocess.Popen + chunked read.
  - `run_compile` and `run_bloat` take a `config_name` parameter and
    delegate to `_run_with_log`.
  - `measure_one` passes `cfg.name` to both.

## Verification

- bash lint -> all linters pass (ruff, ty, C++, JS setup).
- Smoke test (`--config baseline`) produces a log file pair at
  `.build/measure-logs/baseline-compile.log` and
  `.build/measure-logs/baseline-bloat.log`.

## Known follow-up

The smoke test surfaced a separate issue: when consecutive runs use
the same build_flags + sdkconfig, PIO returns a cached ELF from a
prior run (potentially with different config). This is a build-cache
hygiene problem orthogonal to the log capture. To be addressed in a
future PR — possibly via `bash compile --clean` between configs or
an explicit invalidation of `.build/pio/esp32s3/.pio/build/`.

Refs #2886, #2938, #2935, #2906.
@zackees
zackees merged commit 73673d7 into master Jun 7, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Done to Triage in FastLED Tracker Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fadb2c3a-304a-4ba6-8396-d593ada18e1e

📥 Commits

Reviewing files that changed from the base of the PR and between 3f8bd9f and 4a92e19.

📒 Files selected for processing (2)
  • docs/SLIM_ESP32S3.md
  • tests/measure_esp32s3_opt_ins.py

📝 Walkthrough

Walkthrough

This PR enhances ESP32-S3 measurement diagnostics and updates flash-size documentation. The test script now captures per-config log files during compile and bloat measurements, and documentation reflects newly measured Stage 3 overlay and baseline flash sizes for the SLIM configuration.

Changes

Measurement Tooling and Results

Layer / File(s) Summary
Per-config measurement logging infrastructure
tests/measure_esp32s3_opt_ins.py
Added _run_with_log helper to stream and tee compile/bloat command output to per-config log files. Updated run_compile and run_bloat function signatures to accept config_name parameter and wired measure_one to invoke the new signatures while preserving early-return-on-failure control flow.
Updated baseline and flash-saver measurements
docs/SLIM_ESP32S3.md
Updated "Baseline & how to measure" table to report current default-flag build size (~339,962 B) and Stage 3 overlay-only size (~280,738 B). Refreshed "Release-build flash savers" table rows 2–9 with new measured and projected savings for sdkconfig overlay and FASTLED_* build flags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • FastLED/FastLED#2938: PR implements Option B request to tee stdout/stderr into per-config build logs via new _run_with_log wrapper and log file capture.
  • FastLED/FastLED#2935: PR updates the measurement script and documentation that this issue intends to run and refresh with new measured opt-in sizing results.
  • FastLED/FastLED#2886: PR directly updates ESP32-S3 bloat-reduction measurement tooling and documentation with Stage 3 results.
  • FastLED/FastLED#2895: PR updates documentation with measured Stage 3 overlay flash-size figures that relate to this issue's acceptance criteria.

Possibly related PRs

  • FastLED/FastLED#2930: Both PRs update ESP32-S3 baseline flash size (~339,962 B) in documentation and measurement baselines.
  • FastLED/FastLED#2936: Both PRs modify run_compile and run_bloat execution flow in tests/measure_esp32s3_opt_ins.py.
  • FastLED/FastLED#2937: Both PRs update docs/SLIM_ESP32S3.md with the same newly measured Stage 3 overlay flash-size figures.

Poem

A rabbit hops through logs so fine, 🐰
Stage 3 sizes now align,
Per-config captures tale by tale,
Flash and documentation sail!
Measurement dreams in bytes—we win! ✨

✨ 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 feat/2938-measure-log-capture

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.

zackees added a commit that referenced this pull request Jun 7, 2026
Closes #2940.

PIO's link step decides whether to relink based on object-file
timestamps, NOT on platformio.ini / sdkconfig changes. When the
script switched configs that affected only the sdkconfig (e.g.
stage3 → baseline), the previous config's ELF stayed on disk and
the downstream `bash bloat` step measured it.

Smoke test before this fix (after a prior stage3 run left an
overlay-built ELF on disk):

    uv run python tests/measure_esp32s3_opt_ins.py --config baseline
    → baseline reported 280,738 B  # WRONG — that's stage3's number

Smoke test after this fix (same starting state):

    uv run python tests/measure_esp32s3_opt_ins.py --config baseline
    → baseline reported 339,962 B  # CORRECT — matches the pinned
      tests/data/esp32s3_bloat_baseline.txt

The fix: a tiny `_force_relink()` helper deletes
`.build/pio/esp32s3/.pio/build/esp32s3/firmware.elf` (if present)
before each compile. Object cache stays intact for speed; only the
link step is forced.

## Files

- tests/measure_esp32s3_opt_ins.py:
  - New `_ELF_PATH` constant.
  - New `_force_relink()` helper.
  - `measure_one()` calls it after patching platformio.ini, before
    running compile.

## Verification

- `bash lint` -> all linters pass (ruff, ty, C++, JS setup).
- Smoke test produces 339,962 B for baseline — matching pinned.

Refs #2886, #2940, #2939, #2935.
@zackees
zackees deleted the feat/2938-measure-log-capture branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Rerun measure_esp32s3_opt_ins.py 4 Windows-crashed configs on Linux to flip remaining SLIM rows (#2886)

1 participant