Skip to content

perf(parlio): #2548 enable eager-queue by default — encode/TX now interleaved - #2565

Merged
zackees merged 1 commit into
masterfrom
perf/parlio-eager-queue-default-on
May 30, 2026
Merged

zackees merged 1 commit into
masterfrom
perf/parlio-eager-queue-default-on

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

PR #2564 added FL_PARLIO_EAGER_QUEUE as opt-in (default OFF) out of caution about the IDF queue chaining behaviour. The user's directive for this work line is that encoding should be interleaved with TX by default. Verified the feature does that cleanly — flipping the default to ON.

Verified on ESP32-P4 v1.3 (16-lane × 256-LED WS2812B)

OFF (previous) ON (this PR)
steady_avg_total_us 16 995 12 920 (-24 %)
steady_avg_show_us 9 439 (encode + setup BEFORE TX) 11 277 (TX running in background)
steady_avg_wait_us 7 556 (full TX) 1 643 (only TX tail remains)

wait_us collapsing from 7.6 ms → 1.6 ms is the canonical proof of interleaving: TX is running concurrently with show()'s post-submit work (FastLED bookkeeping for 4096 LEDs + remaining engine ring submission) instead of starting after show() returns.

Disable instructions

If a specific chipset + IDF version combination shows WS2812 glitches from the inter-buffer DMA chaining (the original ~20 µs gap concern from calculateBufferByteCount()), set:

-DFL_PARLIO_EAGER_QUEUE=0

…to revert to the conservative one-submit-per-txDone pattern.

Test plan

  • bash lint --cpp clean
  • Build + flash on ESP32-P4 v1.3 with default ON: streaming validation passes, BENCH_VERIFY total=12920 show=11277 wait=1643 confirms interleaving
  • CI: full matrix (will run on this PR)

Refs #2548, #2564.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated compile-time documentation for eager-queue mode configuration and its latency reduction benefits
    • Eager-queue mode is now enabled by default (can be disabled with -DFL_PARLIO_EAGER_QUEUE=0 if needed)

Review Change Stack

…erleaved

PR #2564 added FL_PARLIO_EAGER_QUEUE as opt-in (default OFF) out of
caution about the IDF queue chaining behaviour. The user's stated goal
for this work line is that encoding *should* be interleaved with TX by
default — verified that the feature does that cleanly, so flipping the
default to ON.

### Measured on ESP32-P4 v1.3 (16-lane × 256-LED WS2812B)

  OFF (previous default):
    steady_avg_total = 16 995 µs
    steady_avg_show  =  9 439 µs   ← encode + driver setup BEFORE TX
    steady_avg_wait  =  7 556 µs   ← TX (matches 7 680 µs floor)
  ON (this PR, new default):
    steady_avg_total = 12 920 µs   (-24 %)
    steady_avg_show  = 11 277 µs   ← TX runs in background DURING show()
    steady_avg_wait  =  1 643 µs   ← only TX tail remains when wait() is called

`wait_us` collapsing from 7.6 ms → 1.6 ms is the proof of interleaving:
TX is now running concurrently with show()'s post-submit work (FastLED
bookkeeping for 4096 LEDs + remaining engine ring submission) instead
of starting after show() returns.

### Disable instructions

If a specific chipset + IDF version combination shows WS2812 glitches
from the inter-buffer DMA chaining (the original ~20 µs gap concern
from `calculateBufferByteCount()`), set:

  -DFL_PARLIO_EAGER_QUEUE=0

…to revert to the conservative one-submit-per-txDone pattern.

Refs #2548.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@zackees
zackees merged commit aa4c89e into master May 30, 2026
5 of 6 checks passed
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d72efb3b-5067-4db2-a59b-9035587a7d9b

📥 Commits

Reviewing files that changed from the base of the PR and between 8185672 and 49e1220.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp

📝 Walkthrough

Walkthrough

The PR enables FL_PARLIO_EAGER_QUEUE by default (changing from 0 to 1) and updates compile-time documentation to describe eager-queue's immediate ring-buffer submission behavior and its latency benefits. The associated comment in beginTransmission() is updated to reflect the new narrative, replacing earlier "experimental/gated OFF" messaging.

Changes

Eager-queue default and documentation

Layer / File(s) Summary
Macro default and build-time documentation
src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp
FL_PARLIO_EAGER_QUEUE default changed from 0 (disabled) to 1 (enabled). Documentation explains immediate buffer submission to reduce ISR-latency gaps and provides override path (-DFL_PARLIO_EAGER_QUEUE=0) to revert to conservative behavior. Comment in beginTransmission() updated to match new eager-queue narrative.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through queues so eager,
Now by default, the speedup—much grander!
No longer gated, just leap and align,
Pre-encode buffers in perfect design. 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/parlio-eager-queue-default-on

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees deleted the perf/parlio-eager-queue-default-on branch May 30, 2026 07:02
zackees added a commit that referenced this pull request May 30, 2026
…p_rom_printf (#2581)

### 1. parlio_engine.cpp.hpp — gate eager-queue

PR #2565 turned eager-queue on by default to overlap encode with TX. That
works correctly for frames that FIT entirely in the engine's 3-buffer
ring — encoding completes before any TX submit, the loop drains
`mRingCount` to 0, IDF chains them via DMA descriptors, all good.

But for LARGER frames (long LED strips that exceed the ring's capacity)
the engine relies on chunked streaming: `populateDmaBuffer` encodes one
chunk per ring slot in `beginTransmission()`, leaves `mNextByteOffset <
mTotalBytes`, and expects `txDoneCallback` → `workerIsrCallback` to
encode + submit the rest as TX drains. Eager-queue's "drain mRingCount
to 0" pattern corrupts this:

  - After eager-queue, mRingCount = 0 but IDF still has buffers in flight.
  - txDoneCallback for buffer 0 sees count = 0 AND bytes_transmitted <
    total, takes the "ring empty but more data pending" branch.
  - That branch sets mHardwareIdle = true and mTransmitting = false even
    though IDF is currently transmitting buffer 1 — corrupting the state
    machine.

Fix: only fire the eager-queue loop when `mNextByteOffset >= mTotalBytes`
(i.e., the whole frame is already encoded). For streaming frames, fall
back to the existing one-submit-per-txDone pattern.

Verified on P4 v1.3 16-lane × 256-LED (fits in ring):

  steady_avg_total = 12 431 µs
  steady_avg_show  = 10 817 µs
  steady_avg_wait  =  1 613 µs   ← TX still overlaps with show()

Same numbers as PR #2565 — the fits-in-ring path is preserved. Large-
frame streaming path now no longer trips the broken state machine.

### 2. esp_rom_printf checker

Adds `ci/lint_cpp/esp_rom_printf_checker.py` to the custom-checker
chain. Flags any raw `esp_rom_printf(...)` call in `src/`, `examples/`,
or `tests/`. Suppress with `// ok esp_rom_printf - <reason>` on the
same line for legitimate cases.

Applied opt-out comments to the existing 36 legitimate uses:
  - `src/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hpp` (17):
    USB-Serial-JTAG driver bootstrap, runs before logging is up.
  - `src/platforms/esp/32/detail/io_esp_jtag_or_uart.hpp` (2): same.
  - `examples/AutoResearch/AutoResearchParlioEncode.h` (10) and
    `AutoResearchWave8Expand.h` (7): boot-time bench output to COM25
    (testSimd RPC routing blocked by #2541).

Smoke-tested: a fake `esp_rom_printf` violation in a temp .cpp file is
correctly flagged; the same line with the opt-out comment is not.

Rationale (in checker docstring): esp_rom_printf bypasses FastLED's
logging infrastructure, blocks on a slow peripheral, and was creeping
into general code as a workaround for #2541. The opt-out keeps the
legitimate bootstrap callers explicit.

Refs #2548, #2565.

Co-authored-by: Claude Opus 4.7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant