Skip to content

perf(show): cut legacy show() overhead inside the layered pipeline (meta, #5356) #5375

Open
11 of 11 issues completed

Description

@zackees

Part of #5356.

Goal

Make legacy FastLED.show() on the ESP32 RMT path as fast as it can be inside the current layered architecture:
controller → ChannelManager → channel engine → ESP-IDF.

The work runs as a ralph loop: one sub-issue at a time, each one its own PR merged through the queue. Do the measurement sub-issue first, because every other sub-issue uses it to show its result.

Where we are

ESP32-C6, 35 WS2812 on the legacy addLeds path (the #2994 reproducer):

Point in time mean show()
before #5350 1,687 µs
after #5350 357 µs
now (after #5358, #5360, #5366) ~205–245 µs
3.10.3, on the ESP32-S3 ~110 µs

Each show() now runs about 12.4k instructions over about 34k cycles, an IPC of about 0.4. Roughly 60% of the cycles are stalls. Putting the hot path in IRAM made no difference.

Only about 4.3k of those instructions are work a single strip actually needs:

  • encode: about 1.9k;
  • rmt_transmit() inside ESP-IDF: about 2.0k;
  • buffer copy: about 0.4k.

The rest is overhead from making every layer handle the general case (many strips, many drivers, fallback, async completion).

Most of that overhead is in how each layer is written, not in the layering itself. Each layer gets a cheap path for the common case and keeps the general path for everything else.

How every change is measured

Accept each change on instructions per show(), read from the ESP32-C6's performance counter. That count doesn't move with code layout.

Use wall time only to check cumulative progress, through the AutoResearch latency gate (#5369, tests/data/show_latency_budget.txt). #5362 was closed because a layout-only wall-time "win" vanished on the next build of master.

Done when

Sub-issues

Sub-issues

11 of 11 Issues completed
Loading 11 sub-issues

Activity

  1. added
    sanitized
    on Nov 21, 2026
  2. zackees commented on Nov 21, 2026

    @zackees
    MemberAuthor

    Suggested order for the ralph loop:

    1. test(autoresearch): report instructions per show() from the RISC-V perf counter (#5375) #5376 instruction counter. Do this first: every other PR is accepted on its numbers.
    2. perf(encode): resolve pixel types once per strip and convert in bulk instead of per-pixel PixelIterator calls (#5375) #5377 bulk pixel conversion. This is the largest single item: it applies to every encoder and RGBW, not just the RGB case perf(channels): encode plain-RGB WS2812 frames straight from PixelController (#5357) #5358 fixed.
    3. perf(channels): skip poll()/show() for drivers with no queued or in-flight work (#5375) #5379 skip idle drivers (about 1.2k instructions).
    4. perf(rmt5): single-channel fast path in beginTransmission (no copy/sort/pending queue) (#5375) #5382 single-channel beginTransmission (about 1k).
    5. perf(rmt5): reuse the channel bound to a pin and re-check pin routing only on change (#5375) #5383 channel and pin reuse (about 0.9k).
    6. perf(channels): skip the redundant second wait when all drivers are already READY (#5375) #5381 redundant wait.
    7. perf(channels): keep fl::string off the IChannelDriver::poll() hot path (#5375) #5380 fl::string off poll().
    8. perf(show): trim per-frame controller plumbing (colour adjustment, checks, hooks) (#5375) #5384 controller plumbing. Profile first, then split it.
    9. perf(encode): resolve colour order once per strip (experiment; punt if it adds complexity) (#5375) #5378 colour order once per strip. Experiment last, on top of perf(encode): resolve pixel types once per strip and convert in bulk instead of per-pixel PixelIterator calls (#5375) #5377; close it under its punt rule if it adds complexity.

    After each merge, re-measure instructions per show() and wall time, and post both here. Lower tests/data/show_latency_budget.txt at the end.

  3. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    #5377 done (PR #5403, merged): bulk RGBW/RGBWW encode.

    Before After
    Legacy RGBW, instructions per show() 31,570 15,145 (−52%)
    Legacy RGBW, mean show() 489 µs 181 µs
    Legacy RGB (latency gate), instructions per show() 12,926 12,578 (−2.7%)
    ESP32-S3 Blink flash 320,451 B 319,439 B (−1,012 B)

    New sub-issue found while doing it: #5399, the channel-API plain-RGB encode. It still runs per pixel and has no latency measurement.

    #5379 (skip idle drivers) was triaged as unsafe in its original form; see the comment on that issue. Next up: #5380, then a re-measurement to decide #5379.

    Running total, legacy RGB path (instructions per show()): 12,926 at the start of the series → 12,578 now.

  4. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    #5380 done (PR #5416, merged): fl::string removed from DriverState on the poll() hot path.

    ESP32-C6, legacy RMT, 35 LEDs:

    Before After
    Instructions per show() 12,841 9,995 (−22.2%)
    Mean show() 253.7 µs 169.9 µs
    ESP32-S3 image_flash 319,027 B 318,783 B (−244 B)

    The "before" count includes unrelated PRs that merged after #5377 (#5413, #5414).

    #5379 closed as not planned. Drivers register only when used (#2428), so a default program polls only one driver, and there are no idle drivers to skip. The details are in the closing comment on #5379.

    #5399 closed by #5413.

    Remaining: #5382 (in progress), #5383, #5381, #5384, #5378.

    Running total (legacy RGB, instructions per show()): 12,926 at the start of the series → 9,995 now (−22.7%).

  5. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    #5382 done (PR #5419, merged): RMT5 single-strip fast path. Measured on the ESP32-C6 by alternating BEFORE and AFTER builds twice, with identical instrumentation on both:

    Before After
    Instructions per show() 10,542 9,870 (−6.4%)
    Real cycles per show() 22,156 24,256 (+9.5%)
    Mean show() (counter off) 137.4 µs 149.7 µs
    ESP32-S3 image_flash 318,787 B 318,695 B

    The first measurement showed +42 µs; that did not reproduce. In all 4,432 measured calls show() returned while the RMT was still DRAINING, so no wait was added.

    The +12 µs that remains is deterministic: cycles rose while instructions fell, and IPC is about 0.41. That points to instruction-cache stalls on the flash-resident hot path, filed as new sub-issue #5422.

    Remaining: #5383, #5381, #5384, #5422, #5378.

  6. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    Orchestrator clud-1167194, picking up from the series order in the 09:35Z comment. #5381 is done (#5424, #5425). There's been no series activity since #5423, so next:

    #5384 is untouched. If you're mid-way through any of these, reply and I'll stop.

  7. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    #5383 done (PR #5423, merged): reuse the RMT channel bound to a pin. ESP32-C6, legacy RMT, 35 LEDs, alternating BEFORE/AFTER twice:

    Before After
    Instructions per show() 9,870 9,732 (−1.4%)
    Real cycles per show() ~23,546 ~22,018 (−6.5%)
    Mean show() (counter off) ~145 µs ~136 µs

    #5381 was landed by another session (PR #5424) with no C6 measurement. Triage shows it can't change the RMT benchmark, or any async DMA driver at any frame rate: the cache helps only synchronous drivers. See the correction on #5381.

    Remaining: #5384 (in progress), #5422, #5378.

    Running total, legacy RGB (instructions per show()): 12,926 at the start of the series → ~9,732 now (−24.7%). Other sessions' PRs that merged in between moved the baseline. A clean start-vs-end measurement on one commit comes at the end.

  8. zackees commented on Dec 3, 2026

    @zackees
    MemberAuthor

    All sub-issues complete (#5422 closed as measured/refuted; #5378 landed in #5508). Post-#5508 ESP32-C6 RMT show() measured at 125.3 µs mean (min 124, max 172; 8,352 instr/show, est. IPC 0.42; down from 205–245 µs / 12.4k instr/show). PR #5510 lowers esp32c6 RMT in tests/data/show_latency_budget.txt to 175 µs and adds esp32c6 PARLIO 360 µs; final table posted on #5356.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions