Skip to content

fix(memory): reduce Uno RGB controller and banner footprint - #4751

Merged
zackees merged 1 commit into
masterfrom
fix/memory-4742-uno
Oct 7, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/memory-4742-uno

Conversation

@zackees

@zackees zackees commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Refs #4742 and #4737. Close only the platform child after landed verification; the meta issue stays open.

  • Store EOrderW and RGBW_MODE selectors in one byte, preserving all named ordinals, fields and supported modes. RGBWW selectors already use this representation.
  • Compute (correction + 1) * brightness first in 16 bits (maximum 65280), then multiply by (temperature + 1) in 32 bits. This is the same exact product/division and rounding; zero handling and NO_CORRECTION stay intact.
  • Keep Blink's full Serial banner in AVR flash through Arduino F literals. Combine the first three lines with their original CRLF bytes. No Serial/output/LED/power feature removed.
  • Add scoped image-flash/attributed-RAM budgets for both Uno examples; lower existing Uno workflow/frozen ceilings and shared C3/C6/STM budgets. No new workflows or raised ceilings.

Matched local measurements

All entries below are fbuild board flash / board RAM bytes, not symbol-attributed RAM. Normal default flags, no slim/size opt-ins. fbuild 2.5.37. Same cached board project in this checkout, no git worktrees; board builds run sequentially. Candidate source commit 81c9a6f694dcf031fdab59dcb9edd4e068bdc165. Starting master 28a41d619f8a51952ef4e9fea127ac8eb10f45f9; historical source 20667c3a6413ed46a828f78ec95fb57e58d753f8 (3.10.3). Historical examples use their own revision; tooling/framework/config stay matched. The generated historical Arduino stub uses ::delay(0) solely because 3.10.3 lacks fl::delay.

Uno workload 3.10.3 starting master candidate saved flash / RAM remaining gap to 3.10.3
published Blink 3784 / 131 5158 / 629 5138 / 443 20 / 186 +1354 / +312
published Apa102 3178 / 187 3682 / 326 3650 / 324 32 / 2 +472 / +137
controlled RGB 3784 / 131 3942 / 268 3922 / 266 20 / 2 +138 / +135

Controlled sketch: one NEOPIXEL at GPIO3, red/black show and delay(1000), no Serial. Serial/HardwareSerial remain absent in the Apa102/control symbol reports. Blink retains Serial.begin(115200), all messages, and the same bytes including CRLF and UTF-8 status marker. Library reductions therefore appear independently of the banner change.

Uno toolchain: AVR GCC 7.3.0-atmel3.6.1-arduino7, Arduino AVR core 5.4.0, ATmega328P 16 MHz. Report source SHA before committing describes the starting tooling checkout; the candidate uses this PR's dirty source, then its head commit. Reports claiming historical source are identified by the archived library source, not that metadata SHA.

Symbol evidence / enforceable metrics

  • Apa102 removes 22 B __muluhisi3 and shrinks linked CRGB::computeAdjustment by 10 B. Controller static storage shrinks 2 B. Controlled RGB removes the same helper and shrinks its controller by 2 B; its adjustment caller grows 2 B, yielding the net 20 B flash saving.
  • Blink moves 186 B of literal storage into AVR flash. Its str1.1 RAM pool shrinks 184 B and the controller shrinks 2 B. Flash Print overload costs are included in the measured net 20 B flash reduction.
  • Blink image_flash / attributed RAM: 5158 / 624 → 5138 / 438. Apa102: 3682 / 292 → 3650 / 290. Controlled: 3942 / 262 → 3922 / 260.
  • Scoped budgets use these image/attributed metrics. Attributed RAM does not equal board RAM, and the historical Blink/control attribution includes 153 B despite the board total being 131 B. Never mix these metrics.
  • Renamed/folded constructor symbols can appear as entire additions/removals; ledger totals and image/board measurements govern the savings claim.

Shared effects (published Blink)

board before candidate additional saved flash / RAM new image_flash / attributed RAM ceiling
esp32c3 403210 / 68540 403182 / 68524 28 / 16 385568 / 25621
esp32c6 360474 / 18612 360434 / 18612 40 / 0 403754 / 29888
stm32f103c8 26356 / 3480 26324 / 3472 32 / 8 26324 / 1924

Controlled shared results: C3 384342 / 65468 → 384314 / 65452; C6 360208 / 18596 → 360168 / 18596; STM 25524 / 3480 → 25496 / 3472. C6 singleton RAM remains omitted from symbol attribution; its previously landed 2048-byte encoder-storage assertion remains in place. Framework/toolchain pins: C3 Arduino 3.1.0 / IDF 5.3.2 / GCC 13.2.0; C6 Arduino 3.3.5 / IDF 5.5.1 / GCC 14.2.0; STM32duino 2.9.0 / GCC 15.2.1.

Behavior and local validation

  • RED before code: original RGBW selector-size test fails, including immediate debug rerun; original Uno reports exceed both final image/RAM budgets. Earlier focused image ceiling evidence is RED before the arithmetic optimization.
  • GREEN: independent unsigned 64-bit reference tests every correction/temperature pair (65,536), at brightness 0, 1, 127, 254 and 255, with zero channels/full-scale boundaries under sanitizers. Test also passed against original arithmetic before changes.
  • Full local native gate: 319/319 unit targets and 95/95 host examples pass, including white-channel/color-profile/power-limiter coverage.
  • bash lint passes; manual /code-review rules applied to every changed file, no blocking findings. No ownership/threading/driver/ISR/timing changes.
  • Uno compiler cache validity: changed generated translation units with compile-only assertions, then wrapper clean rebuilds, reproduced published Blink 5138/443 and Apa102 3650/324. No compiler flags or runtime work added; toolchain/framework/cache directories retained.
  • bash bloat reports collected for all historical/starting/candidate workloads. CLI scoped budgets pass; starting reports are RED for both flash and RAM.
  • AVR logging audit: no fl::printf logging in AVR implementation. Existing ISR/controller FL_WARN sites describe invalid configuration, allocation failure or unsupported operations and are absent in default small-memory builds; preserve those diagnostics. RMT/PARLIO optimization remains covered by the earlier completed platform children and shared local measurements.
  • No CI Full invoked, no platform CI labels requested. Platform evidence is local.

Commands: bash compile <board> --examples <example>, bash bloat <board> --example <example> --no-summary, bash bloat uno --example Blink --budget tests/data/uno_blink_bloat_budget.json, bash bloat uno --example Apa102 --budget tests/data/uno_apa102_bloat_budget.json, bash test fastled_core --debug, bash test tests/fl/gfx/rgbww.cpp --debug, bash test --cpp, bash lint. Historical/control staging uses the same fbuild runner wrapper with clean=True, preserving caches.

Artifacts retained locally in .build/memory-4737/uno/: historical/starting/candidate report.json/report.md files, build/bloat logs, symbol ledger, provenance, RED/GREEN budgets, exact banner proof, sanitizer/native/lint logs and manual review.

Compatibility

All defined selector values and supported RGB/RGBW/RGBWW behavior remain. Narrowing selector storage changes Rgbw/controller ABI/layout: rebuild applications and the library together. No prebuilt binary ABI compatibility is claimed. Classic RGB EOrder remains unchanged.

Summary by CodeRabbit

  • Improvements
    • Reduced measured flash usage for Uno Blink and APA102 builds, with updated size limits of 5,138 and 3,650 bytes.
    • AVR Blink examples now store printed messages in flash, helping preserve RAM.
    • Refined color adjustment calculations while maintaining expected results across correction, temperature, and scale values; flash usage also decreased on several tested boards.

@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: 876a42ca-192e-41f4-81c6-aa066b983e06
📥 Commits

Reviewing files that changed from the base of the PR and between 28a41d6 and 81c9a6f.

📒 Files selected for processing (15)
  • .github/workflows/check_uno_size.yml
  • agents/tasks/todo.md
  • ci/lint/check_size_thresholds.py
  • docs/SIZE_THRESHOLD_HISTORY.md
  • examples/Blink/Blink.ino
  • src/crgb.cpp.hpp
  • src/fl/gfx/eorder.h
  • src/fl/gfx/rgbw.h
  • tests/data/esp32c3_bloat_budget.json
  • tests/data/esp32c6_bloat_budget.json
  • tests/data/stm32f103c8_bloat_budget.json
  • tests/data/uno_apa102_bloat_budget.json
  • tests/data/uno_blink_bloat_budget.json
  • tests/fastled_core.cpp
  • tests/fl/gfx/rgbww.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 change updates RGBW enum representations, adjustment arithmetic, and AVR Blink string handling. It adds tests and size-budget records, and lowers the Uno Blink and Apa102 size thresholds.

Changes

Uno size ratchet

Layer / File(s) Summary
Compact code implementation
src/fl/gfx/eorder.h, src/fl/gfx/rgbw.h, src/crgb.cpp.hpp, examples/Blink/Blink.ino
EOrderW and RGBW_MODE now use u8 as their underlying type. CRGB::computeAdjustment uses a 16-bit intermediate before its 32-bit multiplication. AVR builds use F()-wrapped strings for the Blink messages.
Validation and size budgets
tests/fastled_core.cpp, tests/fl/gfx/rgbww.cpp, tests/data/*_bloat_budget.json
Tests cover adjustment results and RGBW enum sizes and values. Uno Blink and Apa102 budget records are added; ESP32-C3, ESP32-C6, and STM32F103C8 budgets are updated.
Thresholds and tracking
.github/workflows/check_uno_size.yml, ci/lint/check_size_thresholds.py, docs/SIZE_THRESHOLD_HISTORY.md, agents/tasks/todo.md
Uno Blink and Apa102 thresholds change to 5138 and 3650. The history and task checklist record the Uno measurements and platform status.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 81c9a

The compact selectors, adjustment arithmetic, and AVR banner changes have no established behavior regression; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 7 files. (8 skipped: 8… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: reducing the Uno RGB controller and Blink banner footprint.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 7 files. (8 skipped: 8 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.

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