Repository navigation
size: drop the cross-project size cache, warn on missing RAM sections, real Teensy 3/Renesas tables - #2065
Merged
Conversation
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).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This was referenced Nov 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 nosize/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):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 plusSIZE_REPORT_VERSION, astatrather than a hash) and thefirmware-bincache, which still avoids anesptool elf2imagespawn. Existingfirmware-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_missingreports when no allocated section has one of the platform's RAM names. A present but empty.bssis 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) andesp32_report_size.Why a warning and not an error: the link has already succeeded, and the linker script's own
> RAMregions andASSERTs 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 inenforce_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 -Soutput fromFBUILD_DEV_MODE=1 fbuild build --cleanblink builds (teensy31,uno_r4_minima), using the cachedtoolchain-gccarmnoneeabi9.2.1 readelf. PlatformIO'sSIZEDATAREGEXPapplied tosize -Aof the same ELFs gives the same RAM that fbuild reports:SIZEDATAREGEXPsections.usbdescriptortable .dmabuffers .usbbuffers .data .bss .noinit .text.itcm .text.itcm.padding.data .bss .noinit(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_platformiofbuild-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(usestracing-test, which is already a workspace dependency)fbuild-build-esp:esp32_report_size_warns_without_dram_sectionsfbuild-build-arm:teensy31_real_blink_ram_matches_platformioLocal: clippy
-D warningson the four crates,cargo fmt --check, dylint on core/engine/esp, unit tests for the four crates.