Skip to content

perf(rmt5): drop the redundant rmt_tx_wait_all_done() after an ISR-confirmed frame (#5356) #5364

Closed

Description

@zackees

Sub-issue of #5356 (show() latency on the ESP32-C6 forced-RMT legacy path).

Cause

When a frame completes, ChannelEngineRMTImpl::poll() calls releaseChannel(), and that calls rmt_tx_wait_all_done(). poll() only gets there after the transmit-done ISR has set transmissionComplete.

  • ESP-IDF calls that callback from the TX-end interrupt, after the last symbol is sent. The pooled buffer is therefore already free.
  • rmt_tx_wait_all_done() itself does no hardware wait. For each in-flight transaction it moves the descriptor from the complete queue to the ready queue: two FreeRTOS queue operations with their locking.
  • rmt_transmit() already recycles a descriptor from the complete queue whenever none is ready.

The comment that justified the wait said the callback may fire before the last bits leave the shift register. But rmt_tx_wait_all_done() waits only for the queue push that the same interrupt performs right after the callback, so it adds no hardware guarantee.

Measurement

ESP32-C6, 35 WS2812, Espressif RISC-V perf counter in instruction mode (PCER 0x7E0 = INST). The per-phase run had the phase timers on top of master 7482e19, so its total is higher than the clean 14,439 below.

phase instructions/frame
completion releaseChannel() in poll() 2,106
whole show() (per-phase run) ~16.4k

Fix

releaseChannel(channel, hardwareDone). The ISR-confirmed completion path passes true and skips the wait. Failure paths have no completion event and still wait.

On-device result, with the instruction counter around show():

build instructions/show cycles/show mean show()
master 7482e19 14,439 34,134 213.3 µs
fix 12,953 35,811 223.8 µs

That is −1,486 instructions per show() (−10%). Wall time did not drop: about 60% of show() cycles are stalls that move with code layout from build to build (IPC 0.36–0.42). Those stalls get their own sub-issue. AutoResearch RX-loopback pixel tests pass 4/4 with the fix.

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