Repository navigation
ci(optimization-report): cap stdout dump at 1 MiB to keep GHA runner alive - #2658
Conversation
…alive With `-fopt-info-all` applied across the full example matrix (~110 sketches on nrf52840_dk + Adafruit BSP boards), the per-board optimization_report.txt routinely exceeds 100 MB. The Optimization Report step in build_template.yml prints the entire file to the GitHub Actions log, which overruns the runner's log-buffer limit and triggers an external shutdown signal — see master CI for nrf52840_supermini (run 26705682359) and adafruit_feather_nrf52840_sense (run 26705682371) where the build step succeeded but Optimization Report cancelled at ~37s with the runner dying mid-step, leaving downstream cleanup steps unrun and the workflow marked FAILURE despite the build being green. Default to printing the LAST 1 MiB of the report (most-recently emitted optimizer info, which is what's most useful for size-driven debugging), with a `--max-bytes 0` escape hatch for the rare local case where the full dump is desired. Snap the tail to the next line boundary so we don't lead with a truncated half-line, and announce up front how many bytes were elided. Refs #2641, #2653. Counterpart to #2655 (which added timeout-minutes:5 to the Symbol Analysis + Optimization Report steps but couldn't help when the runner shutdown comes faster than the step timeout). Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe script adds a configurable byte cap for printing optimization_report.txt (env FL_OPT_REPORT_MAX_BYTES → default constant, overridable via --max-bytes). When the file exceeds the cap the script reads only the final bytes, advances to the next newline to avoid a partial first line, decodes safely, and prints a summary plus the tail. ChangesReport output limiting
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
…ow-up Address review feedback: - Allow FL_OPT_REPORT_MAX_BYTES env var to override the 1 MiB default so devs can bump it locally without editing the script. `0` disables the cap. The --max-bytes CLI flag still wins. - Document the durable fix (upload optimization_report.txt as a build artifact + print only a summary) as a follow-up so this PR remains a focused stop-gap. Co-Authored-By: Claude Opus 4.7 <[email protected]>
There was a problem hiding this comment.
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/optimization_report.py`:
- Around line 35-51: The parse_args function must accept an optional list[str]
parameter so tests can inject argv; update the signature of parse_args
(currently parse_args() -> argparse.Namespace) to parse_args(argv: list[str] |
None = None) -> argparse.Namespace, adjust the type hint accordingly, and pass
that argv into parser.parse_args(argv) when returning so existing behavior (None
uses sys.argv) is preserved; reference the parse_args function and the
parser.parse_args call in your change.
🪄 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: 80e1ab85-35cc-4b41-931b-438316fe2b23
📒 Files selected for processing (1)
ci/optimization_report.py
Address CodeRabbit comment on PR #2658: make parse_args / main accept an optional argv list[str] | None so tests can supply arguments deterministically. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Addressed in commit 11c013a: |
Today every non-AVR / non-esp32c2 board unconditionally gets `-fopt-info-all=<board>/optimization_report.txt` injected by ci/compiler/pio.py. The flag is APPEND-mode and writes a single file shared across every example in the matrix — for slow-link (no-LTO) boards with a large example set (nrf52840 + Adafruit BSP: ~110 examples × ~25-96 source files × hundreds of opt-info lines per TU) the file routinely exceeds 100 MB. When build_template.yml's Optimization Report step then dumps that file to the GitHub Actions log via `ci/optimization_report.py --first`, the per-step log buffer overruns and the runner is killed mid-step, masking already-successful builds. PR #2658 capped the log-side dump at 1 MiB as a stop-gap; this PR closes the source-side hole by making the GCC flag itself opt-in. Changes: - Add `Board.generate_optimization_report: bool = False` (default OFF) - ci/compiler/pio.py only injects `-fopt-info-all=...` when the board opts in (and still respects the esp32c2 / atmelavr suppression) - The linker map (`-Wl,-Map,firmware.map`) stays unconditional — it's a small per-example file and is consumed by size-analysis tooling Behavior for the Optimization Report workflow step is unchanged for opted-in boards. For non-opted-in boards the report file simply doesn't exist; `ci/optimization_report.py --first` already handles that case gracefully (prints a "No optimization report found" message and exits 0). Boards that need the report for size/perf debugging can opt in by adding `generate_optimization_report=True` to their `Board(...)` definition in ci/boards.py. Refs PR #2658. Co-authored-by: Claude Opus 4.7 <[email protected]>
Summary
-fopt-info-allwrites a per-board optimization report. Across the full example matrix (~110 sketches on nrf52840_dk + the other Adafruit-BSP boards), the report routinely exceeds 100 MB.build_template.ymldumps the entire file to the GitHub Actions log viaprint(text). This overruns the runner's log buffer and triggers an external runner shutdown signal.Verified failures on master SHA
a302c1ba:Fix
--max-bytes 0opts back into the full dump for local use.Counterpart to PR #2655
#2655 added
timeout-minutes: 5to Symbol Analysis + Optimization Report, but couldn't help when the runner shutdown arrives faster than the step timeout (the log-buffer overrun is faster than 5 minutes).Test plan
uv run ci/optimization_report.py --first --cwd /tmp/some/buildstill produces useful output for normal-sized reports (the cap is only enforced when the report exceeds 1 MiB).Refs #2641, #2653.
🤖 Generated with Claude Code
Summary by CodeRabbit