Repository navigation
Closed
Labels
sanitizedTitle, body and conversation screened; review text requires separate screening.
Description
Sub-issue of #5375 (meta), part of #5356. Found while doing #5377.
Problem
#5358 (RGB) and #5377 (RGBW/RGBWW) moved the legacy addLeds encode off the per-pixel type-erased PixelIterator. The channel API (FastLED.add(ChannelConfig), Channel::encodeWS2812 in src/fl/channels/channel.cpp.hpp) still encodes plain RGB one pixel at a time:
ReorderingPixelIteratorAny→PixelIterator::writeWS2812()→makeScaledPixelRangeRGB→ScaledPixelIteratorRGB::advance();- per pixel, that is four type-erased calls (has, loadAndScaleRGB, stepDithering, advanceData) plus three capacity-checked
back_inserterappends.
The other ScaledPixelIteratorRGB encoders (APA102, SK9822, TM1908, UCS7604, ...) share the same per-pixel cost. On the legacy path, the same change took show() from 357 to ~219 µs (#5357).
AutoResearch has no channel-API latency measurement, so the cost isn't measured yet.
Fix
- Measurement first: a channel-API mode for
timingDriftTest("api": "channel") that adds the same 35-LED strip withFastLED.add()instead ofaddLeds, sofl::InstructionCounterreports instructions pershow()for that path. - Bulk RGB load in
PixelIterator: aloadScaledRGBBulkthunk (load + scale + dither step + advance for a run of pixels, one type-erased call per run), with the iterator's colour order applied over the run. - Encoders:
writeWS2812()for RGB uses it directly. If it pays for itself,ScaledPixelIteratorRGBrefills from it in runs, so APA102/SK9822/TM1908/UCS7604 benefit without changes.
Constraints
- Byte-identical output for every encoder, colour order and dither mode, with host tests that compare against the per-pixel path.
- The ESP32-S3 Blink image must not grow (the bloat ratchet). The new thunk is linked only where
PixelIteratoris constructed.
Rules for this sub-issue (from the meta issue)
- Keep the layered architecture. Fix this inside its layer. Don't bypass
ChannelManageror the channel engine. - Accept on instructions, not wall time. Measure instructions per
show()on the ESP32-C6 before and after. Usebash autoresearch esp32c6 --legacy --rmtwith the counter from the measurement sub-issue. Put both numbers in the PR. Code layout alone moves wall time by 10–20 µs between builds, so a wall-time number on its own can't show a 5–10% cut. - Usual gates:
bash test --cpp;bash lint;- a passing AutoResearch run with the
show()latency gate on; bash bloat esp32s3 --build, with no growth past the ratchet.
- Keep it small. Don't grow the binary on small-memory tiers (AVR, ATtiny). If a new bulk kernel doesn't pay for itself on
FL_PLATFORM_HAS_TINY_MEMORYbuilds, compile it out of them.
Metadata
Metadata
Assignees
Labels
sanitizedTitle, body and conversation screened; review text requires separate screening.
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Nov 22, 2026
Picking this up; branch perf/5399-channel-bulk-rgb
perf(encode): bulk RGB encode for the channel API path, plus a channe…