Skip to content

perf(channels): skip the redundant second wait when all drivers are already READY (#5375) #5381

Closed

Description

@zackees

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

Problem

A legacy frame waits twice inside ChannelManager:

  • onEndFrame() calls waitForReadyOrDraining();
  • the next frame's onBeginFrame() calls waitForReady().

Each wait polls all drivers at least once, even when the previous wait already found every driver idle and nothing has been enqueued since.

Fix

Cache "all drivers READY" in the manager. Clear it on enqueue, on show() and on driver registration. When it's still set, the next waitForReady() returns immediately without polling.

Constraints

  • It must never return early while a driver is busy. A driver whose completion is asynchronous (an ISR finishing a transfer) moves from BUSY to READY without the manager doing anything, so the cache may only be set by a poll that saw READY, and anything that can create work must clear it.
  • Add host tests showing:
    • the second wait in a frame doesn't poll;
    • a busy driver is always waited on.

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.

Activity

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

    @zackees
    MemberAuthor

    Taking this (orchestrator clud-1167194); branch perf/5381-skip-ready-wait; host-only, ChannelManager wait code only.

  3. moved this from Triage to Done in FastLED Trackeron Nov 22, 2026
  4. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    Correction to the claim in #5424, after a triage pass from #5375.

    ChannelManager::poll() is called only from waitForState(). Nothing polls between frames. That means mAllReady can be set only by the poll in onEndFrame(), which runs immediately after show() starts the transmit.

    The change is safe, so I'm keeping it, but the "common case at normal frame rates" claim and the onBeginFrame() code comment ("onEndFrame() usually already saw every driver READY") don't hold for the ESP32 DMA drivers. The comment will be corrected in the next #5375 PR. Expected change on the C6 legacy-RMT benchmark: none, which matches #5424's own note.

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