Repository navigation
perf(parlio) + lint: gate eager-queue to fits-in-ring frames + ban esp_rom_printf - #2581
Conversation
…p_rom_printf ### 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]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR introduces a new C/C++ linter to detect direct ChangesESP ROM Printf Linter and Compliance
PARLIO Eager-Queue Refinement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Two related changes
1 — Engine: gate eager-queue so chunked streaming still works for large frames
#2565 turned eager-queue ON by default to overlap encode with TX. That's correct for frames that fit in the engine's 3-buffer ring — encoding completes before any TX submit, the loop drains
mRingCount → 0, IDF chains buffers via DMA descriptors, all good.But for larger frames (long LED strips that exceed the ring's capacity), the engine relies on chunked streaming:
beginTransmission()encodes one chunk per ring slot, leavesmNextByteOffset < mTotalBytes, and expectstxDoneCallback → workerIsrCallbackto encode + submit the rest as TX drains. Eager-queue's drain-to-zero pattern corrupts this:Fix: only fire the eager-queue loop when
mNextByteOffset >= mTotalBytes(whole frame already encoded). For streaming frames, fall back to one-submit-per-txDone.Verified on P4 v1.3 16-lane × 256-LED (fits in ring):
Same as #2565 — fits-in-ring path preserved, large-frame streaming path no longer trips the broken state machine.
2 — Lint: ban raw
esp_rom_printfesp_rom_printfis a low-level ROM printf intended for very early boot diagnostics. It's been creeping into general code as a workaround for #2541 (testSimd RPC routing on P4). New checkerci/lint_cpp/esp_rom_printf_checker.pyflags it anywhere insrc//examples//tests/. Suppress with// ok esp_rom_printf - <reason>on the same line.Applied opt-out comments to 36 existing legitimate uses:
src/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hpp(17) anddetail/io_esp_jtag_or_uart.hpp(2): bootstrap before logging is up.examples/AutoResearch/AutoResearchParlioEncode.h(10) andAutoResearchWave8Expand.h(7): bench output to COM25 (bug(esp32p4): testSimd RPC write-timeout — Serial routes to UART0 instead of USB-Serial-JTAG #2541 workaround).Smoke-tested: a fake violation in a scratch
.cppfile is correctly flagged; the same line with the opt-out marker is not.Test plan
bash lint --cppclean (existing legitimate uses are suppressed, no new violations).Files
Refs #2548, #2565.
🤖 Generated with Claude Code
Summary by CodeRabbit
Improvements
Code Quality