Skip to content

perf(rmt5): reuse the channel bound to a pin and re-check pin routing only on change (#5375) #5383

Closed

Description

@zackees

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

Problem

For every frame, ChannelEngineRMTImpl::acquireChannel() searches the channel pool by pin. It also runs reclaimPin(), which re-checks the pin's GPIO routing in case another peripheral took the pin. Together that's about 0.9k instructions per show(), even when the same strip uses the same channel and pin frame after frame.

Fix

  • Remember the channel bound to each pin, and reuse it directly when the pin, timing and buffer size are unchanged.
  • Re-check the pin's routing only when something could have changed it: the first use, after another driver or peripheral has been configured on the pin, or after reconfiguration.

Constraints

  • Keep the protection reclaimPin() gives against another peripheral (another driver, PARLIO, SPI) taking the pin. Base the decision on a cheap generation counter or an explicit event, not on skipping the check blindly.
  • Add host tests showing:
    • an unchanged strip reuses its channel without a pool search;
    • a pin taken by another driver is reclaimed.

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.

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