Size reports - #116
Conversation
Implement a size-check
* Log the OpenThread version when the instance is initialized Also a small, deliberate flash size increase to exercise the size report on pull requests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Size report: one report across all MCUs, listing every region and section Each MCU leg now emits a JSON measurement; a final job renders all of them as one report with the increases above the threshold, all regions and all sections, so that a change can be compared across chips. Unchanged sections are listed too. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Size report: measure all examples, not only basic_udp Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
|
@bjoernQ Ready for review. I'm a bit concerned with Fable saying "esp-hal's bloaty filter drops .rodata entirely". Could that really be the case? |
There was a problem hiding this comment.
🔵 Needs a closer look
The changes add security-sensitive workflow_run CI with write permissions and depend on an elfsize tool whose publishing state is unverifiable here, so human review is warranted.
Pull request overview
This PR adds automated firmware size reporting to CI, inspired by rs-matter's size reporting. It introduces two workflows that build each MCU family's examples at both the PR's merge commit and the base branch, measure the ELFs with the new elfsize tool, and post a single consolidated diff comment on the PR using a fork-safe workflow_run pattern. It also adds the OpenThread version string to the initialization log line.
Changes:
- New
size.ymlworkflow: builds examples for esp32c6/esp32h2/nrf52840 at head and base, measures withelfsize, and uploads a report artifact. - New
size-comment.ymlworkflow: runs onworkflow_runcompletion with a write token to post/update the size report as a PR comment without executing PR code (fork-safe). lib.rs: logs the OpenThread version string alongside the existing "instance initialized" message.
File summaries
| File | Description |
|---|---|
.github/workflows/size.yml |
Adds the build-and-measure job matrix plus a report job producing the size artifact. |
.github/workflows/size-comment.yml |
Adds the fork-safe workflow_run job that posts/updates the size report PR comment. |
openthread/src/lib.rs |
Enriches the initialization log with the OpenThread version via Self::version(). |
Key notes: The lib.rs change is correct (version() returns &'static str). The main issues found are an inline comment in size.yml that describes installing elfsize from a git branch while the command uses cargo install elfsize (crates.io) — which fails if the crate is unpublished — and a hardcoded 0.2% threshold in size-comment.yml that duplicates SIZE_WARN_PERCENT.
Review details
Suppressed comments (1)
.github/workflows/size.yml:154
- Same inconsistency as in the
sizejob: the comment states elfsize is "Not yet published" and "built from thesize-checkbranch of embuild", but the commandcargo install elfsizeinstalls the published crate from crates.io. If the crate is not published this step fails; otherwise the comment is stale. Reconcile the comment and the command.
# Not yet published; until then, built from the `size-check` branch of embuild
- name: Install elfsize
run: cargo install elfsize
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
I'm not too familiar with bloaty but at least it's not listed in https://github.com/esp-rs/esp-hal/blob/e88f8cee26b3bd49449370ebeb9ae7dc18a202a3/.github/workflows/binary-size.yml#L197 Also not sure if we need to do something about e.g. @JurajSadel might be worth double checking! |
Thanks, will open a similar one for |
This is inspired by the
rs-matter(and Matter C++ SDK) size reporting which I find quite nice.See how it looks here.
But rather than relying on a 3K LOCs of Python code copied from Matter C++ (as
rs-matterstill does), this PR uses a newelfsizecommand installable withcargo install elfsizeand maintained in theembuildutility.Here, a comparison with
cargo size.How this differs from esp-hal's
/test-size(I asked Fable to compare, let me know if something is off.)
Same core idea (build base and head in one job, diff the ELFs, comment), with these changes:
workflow_runjob posts the comment from the base repo. No/test-sizecommand, no trust list.pull_request.base.sha. esp-hal diffs againstmainHEAD at dispatch time, which picks up unrelated changes whenmainhas moved.PT_LOADsegments, i.e. the actual flash image. esp-hal's bloaty filter drops.rodataentirely. RAM is a section prefix list, with.stackexcluded because esp-hal sizes it as "whatever is left".elfsizecrate from embuild, ~300 lines of Rust overxmas-elf, installed withcargo install elfsize. No bloaty action, nollvm-tools(which the espup Xtensa toolchain lacks).