Repository navigation
Description
Goal
Ensure tests/measure_esp32s3_opt_ins.py always produces the ELF that matches the current config's build_flags + sdkconfig, even when consecutive configs share build state. The smoke test on PR #2939 surfaced a case where running --config baseline after a prior stage3 run returned the prior config's ELF (280,738 B reported instead of the expected 339,962 B baseline).
Parent: #2886 — measurement-script hygiene.
Root cause hypothesis
PIO's build cache returns cached object files keyed on source content + compile flags. When the script switches between configs that share most object files (the entire FastLED library + Arduino-ESP32 framework), the link step pulls cached .o files and produces an ELF. If the script's call sequence (build → bloat) doesn't invalidate the previous ELF before the new build, the bash bloat esp32s3 step may run against the stale ELF if PIO's link decided no relink was needed.
Specifically: when transitioning stage3 → baseline, the only change is the sdkconfig overlay (which affects ESP-IDF compilation, not FastLED). PIO's PSRAM-aware build may decide the ELF is up-to-date and skip the relink, leaving the stage3 ELF in place even though the sdkconfig path changed.
Deliverable
tests/measure_esp32s3_opt_ins.py — force-delete the prior ELF before each compile
def measure_one(cfg: OptInConfig, example: str) -> int | None:
print(f"\n=== measure-opt-ins: config {cfg.name} ({cfg.label}) ===", flush=True)
restore_platformio_ini(keep_backup=True)
patch_platformio_ini(cfg)
+ # Force PIO to relink even if no source-file timestamps changed.
+ # The sdkconfig overlay switch (stage3 ↔ baseline) doesn't always
+ # propagate to PIO's link-decision logic, so without an explicit
+ # ELF delete the bloat step may measure the previous config's
+ # binary. See #2940.
+ elf_path = PROJECT_ROOT / ".build" / "pio" / "esp32s3" / ".pio" / "build" / "esp32s3" / "firmware.elf"
+ if elf_path.is_file():
+ elf_path.unlink()
if not run_compile(example, cfg.name):Deleting the ELF before each compile forces PIO's link step to actually run, even if all object files are cached. The objects are still cache-hit (so the compile is fast), but the link uses the current platformio.ini's link order and sdkconfig.
Optional follow-up: snapshot platformio.ini per config
If the cache invalidation alone doesn't fix the smoke-test discrepancy, save a copy of the patched platformio.ini to .build/measure-logs/<config>-platformio.ini for diagnostic purposes. Defer until after the primary fix.
Acceptance
tests/measure_esp32s3_opt_ins.py --config baselineproduces 339,962 B (the pinned baseline fromtests/data/esp32s3_bloat_baseline.txt).- Running
baselineafter a successfulstage3run produces the baseline number, not stage3's 280,738 B. bash lintpasses.
Out of scope
- Reworking the entire script to compute
total_flashfrom.build/symbols/esp32s3/report.jsonfor the just-built ELF rather than the latest-on-disk ELF. The current per-config archival toreport.<config>.jsonis sufficient for post-hoc analysis. - Migrating away from
bash compile's PIO cache. The PIO cache is the right speed/correctness trade-off; we just need to invalidate the link step.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta.
- tools(bloat): ship tests/measure_esp32s3_opt_ins.py multi-config audit driver #2906 / tools(bloat): extend measure_esp32s3_opt_ins.py with 4 new opt-ins + max_savings #2934 / fix(bloat): make measure_esp32s3_opt_ins.py work on Windows #2936 / feat(bloat): capture per-config build logs in measure_esp32s3_opt_ins.py #2939 — measurement-driver evolution.
- Run measure_esp32s3_opt_ins.py end-to-end + flip SLIM rows 2/4/6/7/8/9 to ✅ (#2886) #2935 — original measurement-run issue.
- docs(esp32): flip SLIM rows 2/3/7/8/9 to ✅ with measured numbers (#2935) #2937 — partial SLIM doc flip (5 of 9 actionable rows).
- Rerun measure_esp32s3_opt_ins.py 4 Windows-crashed configs on Linux to flip remaining SLIM rows (#2886) #2938 — Linux rerun follow-up for the 4 Windows-crashed configs.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(bloat): force ELF delete before each measure-opt-ins compile (Fas…