Repository navigation
fix(channels): skip vTaskDelay(1) floor in wait-loop on ESP32-P4 (#2493 follow-up) - #2503
Conversation
… follow-up) ChannelManager::waitForCondition and IChannelDriver::waitForCondition call task::run(250, SYSTEM) once per iteration to keep WiFi/lwIP alive while polling. On ESP32-P4 at CONFIG_FREERTOS_HZ=1000 this floor-rounds to vTaskDelay(1) = 1 ms minimum per iteration (see coroutine_esp32.impl.hpp:65-86, the "if (ticks == 0) ticks = 1" branch added for the #2254 I2S websocket starvation fix). For 12-strip x 256-LED PARLIO sketches the wait loop iterates ~7-8 times during DMA drain, adding ~8 ms per frame on top of the ~7.7 ms hardware DMA -- matching the ~16.7 ms FastLED.show() time reported in issue #2493. ESP32-P4 ships with no built-in WiFi, no Bluetooth, and no lwIP, so the original "let lwIP run" rationale does not apply. taskYIELD() (task::run(0, SYSTEM)) is sufficient: equal-priority tasks still get CPU, the PARLIO ISR keeps draining DMA, and the per-iteration cost drops from 1 ms to sub-microsecond. Other platforms keep the existing vTaskDelay(1) floor unchanged so the #2254 fix remains in place wherever WiFi/lwIP can actually run. Refs: #2493, #2254, #2420 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughBoth driver and manager channel components add platform-aware polling yield logic. When the ChangesESP32-P4 Polling Yield Optimization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Adds an end-to-end sweep that does not depend on host-side serial (which is the second blocker in #2507 — USB-Serial-JTAG produces no host-visible bytes after Arduino boot on this dev board). examples/PerfTraceBench/PerfTraceBench.ino: - 12 lanes × 256 LEDs WS2812B (override NUM_STRIPS / NUM_LEDS / NUM_FRAMES) - Per-frame: clear/enable fl::PerfTrace, FastLED.show(), snapshot the event log + show_us into a packed binary buffer - After NUM_FRAMES frames, write the buffer to the first writable data partition (esp_partition_find_first) and halt ci/perf_trace_decode.py: - Parses the flash dump (magic-tagged header / frame / event records + string-interned name table) and renders a per-frame table Usage: pio run -e esp32p4 --target upload (with PLATFORMIO_SRC_DIR=examples/PerfTraceBench) esptool --chip esp32p4 --port COMxx read-flash <part_offset> <size> dump.bin uv run ci/perf_trace_decode.py dump.bin Result on ESP32-P4-EV (12×256, build off this branch): show_us steady-state ≈ 1,058,000 µs per frame ChannelManager::waitForCondition (manager.cpp.hpp:353) ≈ 755,000 µs of that showLedsInternal ≈ 3,200 µs, onBeginFrame ≈ 30 µs, all other scopes <10 µs The #2503 fix targeted the polling-loop yield (driver.cpp.hpp:23), but the per-frame budget is dominated by the OTHER waitForCondition (line 353 in manager.cpp.hpp), so the PARLIO blocking issue from #2493 IS NOT fully resolved. ~755 ms per frame is 100× the expected WS2812B PARLIO drain time (~7.6 ms for 256 LEDs). Refs: #2493 #2494 #2503 #2507 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
FastLED.show()was spending ~8 ms per frame invTaskDelay(1)calls insideChannelManager::waitForConditionandIChannelDriver::waitForCondition— accounting for the ~16.7 ms/frame regression reported in ESP32-P4 PARLIO: FastLED.show() appears to block for ~16.7 ms before WS2812 data burst begins #2493 for 12×256 PARLIO multi-strip workloads.task::run(250, SYSTEM)atcoroutine_esp32.impl.hpp:65-86) was added to keep WiFi/lwIP alive during I2S waits per ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254. P4 has no WiFi, no Bluetooth, no lwIP — the rationale doesn't apply.task::run(0, SYSTEM)(→taskYIELD()) under#if defined(FL_IS_ESP_32P4). All other platforms keep the existing behavior.Root cause walk
For 12 strips × 256 WS2812B: DMA drain ≈ 7.7 ms, wait-loop polls once per ms → ~8 iterations × 1 ms ≈ 8 ms wasted on top of DMA → total ≈ 16 ms. Matches #2493 reported timing exactly.
Expected impact
FastLED.show()Test plan
bash test tests/fl/channels/manager.cpp --debug,bash test tests/fl/channels/channel_manager.cpp --debug,bash test tests/fl/channels/driver.cpp --debugFastLED.show()time for a 12×256 PARLIO sketch drops to ~8 ms (was ~16.7 ms per ESP32-P4 PARLIO: FastLED.show() appears to block for ~16.7 ms before WS2812 data burst begins #2493)Context
#2493 was closed by #2498 (8d4e8ef), which addressed the driver-registration symptom (LEDs not pushing data). That commit did not touch the wait-loop timing path. This PR addresses the residual timing issue called out in the issue thread by @zackees (P4 doesn't need the deep yield).
Discovered while looking at #2493 on attached hardware. The companion build-system PR is #2502 (library.json srcFilter for
fast_isr.S), needed to even link P4 builds on a clean tree.Refs: #2493, #2254, #2420, #2498, #2502
🤖 Generated with Claude Code
Summary by CodeRabbit