Skip to content

fix(memory): reduce ESP32 RMT HTTP and SPI storage - #4753

Merged
zackees merged 1 commit into
masterfrom
fix/memory-4738-esp32dev
Oct 7, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/memory-4738-esp32dev

Conversation

@zackees

@zackees zackees commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Refs #4738 and #4737. Parent #4737 must remain open.

  • Reuse RMT TX counters for the combined global pool, pack the pool flag into existing padding, and use FL_LOG_RMT for routine capability limits. Preserve dedicated pools, reservations, recovery and per-direction queries.
  • Initialize HTTP route ownership on actual use with static singleton storage; replace dynamic SPI host tracking with constant-initialized SDK-indexed storage while retaining the existing host policy.
  • Fix four pre-existing undefined-behavior failures exposed by strict sanitizer validation: integer minimum parsing/formatting, negative gradient shifts, signed Q15 conversion and stencil/damping shifts. Add signed wave and large-damping regressions.
  • Lower existing ESP32 flash ceiling and C3/C6 bloat budgets; add the ESP32 default flash/attributed-RAM budget.

Measurements

Matched current fbuild2.5.37, Arduino-ESP32 3.3.11 / IDF5.5.5 / Xtensa GCC14.2.0; normal default flags, no slim configuration.

ESP32 workload starting master flash/RAM candidate flash/RAM saving
published Blink 310880 / 26036 310428 / 25892 452 / 144
controlled RGB 296584 / 26028 296140 / 25884 444 / 144

3.10.3 matched published/control:271250/23370. Remaining candidate gaps:published39178/2522, controlled24890/2514. Default image flash313683→313231; attributed RAM34637→34489 (distinct from board RAM).

Shared published C3:403182/68524→402670/68388; C6:360434/18612→359834/18460. Local S3/STM/Uno Blink/Uno Apa102/Tiny builds preserve existing reductions. Exact controlled C3 result383802/65316; C6 result359584/18460, versus a fresh starting-HEAD rebuild360168/18596 (584/136 saved). Its baseline exactly reproduces the previously landed control, including keyed symbol sizes. Published and controlled savings are reported separately.

Validation and production paths

  • All builds/tests local, sequential, in the existing checkout; caches retained. CI Full was never invoked.
  • Default Blink and exact matched RGB sketch rebuilt and analyzed with fbuild bloat; focused RED→GREEN budgets retained.
  • Real ESP-IDF/QEMU RMT global/dedicated allocation, reservations, recovery, reset and accounting PASS on original/candidate.
  • Real HTTP loopback lifecycle PASS: GET, live route growth, restart, registration-failure cleanup. Production user:AutoResearchNet.
  • SPI original/candidate production ownership accounting PASS:two instances, exclusive acquisition, release/reacquisition, invalid/repeated releases. Temporary test friendship existed only in staged probes. SPI public hardware-initialization probe times out inside the SDK on both original and candidate; physical LED timing and successful hardware recovery are not claimed.
  • Strict UBSan acceptance:315 rerun units +4 previously strict-passed cached targets,95 host examples PASS. Focused pre-fix RED and post-fix GREEN for all four arithmetic defects. Full Python CI tests and lint PASS; git diff --check PASS.
  • Manual review of all18 changed/new files completed against repository review rules. No feature removed, new public API, new workflow, relaxed budget or new heap owner.

Summary by CodeRabbit

  • Performance

    • Reduced memory use across ESP32 RMT, HTTP, and SPI components, leaving more resources available for applications.
  • Bug Fixes

    • Improved handling of extreme integer values in parsing and formatting.
    • Corrected wave simulation behavior for negative values and high damping settings, with added coverage for these cases.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20023639-f071-4fc7-8568-3f020f4b3c28
📥 Commits

Reviewing files that changed from the base of the PR and between 8d8207f and 73b21d6.

📒 Files selected for processing (18)
  • .github/workflows/check_esp32_size.yml
  • agents/tasks/lessons.md
  • agents/tasks/todo.md
  • ci/lint/check_size_thresholds.py
  • docs/SIZE_THRESHOLD_HISTORY.md
  • src/fl/gfx/fill.cpp.hpp
  • src/fl/math/wave/wave_simulation_real.cpp.hpp
  • src/fl/stl/asio/http/server.cpp.hpp
  • src/fl/stl/charconv.cpp.hpp
  • src/fl/stl/strstream.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h
  • src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp
  • src/platforms/esp/32/drivers/spi/channel_driver_spi.h
  • tests/data/esp32c3_bloat_budget.json
  • tests/data/esp32c6_bloat_budget.json
  • tests/data/esp32dev_bloat_budget.json
  • tests/fl/math/wave/wave_simulation_real.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The pull request updates ESP32 memory accounting and storage, lowers the ESP32 size threshold, and records board budget measurements. It also changes arithmetic in graphics, wave simulation, integer parsing, and decimal formatting.

Changes

ESP32 Storage and Size Budgets

Layer / File(s) Summary
RMT shared-pool accounting
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h, src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp
Global-pool capacity and allocation totals now use TX ledger fields. Pool mode is stored on RmtMemoryManager; dedicated-pool accounting remains split between TX and RX.
SPI host tracking
src/platforms/esp/32/drivers/spi/channel_driver_spi.h, src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp
SPI host usage is tracked in a fixed array indexed by SDK host ID. Comments in the header and implementation also replace corrupted characters with readable text.
ESP32 HTTP route-context storage
src/fl/stl/asio/http/server.cpp.hpp
Route contexts are stored through a function-local accessor backed by fl::Singleton. Registration, failure cleanup, and shutdown use the accessor.
Size thresholds and recorded measurements
.github/workflows/check_esp32_size.yml, ci/lint/check_size_thresholds.py, docs/SIZE_THRESHOLD_HISTORY.md, tests/data/*bloat_budget.json, agents/tasks/lessons.md, agents/tasks/todo.md
The ESP32 size threshold changes from 340000 to 313231 bytes. ESP32 budget records and task notes are updated with measurements and validation details.

Arithmetic Edge Cases

Layer / File(s) Summary
Integer parsing and formatting
src/fl/stl/charconv.cpp.hpp, src/fl/stl/strstream.cpp.hpp
parseInt accumulates magnitudes using unsigned arithmetic. Negative decimal formatting computes the magnitude using unsigned subtraction.
Wave and graphics arithmetic
src/fl/gfx/fill.cpp.hpp, src/fl/math/wave/wave_simulation_real.cpp.hpp, tests/fl/math/wave/wave_simulation_real.cpp
Gradient and wave calculations replace signed left shifts with multiplication. Q15 conversion and damping logic are updated, with tests for signed conversions and large damping values.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 73b21

No identified issue needs resolution before merge; normal validation can proceed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.40% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 11 files. (7 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: reducing ESP32 RMT, HTTP, and SPI storage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 23.40% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 11 files. (7 skipped: 7 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit 003083f into master Oct 7, 2026
120 checks passed
@zackees
zackees deleted the fix/memory-4738-esp32dev branch November 5, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant