Skip to content

perf(rmt5): single-channel fast path in beginTransmission (no copy/sort/pending queue) (#5375) #5382

Closed

Description

@zackees

Sub-issue of #5375 (meta), part of #5356.

Problem

ChannelEngineRMTImpl::beginTransmission() (src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp) runs the general multi-strip path for every frame:

  1. copies every ChannelDataPtr (a shared_ptr, so one atomic refcount update per copy) into a vector_inlined;
  2. sorts it with sort_small;
  3. pushes each entry onto mPendingChannels;
  4. runs processPendingChannels() to pop it again.

For the common single-strip frame that is about 1k instructions per show() of bookkeeping.

Fix

Add a fast path inside the engine for a frame with one channel and a free hardware channel: go straight to acquire and transmit, with no copy, sort or pending-queue round trip.

Multiple strips, or more strips than hardware channels, keep today's path unchanged.

Constraints

  • No change in behaviour when channels are full or strips outnumber hardware channels.
  • The existing RMT host tests must pass. Add one showing a single-channel frame transmits without going through the pending queue.

Rules for this sub-issue (from the meta issue)

  • Keep the layered architecture. Fix this inside its layer. Don't bypass ChannelManager or the channel engine.
  • Accept on instructions, not wall time. Measure instructions per show() on the ESP32-C6 before and after. Use bash autoresearch esp32c6 --legacy --rmt with 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_MEMORY builds, compile it out of them.
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