Skip to content

size: drop the cross-project size cache, warn on missing RAM sections, real Teensy 3/Renesas tables - #2065

Merged
zackees merged 3 commits into
mainfrom
fix/size-followups-2042
Nov 17, 2026
Merged

zackees merged 3 commits into
mainfrom
fix/size-followups-2042

Conversation

@zackees

@zackees zackees commented Nov 17, 2026

Copy link
Copy Markdown
Member

Part of #2042 (size group). Three items, three commits.

1. Delete the cross-project size report cache (#1894)

The #1894 size cache was ESP32-only: crates/fbuild-build-esp/src/esp32/size_report_cache.rs, stored under <link-output cache>/firmware-size, keyed on SHA-256(whole ELF) + SIZE_REPORT_VERSION. Since #2021/#2023 the report is computed in-process from the section headers, with no size/objcopy/esptool spawn, so the cache was not saving a subprocess any more.

Measured on real FastLED ELFs (release build, warm page cache, mean of 30 iterations; hit = content_key + restore, compute = read_elf_section_sizes + classify):

ELF bytes cache hit compute
esp32c6 17,122,580 13.77 ms 7.49 ms
esp32s3_n16r8 15,176,188 11.94 ms 7.11 ms
esp32s3 6,246,520 5.13 ms 1.20 ms
esp32dev 5,261,684 3.85 ms 1.32 ms
esp32c3 5,251,640 4.20 ms 0.98 ms
nrf52840_dk (for scale) 162,340 0.24 ms 0.03 ms

On ESP32 ELFs a hit cost 1.7–4.3x as much as computing the report, and a miss paid the hash on top. Deleted the module, its tests, the linker hooks and the README entry.

Kept: the per-project .firmware_size_cache.json (keyed on a file stamp plus SIZE_REPORT_VERSION, a stat rather than a hash) and the firmware-bin cache, which still avoids an esptool elf2image spawn. Existing firmware-size/ directories in user caches are now unused (capped at 4 MiB) and nothing removes them.

2. RAM 0 bytes: warn, don't fail

fbuild_core::ram_sections_missing reports when no allocated section has one of the platform's RAM names. A present but empty .bss is a real 0 and is not reported. Both size-report entry points log the warning with the expected section list and the ELF path: report_size_with_ram (every section-header platform: generic ARM/AVR, Teensy, ESP8266, CH32V) and esp32_report_size.

Why a warning and not an error: the link has already succeeded, and the linker script's own > RAM regions and ASSERTs still bound the layout. The firmware is valid; only fbuild's report is incomplete. Failing would break a working build because fbuild's section table has a gap. Fail-fast is about not degrading silently, and the warning means it isn't silent: it says RAM is reported as 0 and the RAM limit is not checked. This matches the existing non-fatal RAM-overflow warning in enforce_size_limits. No real ELF checked so far triggers it.

3. Real section tables for Teensy 3 and Renesas

I replaced the made-up tables with arm-none-eabi-readelf -S output from FBUILD_DEV_MODE=1 fbuild build --clean blink builds (teensy31, uno_r4_minima), using the cached toolchain-gccarmnoneeabi 9.2.1 readelf. PlatformIO's SIZEDATAREGEXP applied to size -A of the same ELFs gives the same RAM that fbuild reports:

env PlatformIO SIZEDATAREGEXP sections RAM
teensy31 teensy: .usbdescriptortable .dmabuffers .usbbuffers .data .bss .noinit .text.itcm .text.itcm.padding 160+444+864+272+1120 = 2860
uno_r4_minima renesas-ra: .data .bss .noinit 140+28+3972 = 4140

(teensy36 was also checked: 3208, matching.)

Tests

  • fbuild-core: missing_ram_sections_are_reported, present_but_empty_ram_section_is_not_reported, unallocated_ram_named_section_is_still_missing, renesas_real_blink_ram_matches_platformio
  • fbuild-build-engine: report_size_warns_when_no_ram_section_is_present (failed before the change), report_size_does_not_warn_when_ram_sections_are_present (uses tracing-test, which is already a workspace dependency)
  • fbuild-build-esp: esp32_report_size_warns_without_dram_sections
  • fbuild-build-arm: teensy31_real_blink_ram_matches_platformio

Local: clippy -D warnings on the four crates, cargo fmt --check, dylint on core/engine/esp, unit tests for the four crates.

The #1894 `firmware-size` cache keyed each ESP32 size report on a SHA-256 of
the whole ELF. Since #2021/#2023 the report is computed in-process from the
section headers, which is cheaper than the key alone. Release build, warm page
cache, mean of 30 runs on real FastLED ELFs:

  ELF (bytes)            cache hit   compute
  esp32c6     17122580    13.77 ms   7.49 ms
  esp32s3_n16r8 15176188  11.94 ms   7.11 ms
  esp32s3      6246520     5.13 ms   1.20 ms
  esp32dev     5261684     3.85 ms   1.32 ms
  esp32c3      5251640     4.20 ms   0.98 ms

A miss paid the hash on top of the computation. The per-project
`.firmware_size_cache.json` (stat-keyed, SIZE_REPORT_VERSION) stays; the
`firmware-bin` elf2image cache, which avoids an esptool spawn, stays.

Part of #2042 (size group).
The Teensy 3 and Renesas RAM tests from #2052 used section tables written
from the linker scripts. Replace them with `arm-none-eabi-readelf -S` of
dev-mode `--clean` blink builds (teensy31, uno_r4_minima). PlatformIO's
SIZEDATAREGEXP applied to `size -A` of the same ELFs gives 2_860 (teensy)
and 4_140 (renesas-ra) bytes of RAM, which is what fbuild reports.

Part of #2042 (size group).
Since #2052 RAM is the sum of the platform's named sections (PlatformIO's
SIZEDATAREGEXP set). A linker layout with none of them reported 0 bytes of
RAM with no hint, and the RAM limit check passed vacuously.

`fbuild_core::ram_sections_missing` detects the case (no *allocated*
section with a RAM name; a present but empty `.bss` is a real 0), and the
two size-report entry points (`report_size_with_ram` for every
section-header platform, `esp32_report_size` for ESP32) log a warning
naming the expected sections and the ELF.

Warning, not error: the link already succeeded and the linker script's own
`> RAM` regions and ASSERTs still bound the layout, so the firmware is fine
and only the report is incomplete. Failing would break a working build over
a gap in fbuild's section table. The warning keeps it from being silent.

Part of #2042 (size group).
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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.

1 participant