Repository navigation
perf(esp32): reuse the converted firmware image across fresh projects - #1902
Merged
Merged
Conversation
A fresh project directory whose objects are byte-identical to a previous build now restores firmware.elf from the link-output cache (#1900), but the remaining phase was `esptool elf2image`: 391 ms of a 1332 ms build, ~29% of the total and the largest phase left (#1894). firmware.bin is a pure function of the linked ELF plus the flash parameters handed to esptool, and the ELF is already byte-identical across directories (verified by md5), so the converted image is reusable verbatim. This caches it beside the link-output cache, keyed on the ELF *contents* plus chip, flash mode/frequency/size and the esptool binary identity; a hit copies the image and skips the esptool spawn entirely. The restore also records the per-project bin cache, so the next build in that directory takes the cheap path too. Measured on one host with a warm framework cache, fresh ESP32-S3 blink dirs (2.5.51, branch vs main): link-convert 391 ms -> 4 ms, build total 1332 ms -> 845 ms, identical firmware.bin md5 across every directory.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Closes the remaining ~29% of a fresh-project ESP32 build. Follow-up to #1900 (link-output cache), part of #1894.
What was left
With #1900 merged, a fresh directory restores
firmware.elfand the phase table on a warm-cache fresh dir is:link-restorelink-convert(esptool elf2image)link-sizelink-convertis the largest single phase left.firmware.binis a pure function of the linked ELF plus the flash parameters passed to esptool, and the ELF is already byte-identical across fresh directories (verified bymd5sum), so the converted image is reusable verbatim.Change
New
esp32/firmware_bin_cachemodule, consulted byEsp32Linker::convert_firmwareafter the per-project cache misses and before esptool is spawned:esptool), so any input that changes the emitted bytes changes the key;EXDEV-safe fallback) and records the per-project.firmware_bin_cache.json, so the next build in that directory short-circuits before the shared cache;<cache>/link-output/firmware-bin, i.e. the existing link-output cache root — no new plumbing at thebuild.rscall site.Measured
Same host, warm framework cache, fresh ESP32-S3 DevKitC-1 blink directories (2.5.51, branch vs
main):link-convertfirmware.binmd59f1e391a…9f1e391a…(identical)Store path re-verified after the final refactor (fresh dir, cache cleared): convert 413 ms + entry written, next fresh dir convert 4 ms, same image.
Tests / gates
convert_firmwarereuses without spawning esptool (the linker is given a non-existent esptool binary, so any spawn would fail);0 passed; 1 failed);fbuild-build-esp --lib: 218 passed / 0 failed / 1 ignored;soldr clippy --workspace --all-targets -- -D warnings: rc 0;soldr fmt --check: rc 0; test layout, dylint allowlists and platform boundary (rows=44; dylint_rows=43) all rc 0.