Skip to content

fix(esp32): guarantee deep yield in driver wait loops (Refs #2254) - #2290

Closed
zackees wants to merge 1 commit into
masterfrom
fix-esp32s3-i2s-websocket-starvation-2254
Closed

zackees wants to merge 1 commit into
masterfrom
fix-esp32s3-i2s-websocket-starvation-2254

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Restores WiFi / Ethernet / lwIP throughput on ESP32-S3 when the I2S LCD_CAM channel driver (and any other driver that spin-waits on DMA via task::run(us, ExecFlags::SYSTEM)) is active. Addresses Issue 1 of #2254.

Sub-issues from #2254

Sub-issue Status in this PR
1. I2S driver starves websockets (~1 FPS) Addressed
2. SPI driver — incorrect LED output Not addressed — see notes below
3. FastLED Audio driver reduces FPS Not addressed — see notes below

Diagnosis

The Mar 10 cooperative-yield refactor (#2167) and the Apr 5 needsDeepYield() machinery intended a vTaskDelay(>=1) in the SYSTEM-yield path when WiFi was active, so that lower-priority lwIP tasks could run during LED DMA spin-waits. Two regressions made the deep yield degenerate back to taskYIELD(), which does not yield to lower-priority tasks:

  1. Tick-rate truncation. pumpCoroutines(1000) in src/platforms/esp/32/coroutine_esp32.impl.hpp computes ticks as us / tick_period_us. On the default ESP-IDF tick rate of 100 Hz, 1000 / 10000 = 0 → taskYIELD() instead of vTaskDelay(1). Arduino-ESP32 at 1000 Hz happened to work; ESP-IDF-native projects (MoonLight among them) hit the bad path and saw ~1 FPS websockets while LEDs rendered correctly.

  2. Over-narrow deep-yield gate. The SYSTEM yield in executor.cpp.hpp only took the deep path when esp_wifi_get_mode() != WIFI_MODE_NULL. That condition misses:

    • Ethernet-only deployments (no WiFi mode, but lwIP is live).
    • The pre-WiFi.begin() window where the mode is still WIFI_MODE_NULL but network stacks may be initializing.
    • Weak-linkage edge cases where esp_wifi_get_mode resolves to nullptr even when WiFi is in use.

Fix

Two minimal changes:

  • src/platforms/esp/32/coroutine_esp32.impl.hpp — pumpCoroutines() now rounds a non-zero microseconds request UP to at least 1 FreeRTOS tick. A 0 us request still just does taskYIELD().
  • src/fl/task/executor.cpp.hpp — task::run(us, ExecFlags::SYSTEM) takes the deep-yield path whenever microseconds > 0, independent of WiFi mode. This is the path used by every driver's DMA spin-wait (I2S, SPI, LCD_SPI, LCD_CLOCKLESS, LCD_RGB, PARLIO, RMT, UART, I2S_SPI) and by FastLED.show()'s minFPS wait.

Net effect: any spin-wait loop that calls task::run(>0, SYSTEM) now guarantees at least one FreeRTOS tick of delay per iteration on ESP32, freeing the CPU for lwIP / WiFi / Ethernet tasks.

What I built / tested locally

  • bash test --cpp — 299 / 299 tests pass.
  • bash lint — clean (Python, C++, JS, Meson).
  • bash compile esp32s3 --examples Blink — succeeds.
  • bash compile esp32s3 --examples SpecialDrivers/ESP/DriverTest — succeeds.

Hardware verification (USER action required)

I cannot run on a physical board. Please verify on ESP32-S3 with WiFi + I2S channel driver + websockets:

  • Confirm websocket throughput returns to expected levels (roughly match RMT's numbers)
  • Confirm LED output remains visually correct on I2S
  • Re-measure FPS and confirm no unexpected regression (a per-iteration 1-tick delay adds ~10 ms on 100 Hz tick or ~1 ms on 1 kHz tick during spin-waits, vs. the old busy-spin; this is a trade-off and should be a net win because DMA typically takes longer than one tick)
  • Repeat with Ethernet-only setup if possible (this PR also unblocks that case)

If FPS regresses significantly because a driver is completing DMA in well under one tick, please report — we may need a vTaskDelay(0) + tight re-check fast-path for ultra-short DMA transfers.

Not addressed in this PR

  • Issue 2 (SPI driver — incorrect LED output) — I read the LCD_SPI driver (channel_driver_lcd_spi.cpp.hpp, lcd_spi_peripheral_esp.cpp.hpp) and the fix(esp32): resolve SPI/LCD_SPI buffer growth failure on channel reuse #2251 fix. I could not identify a plausible root cause from code inspection alone — the transpose encoder, the APA102 frame encoder, the chunked DMA streaming, and the buffer-reallocation fix from fix(esp32): resolve SPI/LCD_SPI buffer growth failure on channel reuse #2251 all look internally consistent. Diagnosing the visible rendering defect realistically needs the video reference reproduced on a bench. Leaving open.

  • Issue 3 (Audio driver reduces FPS 100→60) — Confirmed by code inspection: the audio pump runs via fl::task::every_ms(1).then(...) in src/fl/audio/audio_processor.cpp.hpp::createWithAutoInput, which executes on whichever thread calls task::run(... TASKS ...) — i.e. the LED main loop. The fix is to dispatch audio pumping to its own FreeRTOS task (TaskCoroutineESP32::create() already exists in src/platforms/esp/32/coroutine_esp32.impl.hpp). This requires auditing Processor / Context thread safety to avoid races on shared detector state, which I intentionally did not gold-plate in this PR. Leaving open as a follow-up.

Refs #2254

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved task scheduling and delay handling for more reliable timing behavior in OS-level yield operations.

Restores websocket throughput on ESP32-S3 under the I2S channel driver
and any other driver that spin-waits on DMA via
`task::run(us, ExecFlags::SYSTEM)`.

Diagnosis
---------
The Mar 10 cooperative-yield fix (#2167) and the Apr 5 needsDeepYield()
machinery intended a `vTaskDelay(>=1)` in the SYSTEM-yield path when
WiFi was active, so that lower-priority lwIP tasks could run. Two
regressions made the deep yield degenerate to `taskYIELD()` (which
does NOT yield to lower-priority tasks):

1. `pumpCoroutines(1000)` computed ticks from microseconds. On the
   default ESP-IDF tick rate of 100 Hz, `1000us / 10000us-per-tick = 0`
   → `taskYIELD()` instead of `vTaskDelay(1)`. Arduino-ESP32 at
   1000 Hz happened to work; MoonLight and other ESP-IDF-native
   projects hit the bad path and saw ~1 FPS websockets.

2. The deep-yield gate relied on `esp_wifi_get_mode() != WIFI_MODE_NULL`.
   This missed Ethernet-only deployments and the pre-WiFi.begin()
   window, both of which still need lwIP to get CPU time.

Fix
---
* `pumpCoroutines()` rounds a non-zero microseconds request UP to at
  least 1 FreeRTOS tick. A 0us request still just does `taskYIELD()`.
* `task::run(us, SYSTEM)` takes the deep-yield path whenever
  `microseconds > 0`, independent of WiFi state.

Tests
-----
* All 299 host C++ tests still pass.
* Lint clean.
* esp32s3 Blink and SpecialDrivers/ESP/DriverTest compile cleanly.
* Hardware verification of FPS/websockets behavior is the user's
  responsibility; see PR description.

Addresses Issue 1 in #2254. Issues 2 (SPI rendering) and 3 (audio FPS)
are not addressed by this commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR modifies yield and delay behavior in the task execution layer and ESP32 coroutine runtime. It unconditionally applies deep yielding based on time budget availability rather than conditional detection, and explicitly handles zero-wait requests while rounding up tick conversions in FreeRTOS delays.

Changes

Cohort / File(s) Summary
Task Executor Yield Logic
src/fl/task/executor.cpp.hpp
Removed conditional needsDeepYield() gating and now unconditionally calls pumpCoroutines(1000) when microseconds > 0 and ExecFlags::SYSTEM flag is set; retains lightweight fl::yield() path only for microseconds == 0.
ESP32 Coroutine Runtime Pump
src/platforms/esp/32/coroutine_esp32.impl.hpp
Updated pumpCoroutines(fl::u32 us) to explicitly handle zero-wait requests with immediate taskYIELD(), and rounds up tick conversion to guarantee at least one FreeRTOS tick for non-zero waits instead of conditional fallback behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

  • FastLED#2254: Directly related through shared modifications to ESP32 RTOS yield/delay semantics (taskYIELD, vTaskDelay) and cooperative yield timing behavior.

Poem

🐰 Hops through yield and delay so fine,
Deep pumps dance when time aligns,
Zero waits get their quick release,
Ticks round up for RTOS peace! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main fix: guaranteeing deep yield in driver wait loops on ESP32, which is the core purpose of both code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix-esp32s3-i2s-websocket-starvation-2254

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/platforms/esp/32/coroutine_esp32.impl.hpp (1)

65-85: Comment/implementation mismatch: "Round UP" is actually a min-1 clamp.

The comment says ticks are rounded up, but the code truncates (us / tick_period_us) and only bumps 0 to 1. For us values strictly between one and two tick periods (e.g. us = 15000 at a 100 Hz tick where tick_period_us = 10000), ticks becomes 1 (~10 ms) rather than 2 (~20 ms) as a true ceiling would produce. The fix goal ("≥ 1 tick") is met for typical sub-tick callers (the only path that actually exercises the clamp), but if you intend real ceiling semantics as documented, use:

♻️ Optional ceiling-division refactor
-        const fl::u32 tick_period_us = 1000000u / configTICK_RATE_HZ;
-        fl::u32 ticks = us / tick_period_us;
-
         if (us == 0) {
             // Caller explicitly asked for no delay — just yield among
             // equal/higher priority tasks.
             taskYIELD();
             return;
         }
 
-        // Caller asked for a non-zero wait. Round UP to at least 1 tick ...
-        if (ticks == 0) {
-            ticks = 1;
-        }
+        // Caller asked for a non-zero wait. Ceiling-divide to guarantee
+        // at least 1 tick so that lower-priority tasks (e.g. lwIP/WiFi)
+        // actually get CPU time. See issue `#2254` (Issue 1).
+        const fl::u32 tick_period_us = 1000000u / configTICK_RATE_HZ;
+        const fl::u32 ticks = (us + tick_period_us - 1) / tick_period_us;
         vTaskDelay(ticks);

Note: per FreeRTOS semantics vTaskDelay(n) guarantees a minimum of n-1 ticks, so vTaskDelay(1) can return almost immediately if called just before a tick boundary — the task still enters the delayed list, which is what allows lwIP/WiFi tasks to run, so the spin-wait starvation fix still works.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/platforms/esp/32/coroutine_esp32.impl.hpp` around lines 65 - 85, The
comment is wrong: the code currently truncates us/tick_period_us and only clamps
zero to one; change the computation of ticks in the coroutine delay routine so
it performs a proper ceiling division (i.e. ticks = (us + tick_period_us - 1) /
tick_period_us) while preserving the early-return for us == 0 and the subsequent
vTaskDelay(ticks) call; update the calculation that sets fl::u32 ticks so
callers requesting partial ticks are rounded up to the next whole tick.
src/fl/task/executor.cpp.hpp (1)

135-141: Extract the hardcoded 1000 µs hint into a named constant for consistency and clarity.

The magic number 1000 appears twice in this code path (lines 137 and 147) and should be unified as a named constant. The suggested kDeepYieldHintUs makes the intent explicit and ensures both sites remain synchronized if the hint value needs future adjustment.

The change to always call pumpCoroutines(1000) when microseconds > 0 (removing the prior needsDeepYield() gate) is safe across platforms:

  • Arduino: pumpCoroutines is a no-op; no behavioral change.
  • Teensy: Suspend only occurs if called from within a coroutine; calling from the main executor thread is safe.
  • ESP32: Now always performs vTaskDelay with proper FreeRTOS tick rounding (≥1 tick), which correctly prevents WiFi/lwIP starvation.
  • WASM: No-op from main thread; calling from executor context is safe.
  • Stub: Runs pending coroutines; minimal overhead, no functional issue.

Note that with this change, microseconds == 0 is now the only entry point that takes the lightweight fl::yield() path. Callers relying on small microseconds values (e.g., task::run(100, SYSTEM)) will block for approximately 1 ms per iteration on platforms with cooperative scheduling, so budgets should account for this minimum granularity.

Proposed constant extraction:

Named-constant refactor
+// Per-iteration deep-yield hint. On ESP32 this is clamped to at least
+// 1 FreeRTOS tick by CoroutineRuntimeEsp32::pumpCoroutines.
+static constexpr fl::u32 kDeepYieldHintUs = 1000;
+
 void run(fl::u32 microseconds, ExecFlags flags) {
     ...
         if (do_system) {
             if (microseconds > 0) {
-                fl::platforms::ICoroutineRuntime::instance().pumpCoroutines(1000);
+                fl::platforms::ICoroutineRuntime::instance().pumpCoroutines(kDeepYieldHintUs);
             } else {
                 fl::yield();
             }
         }
 
         // COROUTINES: Platform cooperative coroutines (pumpCoroutines)
         if (do_coroutines) {
             auto time_left = remaining();
             if (time_left) {
-                fl::u32 sleep_us = fl::min(1000u, time_left);
+                fl::u32 sleep_us = fl::min(kDeepYieldHintUs, time_left);
                 fl::platforms::ICoroutineRuntime::instance().pumpCoroutines(sleep_us);
             }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/task/executor.cpp.hpp` around lines 135 - 141, Extract the hardcoded
1000µs hint into a named constant (e.g., kDeepYieldHintUs) and replace both
occurrences of the literal in the executor path so they stay synchronized;
update the branch that currently calls
fl::platforms::ICoroutineRuntime::instance().pumpCoroutines(1000) to use
kDeepYieldHintUs and ensure the other site that previously used 1000 is changed
the same way, leaving the fl::yield() call for the microseconds==0 path
unchanged so behavior matches the review description.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/fl/task/executor.cpp.hpp`:
- Around line 135-141: Extract the hardcoded 1000µs hint into a named constant
(e.g., kDeepYieldHintUs) and replace both occurrences of the literal in the
executor path so they stay synchronized; update the branch that currently calls
fl::platforms::ICoroutineRuntime::instance().pumpCoroutines(1000) to use
kDeepYieldHintUs and ensure the other site that previously used 1000 is changed
the same way, leaving the fl::yield() call for the microseconds==0 path
unchanged so behavior matches the review description.

In `@src/platforms/esp/32/coroutine_esp32.impl.hpp`:
- Around line 65-85: The comment is wrong: the code currently truncates
us/tick_period_us and only clamps zero to one; change the computation of ticks
in the coroutine delay routine so it performs a proper ceiling division (i.e.
ticks = (us + tick_period_us - 1) / tick_period_us) while preserving the
early-return for us == 0 and the subsequent vTaskDelay(ticks) call; update the
calculation that sets fl::u32 ticks so callers requesting partial ticks are
rounded up to the next whole tick.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53c9858e-6f1f-44fc-8430-f5d47832490b

📥 Commits

Reviewing files that changed from the base of the PR and between b6c2501 and 25873cf.

📒 Files selected for processing (2)
  • src/fl/task/executor.cpp.hpp
  • src/platforms/esp/32/coroutine_esp32.impl.hpp

@zackees zackees closed this Apr 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Header Compilation Performance

Total Time: 1155.35ms

Top 5 Slowest Headers

  1. FastLED.h - 875.21ms
  2. fl/fastled.h - 379.94ms
  3. fl/task/executor.h - 285.38ms
  4. crgb.h - 217.48ms
  5. fl/gfx/crgb.h - 216.19ms

Warnings

⚠️ Header FastLED.h exceeds 150ms (875.2ms)
⚠️ Header fl/fastled.h exceeds 150ms (379.9ms)
⚠️ Header fl/task/executor.h exceeds 150ms (285.4ms)
⚠️ Header crgb.h exceeds 150ms (217.5ms)
⚠️ Header fl/gfx/crgb.h exceeds 150ms (216.2ms)
⚠️ Header fl/math/ease.h exceeds 150ms (211.3ms)
⚠️ Header fl/math/fixed_point.h exceeds 150ms (208.9ms)
⚠️ Header fl/task/scheduler.h exceeds 50ms (149.5ms)
⚠️ Header fl/stl/singleton.h exceeds 50ms (140.1ms)
⚠️ Header fl/stl/thread_local.h exceeds 50ms (139.4ms)
⚠️ Header fl/stl/thread.h exceeds 50ms (138.3ms)
⚠️ Header platforms/thread.h exceeds 50ms (138.2ms)
⚠️ Header platforms/stub/thread_stub.h exceeds 50ms (138.2ms)
⚠️ Header platforms/stub/thread_stub_stl.h exceeds 50ms (138.1ms)
⚠️ Header fl/task/promise.h exceeds 50ms (122.4ms)
⚠️ Header fl/ui.h exceeds 50ms (117.6ms)
⚠️ Header fl/stl/json.h exceeds 50ms (76.3ms)
⚠️ Header fl/stl/function.h exceeds 50ms (73.2ms)
⚠️ Header fl/math/fixed_point/s4x12.h exceeds 50ms (62.8ms)
⚠️ Header fl/stl/json/types.h exceeds 50ms (59.3ms)
⚠️ Header platforms.h exceeds 50ms (54.0ms)
⚠️ Header platforms/stub/fastled_stub.h exceeds 50ms (53.9ms)
⚠️ Template instantiation time is high (52.6%)

Full Report
================================================================================
FASTLED COMPILATION PERFORMANCE REPORT
================================================================================
Generated: 2026-04-18 04:19:01
Compiler: clang++-17
File: ci/perf/test_compile.cpp

SUMMARY
--------------------------------------------------------------------------------
Total Compilation Time:    1,881.50 ms
Frontend Time:             17.16 ms (0.9%)
Backend Time:              141.69 ms (7.5%)

COMPILATION PHASES
--------------------------------------------------------------------------------
Source                    11967.67 ms (636.1%)
Templates                   658.36 ms ( 35.0%)

FASTLED HEADERS (Level 1 - Direct Includes)
--------------------------------------------------------------------------------
  1411.5 ms - FastLED.h (SLOW)
   680.5 ms - fl/task/executor.h (SLOW)
   507.5 ms - fl/fastled.h (SLOW)
   360.9 ms - fl/task/scheduler.h (SLOW)
   351.2 ms - fl/stl/singleton.h (SLOW)
   350.5 ms - fl/stl/thread_local.h (SLOW)
   349.3 ms - fl/stl/thread.h (SLOW)
   349.2 ms - platforms/thread.h (SLOW)
   349.1 ms - platforms/stub/thread_stub.h (SLOW)
   349.1 ms - platforms/stub/thread_stub_stl.h (SLOW)
   308.1 ms - crgb.h (SLOW)
   306.9 ms - fl/gfx/crgb.h (SLOW)
   305.4 ms - fl/task/promise.h (SLOW)
   301.9 ms - fl/math/ease.h (SLOW)
   299.5 ms - fl/math/fixed_point.h (SLOW)
   255.3 ms - fl/stl/function.h (SLOW)
   152.6 ms - fl/math/fixed_point/s4x12.h (SLOW)
   131.9 ms - fl/math/sin32.h (SLOW)
   128.5 ms - fl/math/simd.h (SLOW)
   128.0 ms - fl/math/simd/types.h (SLOW)

FASTLED HEADERS (Nested Includes - Up to 10 Levels)
--------------------------------------------------------------------------------
FastLED.h (1411.5ms)
  ├─  680.5 ms - fl/task/executor.h
  │ ├─  360.9 ms - fl/task/scheduler.h
  │ │ ├─  351.2 ms - fl/stl/singleton.h
  │ │ │ └─  350.5 ms - fl/stl/thread_local.h
  │ │ │   └─  349.3 ms - fl/stl/thread.h
  │ │ │     └─  349.2 ms - platforms/thread.h
  │ │ │       └─  349.1 ms - platforms/stub/thread_stub.h
  │ │ │         └─  349.1 ms - platforms/stub/thread_stub_stl.h
  │ │ │           └─  341.0 ms - thread
  │ │ │             ├─  180.0 ms - std_thread.h
  │ │ │             └─  147.3 ms - this_thread_sleep.h
  │ │ └─    8.9 ms - fl/task/task.h
  │ │   └─    3.6 ms - fl/trace.h
  │ │     ├─    2.3 ms - fl/stl/chrono.h
  │ │     └─    1.0 ms - fl/stl/tuple.h
  │ ├─  305.4 ms - fl/task/promise.h
  │ │ ├─  255.3 ms - fl/stl/function.h
  │ │ │ ├─  118.8 ms - fl/stl/vector.h
  │ │ │ │ ├─   83.8 ms - fl/math/math.h
  │ │ │ │ │ └─   78.0 ms - fl/stl/undef.h
  │ │ │ │ │   └─  137.1 ms - stdlib.h
  │ │ │ │ │     ├─   69.3 ms - cstdlib
  │ │ │ │ │     │ ├─  137.1 ms - stdlib.h
  │ │ │ │ │     │ │ ├─   69.3 ms - cstdlib
  │ │ │ │ │     │ │ ├─   24.9 ms - types.h
  │ │ │ │ │     │ │ └─    0.5 ms - floatn.h
  │ │ │ │ │     │ └─    0.5 ms - std_abs.h
  │ │ │ │ │     ├─   24.9 ms - types.h
  │ │ │ │ │     │ ├─   24.9 ms - types.h
  │ │ │ │ │     │ │ ├─   24.9 ms - types.h
  │ │ │ │ │     │ │ ├─    2.1 ms - pthreadtypes.h
  │ │ │ │ │     │ │ ├─    1.7 ms - select.h
  │ │ │ │ │     │ │ └─    1.6 ms - endian.h
  │ │ │ │ │     │ ├─    2.1 ms - pthreadtypes.h
  │ │ │ │ │     │ │ └─    1.5 ms - thread-shared-types.h
  │ │ │ │ │     │ ├─    1.7 ms - select.h
  │ │ │ │ │     │ └─    1.6 ms - endian.h
  │ │ │ │ │     └─    0.5 ms - floatn.h
  │ │ │ │ ├─   18.9 ms - fl/stl/allocator.h
  │ │ │ │ │ └─   13.0 ms - fl/stl/bitset.h
  │ │ │ │ │   └─    8.4 ms - fl/stl/bitset_dynamic.h
  │ │ │ │ │     └─    2.2 ms - fl/stl/unique_ptr.h
  │ │ │ │ │       └─    0.5 ms - fl/stl/utility.h
  │ │ │ │ ├─    5.0 ms - fl/stl/initializer_list.h
  │ │ │ │ ├─    2.8 ms - fl/stl/basic_vector.h
  │ │ │ │ └─    0.7 ms - fl/stl/functional.h
  │ │ │ ├─   84.3 ms - fl/stl/variant.h
  │ │ │ │ └─   82.3 ms - fl/stl/new.h
  │ │ │ │   └─   82.3 ms - platforms/new.h
  │ │ │ │     └─   82.3 ms - platforms/shared/new.h
  │ │ │ │       └─   66.2 ms - new
  │ │ │ │         ├─   35.7 ms - c++config.h
  │ │ │ │         │ └─   26.2 ms - os_defines.h
  │ │ │ │         └─    0.7 ms - version.h
  │ │ │ ├─   36.9 ms - fl/stl/shared_ptr.h
  │ │ │ │ ├─   24.5 ms - fl/stl/type_traits.h
  │ │ │ │ │ └─   17.9 ms - fl/stl/move.h
  │ │ │ │ ├─    7.3 ms - fl/stl/atomic.h
  │ │ │ │ │ └─    6.5 ms - platforms/atomic.h
  │ │ │ │ │   └─    6.4 ms - platforms/shared/atomic.h
  │ │ │ │ └─    0.7 ms - fl/stl/bit_cast.h
  │ │ │ ├─    4.8 ms - fl/stl/compiler_control.h
  │ │ │ └─    4.8 ms - fl/stl/algorithm.h
  │ │ │   └─    2.0 ms - fl/math/random.h
  │ │ │     └─    1.0 ms - fl/math/random8.h
  │ │ └─   44.8 ms - fl/stl/string.h
  │ │   ├─   12.9 ms - fl/stl/basic_string.h
  │ │   │ ├─    1.1 ms - fl/stl/not_null.h
  │ │   │ └─    0.9 ms - fl/stl/iterator.h
  │ │   ├─    8.9 ms - fl/stl/span.h
  │ │   │ └─    3.5 ms - fl/math/geometry.h
  │ │   ├─    5.8 ms - fl/stl/string_view.h
  │ │   └─    1.5 ms - fl/stl/optional.h
  │ ├─   11.7 ms - platforms/await.h
  │ │ └─   11.3 ms - platforms/coroutine_runtime.h
  │ │   └─    9.7 ms - fl/system/engine_events.h
  │ │     ├─    5.0 ms - fl/math/screenmap.h
  │ │     │ └─    3.7 ms - fl/stl/flat_map.h
  │ │     └─    3.1 ms - fl/math/xymap.h
  │ │       └─    0.8 ms - fl/math/lut.h
  │ └─    0.8 ms - fl/task/promise_result.h
  ├─  507.5 ms - fl/fastled.h
  │ ├─  308.1 ms - crgb.h
  │ │ ├─  306.9 ms - fl/gfx/crgb.h
  │ │ │ └─  301.9 ms - fl/math/ease.h
  │ │ │   └─  299.5 ms - fl/math/fixed_point.h
  │ │ │     ├─  152.6 ms - fl/math/fixed_point/s4x12.h
  │ │ │     │ ├─  131.9 ms - fl/math/sin32.h
  │ │ │     │ │ └─  128.5 ms - fl/math/simd.h
  │ │ │     │ │   └─  128.0 ms - fl/math/simd/types.h
  │ │ │     │ │     └─  127.7 ms - platforms/simd.h
  │ │ │     │ ├─    1.1 ms - fl/math/fixed_point/traits.h
  │ │ │     │ └─    0.7 ms - fl/math/fixed_point/isqrt.h
  │ │ │     ├─   18.5 ms - fl/math/fixed_point/s8x8.h
  │ │ │     ├─   18.5 ms - fl/math/fixed_point/s16x16.h
  │ │ │     ├─   18.3 ms - fl/math/fixed_point/s8x24.h
  │ │ │     └─   18.2 ms - fl/math/fixed_point/s24x8.h
  │ │ └─    0.8 ms - chsv.h
  │ │   └─    0.8 ms - fl/gfx/hsv.h
  │ ├─   84.9 ms - platforms.h
  │ │ └─   84.8 ms - platforms/stub/fastled_stub.h
  │ │   ├─   48.5 ms - platforms/stub/fastspi_stub.h
  │ │   │ └─   48.5 ms - platforms/stub/fastspi_stub_generic.h
  │ │   │   ├─   42.3 ms - platforms/shared/active_strip_data/active_strip_data.h
  │ │   │   │ └─   40.2 ms - fl/id_tracker.h
  │ │   │   │   └─   39.3 ms - fl/stl/mutex.h
  │ │   │   │     └─   39.2 ms - platforms/mutex.h
  │ │   │   │       └─   39.1 ms - platforms/stub/mutex_stub.h
  │ │   │   └─    5.8 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │ │   └─   36.2 ms - platforms/stub/clockless_stub.h
  │ │     └─   36.2 ms - platforms/stub/clockless_channel_stub.h
  │ │       ├─   12.9 ms - fl/system/log.h
  │ │       │ └─   12.5 ms - fl/stl/strstream.h
  │ │       ├─   12.8 ms - fl/channels/data.h
  │ │       │ └─    9.6 ms - fl/channels/config.h
  │ │       │   ├─    2.2 ms - fl/chipsets/chipset_timing_config.h
  │ │       │   │ └─    1.4 ms - fl/chipsets/led_timing.h
  │ │       │   └─    1.7 ms - fl/chipsets/spi.h
  │ │       ├─    2.3 ms - fl/channels/manager.h
  │ │       ├─    1.5 ms - fl/stl/weak_ptr.h
  │ │       └─    1.1 ms - fl/channels/driver.h
  │ ├─   46.4 ms - colorutils.h
  │ │ └─   45.6 ms - fl/gfx/colorutils.h
  │ │   ├─    8.8 ms - fl/gfx/blur.h
  │ │   │ └─    4.7 ms - fl/gfx/canvas.h
  │ │   │   └─    2.9 ms - fl/math/alpha.h
  │ │   └─    3.1 ms - fl/gfx/fill.h
  │ ├─   23.7 ms - pixel_controller.h
  │ │ ├─   17.0 ms - pixel_iterator.h
  │ │ │ └─   16.9 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │ │   ├─    5.0 ms - fl/chipsets/encoders/apa102.h
  │ │ │   │ └─    3.9 ms - fl/chipsets/encoders/encoder_utils.h
  │ │ │   │   └─    3.2 ms - fl/gfx/gamma_lut.h
  │ │ │   ├─    4.5 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │ │   ├─    1.0 ms - fl/chipsets/encoders/sk9822.h
  │ │ │   └─    0.9 ms - fl/chipsets/encoders/hd108.h
  │ │ └─    2.5 ms - rgbw.h
  │ │   └─    2.3 ms - fl/gfx/rgbw.h
  │ └─   22.8 ms - pixeltypes.h
  │   ├─   19.1 ms - lib8tion.h
  │   │ ├─    9.9 ms - fl/math/math8.h
  │   │ │ ├─    5.2 ms - fl/math/intmap.h
  │   │ │ │ └─    4.1 ms - platforms/intmap.h
  │   │ │ ├─    2.5 ms - fl/math/scale8.h
  │   │ │ │ └─    2.5 ms - platforms/scale8.h
  │   │ │ │   └─    1.0 ms - platforms/shared/scale8.h
  │   │ │ └─    2.0 ms - platforms/math8.h
  │   │ │   └─    1.7 ms - platforms/shared/math8.h
  │   │ ├─    2.0 ms - fl/math/beat.h
  │   │ │ └─    1.0 ms - fl/math/trig8.h
  │   │ │   └─    1.0 ms - platforms/trig8.h
  │   │ │     └─    0.9 ms - platforms/shared/trig8.h
  │   │ └─    0.5 ms - fl/math/time_functions.h
  │   └─    3.2 ms - crgb.hpp
  ├─  117.9 ms - fl/ui.h
  │ ├─   75.9 ms - fl/stl/json.h
  │ │ └─   58.5 ms - fl/stl/json/types.h
  │ │   └─    7.5 ms - fl/stl/limits.h
  │ ├─   10.1 ms - fl/ui_impl.h
  │ │ └─    9.5 ms - platforms/ui_defs.h
  │ │   ├─    2.1 ms - platforms/shared/ui/json/audio.h
  │ │   │ └─    0.9 ms - platforms/shared/ui/json/audio_internal.h
  │ │   ├─    1.5 ms - platforms/shared/ui/json/button.h
  │ │   │ └─    0.6 ms - platforms/shared/ui/json/ui_internal.h
  │ │   ├─    0.9 ms - platforms/shared/ui/json/checkbox.h
  │ │   ├─    0.8 ms - platforms/shared/ui/json/help.h
  │ │   └─    0.8 ms - platforms/shared/ui/json/number_field.h
  │ └─    6.8 ms - fl/stl/url.h
  ├─   27.8 ms - chipsets.h
  │ ├─   11.2 ms - fl/chipsets/ucs7604.h
  │ │ └─    8.4 ms - fl/chipsets/encoders/ucs7604.h
  │ ├─    6.5 ms - fl/chipsets/apa102.h
  │ ├─    1.7 ms - fl/chipsets/lpd880x.h
  │ ├─    0.9 ms - fl/chipsets/p9813.h
  │ └─    0.8 ms - fl/chipsets/encoders/ws2816.h
  └─   22.0 ms - fl/audio/audio_processor.h
    ├─    5.6 ms - fl/audio/audio_context.h
    │ └─    1.6 ms - fl/audio/fft/fft.h
    ├─    1.7 ms - fl/audio/detector/vibe.h
    └─    0.9 ms - fl/audio/signal_conditioner.h
fl/task/executor.h (680.5ms)
  ├─  360.9 ms - fl/task/scheduler.h
  │ ├─  351.2 ms - fl/stl/singleton.h
  │ │ └─  350.5 ms - fl/stl/thread_local.h
  │ │   └─  349.3 ms - fl/stl/thread.h
  │ │     └─  349.2 ms - platforms/thread.h
  │ │       └─  349.1 ms - platforms/stub/thread_stub.h
  │ │         └─  349.1 ms - platforms/stub/thread_stub_stl.h
  │ │           └─  341.0 ms - thread
  │ │             ├─  180.0 ms - std_thread.h
  │ │             │ ├─   66.6 ms - tuple
  │ │             │ ├─   26.1 ms - iosfwd
  │ │             │ ├─   21.6 ms - refwrap.h
  │ │             │ ├─   16.0 ms - gthr.h
  │ │             │ └─    6.1 ms - unique_ptr.h
  │ │             └─  147.3 ms - this_thread_sleep.h
  │ │               ├─  106.7 ms - chrono.h
  │ │               └─   30.7 ms - cerrno
  │ └─    8.9 ms - fl/task/task.h
  │   └─    3.6 ms - fl/trace.h
  │     ├─    2.3 ms - fl/stl/chrono.h
  │     └─    1.0 ms - fl/stl/tuple.h
  ├─  305.4 ms - fl/task/promise.h
  │ ├─  255.3 ms - fl/stl/function.h
  │ │ ├─  118.8 ms - fl/stl/vector.h
  │ │ │ ├─   83.8 ms - fl/math/math.h
  │ │ │ │ └─   78.0 ms - fl/stl/undef.h
  │ │ │ │   └─  137.1 ms - stdlib.h
  │ │ │ │     ├─   69.3 ms - cstdlib
  │ │ │ │     │ ├─  137.1 ms - stdlib.h
  │ │ │ │     │ │ ├─   69.3 ms - cstdlib
  │ │ │ │     │ │ │ ├─  137.1 ms - stdlib.h
  │ │ │ │     │ │ │ └─    0.5 ms - std_abs.h
  │ │ │ │     │ │ ├─   24.9 ms - types.h
  │ │ │ │     │ │ │ ├─   24.9 ms - types.h
  │ │ │ │     │ │ │ ├─    2.1 ms - pthreadtypes.h
  │ │ │ │     │ │ │ ├─    1.7 ms - select.h
  │ │ │ │     │ │ │ └─    1.6 ms - endian.h
  │ │ │ │     │ │ └─    0.5 ms - floatn.h
  │ │ │ │     │ └─    0.5 ms - std_abs.h
  │ │ │ │     ├─   24.9 ms - types.h
  │ │ │ │     │ ├─   24.9 ms - types.h
  │ │ │ │     │ │ ├─   24.9 ms - types.h
  │ │ │ │     │ │ │ ├─   24.9 ms - types.h
  │ │ │ │     │ │ │ ├─    2.1 ms - pthreadtypes.h
  │ │ │ │     │ │ │ ├─    1.7 ms - select.h
  │ │ │ │     │ │ │ └─    1.6 ms - endian.h
  │ │ │ │     │ │ ├─    2.1 ms - pthreadtypes.h
  │ │ │ │     │ │ │ └─    1.5 ms - thread-shared-types.h
  │ │ │ │     │ │ ├─    1.7 ms - select.h
  │ │ │ │     │ │ └─    1.6 ms - endian.h
  │ │ │ │     │ ├─    2.1 ms - pthreadtypes.h
  │ │ │ │     │ │ └─    1.5 ms - thread-shared-types.h
  │ │ │ │     │ ├─    1.7 ms - select.h
  │ │ │ │     │ └─    1.6 ms - endian.h
  │ │ │ │     └─    0.5 ms - floatn.h
  │ │ │ ├─   18.9 ms - fl/stl/allocator.h
  │ │ │ │ └─   13.0 ms - fl/stl/bitset.h
  │ │ │ │   └─    8.4 ms - fl/stl/bitset_dynamic.h
  │ │ │ │     └─    2.2 ms - fl/stl/unique_ptr.h
  │ │ │ │       └─    0.5 ms - fl/stl/utility.h
  │ │ │ ├─    5.0 ms - fl/stl/initializer_list.h
  │ │ │ ├─    2.8 ms - fl/stl/basic_vector.h
  │ │ │ └─    0.7 ms - fl/stl/functional.h
  │ │ ├─   84.3 ms - fl/stl/variant.h
  │ │ │ └─   82.3 ms - fl/stl/new.h
  │ │ │   └─   82.3 ms - platforms/new.h
  │ │ │     └─   82.3 ms - platforms/shared/new.h
  │ │ │       └─   66.2 ms - new
  │ │ │         ├─   35.7 ms - c++config.h
  │ │ │         │ └─   26.2 ms - os_defines.h
  │ │ │         │   └─   22.7 ms - features.h
  │ │ │         └─    0.7 ms - version.h
  │ │ ├─   36.9 ms - fl/stl/shared_ptr.h
  │ │ │ ├─   24.5 ms - fl/stl/type_traits.h
  │ │ │ │ └─   17.9 ms - fl/stl/move.h
  │ │ │ ├─    7.3 ms - fl/stl/atomic.h
  │ │ │ │ └─    6.5 ms - platforms/atomic.h
  │ │ │ │   └─    6.4 ms - platforms/shared/atomic.h
  │ │ │ └─    0.7 ms - fl/stl/bit_cast.h
  │ │ ├─    4.8 ms - fl/stl/compiler_control.h
  │ │ └─    4.8 ms - fl/stl/algorithm.h
  │ │   └─    2.0 ms - fl/math/random.h
  │ │     └─    1.0 ms - fl/math/random8.h
  │ └─   44.8 ms - fl/stl/string.h
  │   ├─   12.9 ms - fl/stl/basic_string.h
  │   │ ├─    1.1 ms - fl/stl/not_null.h
  │   │ └─    0.9 ms - fl/stl/iterator.h
  │   ├─    8.9 ms - fl/stl/span.h
  │   │ └─    3.5 ms - fl/math/geometry.h
  │   ├─    5.8 ms - fl/stl/string_view.h
  │   └─    1.5 ms - fl/stl/optional.h
  ├─   11.7 ms - platforms/await.h
  │ └─   11.3 ms - platforms/coroutine_runtime.h
  │   └─    9.7 ms - fl/system/engine_events.h
  │     ├─    5.0 ms - fl/math/screenmap.h
  │     │ └─    3.7 ms - fl/stl/flat_map.h
  │     └─    3.1 ms - fl/math/xymap.h
  │       └─    0.8 ms - fl/math/lut.h
  └─    0.8 ms - fl/task/promise_result.h
fl/fastled.h (507.5ms)
  ├─  308.1 ms - crgb.h
  │ ├─  306.9 ms - fl/gfx/crgb.h
  │ │ └─  301.9 ms - fl/math/ease.h
  │ │   └─  299.5 ms - fl/math/fixed_point.h
  │ │     ├─  152.6 ms - fl/math/fixed_point/s4x12.h
  │ │     │ ├─  131.9 ms - fl/math/sin32.h
  │ │     │ │ └─  128.5 ms - fl/math/simd.h
  │ │     │ │   └─  128.0 ms - fl/math/simd/types.h
  │ │     │ │     └─  127.7 ms - platforms/simd.h
  │ │     │ │       └─  127.7 ms - platforms/shared/simd_x86.hpp
  │ │     │ ├─    1.1 ms - fl/math/fixed_point/traits.h
  │ │     │ └─    0.7 ms - fl/math/fixed_point/isqrt.h
  │ │     ├─   18.5 ms - fl/math/fixed_point/s8x8.h
  │ │     ├─   18.5 ms - fl/math/fixed_point/s16x16.h
  │ │     ├─   18.3 ms - fl/math/fixed_point/s8x24.h
  │ │     └─   18.2 ms - fl/math/fixed_point/s24x8.h
  │ └─    0.8 ms - chsv.h
  │   └─    0.8 ms - fl/gfx/hsv.h
  ├─   84.9 ms - platforms.h
  │ └─   84.8 ms - platforms/stub/fastled_stub.h
  │   ├─   48.5 ms - platforms/stub/fastspi_stub.h
  │   │ └─   48.5 ms - platforms/stub/fastspi_stub_generic.h
  │   │   ├─   42.3 ms - platforms/shared/active_strip_data/active_strip_data.h
  │   │   │ └─   40.2 ms - fl/id_tracker.h
  │   │   │   └─   39.3 ms - fl/stl/mutex.h
  │   │   │     └─   39.2 ms - platforms/mutex.h
  │   │   │       └─   39.1 ms - platforms/stub/mutex_stub.h
  │   │   │         └─   39.1 ms - platforms/stub/mutex_stub_stl.h
  │   │   └─    5.8 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │   └─   36.2 ms - platforms/stub/clockless_stub.h
  │     └─   36.2 ms - platforms/stub/clockless_channel_stub.h
  │       ├─   12.9 ms - fl/system/log.h
  │       │ └─   12.5 ms - fl/stl/strstream.h
  │       ├─   12.8 ms - fl/channels/data.h
  │       │ └─    9.6 ms - fl/channels/config.h
  │       │   ├─    2.2 ms - fl/chipsets/chipset_timing_config.h
  │       │   │ └─    1.4 ms - fl/chipsets/led_timing.h
  │       │   └─    1.7 ms - fl/chipsets/spi.h
  │       ├─    2.3 ms - fl/channels/manager.h
  │       ├─    1.5 ms - fl/stl/weak_ptr.h
  │       └─    1.1 ms - fl/channels/driver.h
  ├─   46.4 ms - colorutils.h
  │ └─   45.6 ms - fl/gfx/colorutils.h
  │   ├─    8.8 ms - fl/gfx/blur.h
  │   │ └─    4.7 ms - fl/gfx/canvas.h
  │   │   └─    2.9 ms - fl/math/alpha.h
  │   └─    3.1 ms - fl/gfx/fill.h
  ├─   23.7 ms - pixel_controller.h
  │ ├─   17.0 ms - pixel_iterator.h
  │ │ └─   16.9 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │   ├─    5.0 ms - fl/chipsets/encoders/apa102.h
  │ │   │ └─    3.9 ms - fl/chipsets/encoders/encoder_utils.h
  │ │   │   └─    3.2 ms - fl/gfx/gamma_lut.h
  │ │   ├─    4.5 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │   ├─    1.0 ms - fl/chipsets/encoders/sk9822.h
  │ │   └─    0.9 ms - fl/chipsets/encoders/hd108.h
  │ └─    2.5 ms - rgbw.h
  │   └─    2.3 ms - fl/gfx/rgbw.h
  └─   22.8 ms - pixeltypes.h
    ├─   19.1 ms - lib8tion.h
    │ ├─    9.9 ms - fl/math/math8.h
    │ │ ├─    5.2 ms - fl/math/intmap.h
    │ │ │ └─    4.1 ms - platforms/intmap.h
    │ │ ├─    2.5 ms - fl/math/scale8.h
    │ │ │ └─    2.5 ms - platforms/scale8.h
    │ │ │   └─    1.0 ms - platforms/shared/scale8.h
    │ │ └─    2.0 ms - platforms/math8.h
    │ │   └─    1.7 ms - platforms/shared/math8.h
    │ ├─    2.0 ms - fl/math/beat.h
    │ │ └─    1.0 ms - fl/math/trig8.h
    │ │   └─    1.0 ms - platforms/trig8.h
    │ │     └─    0.9 ms - platforms/shared/trig8.h
    │ └─    0.5 ms - fl/math/time_functions.h
    └─    3.2 ms - crgb.hpp
fl/ui.h (117.9ms)
  ├─   75.9 ms - fl/stl/json.h
  │ └─   58.5 ms - fl/stl/json/types.h
  │   └─    7.5 ms - fl/stl/limits.h
  ├─   10.1 ms - fl/ui_impl.h
  │ └─    9.5 ms - platforms/ui_defs.h
  │   ├─    2.1 ms - platforms/shared/ui/json/audio.h
  │   │ └─    0.9 ms - platforms/shared/ui/json/audio_internal.h
  │   ├─    1.5 ms - platforms/shared/ui/json/button.h
  │   │ └─    0.6 ms - platforms/shared/ui/json/ui_internal.h
  │   ├─    0.9 ms - platforms/shared/ui/json/checkbox.h
  │   ├─    0.8 ms - platforms/shared/ui/json/help.h
  │   └─    0.8 ms - platforms/shared/ui/json/number_field.h
  └─    6.8 ms - fl/stl/url.h
chipsets.h (27.8ms)
  ├─   11.2 ms - fl/chipsets/ucs7604.h
  │ └─    8.4 ms - fl/chipsets/encoders/ucs7604.h
  ├─    6.5 ms - fl/chipsets/apa102.h
  ├─    1.7 ms - fl/chipsets/lpd880x.h
  ├─    0.9 ms - fl/chipsets/p9813.h
  └─    0.8 ms - fl/chipsets/encoders/ws2816.h

TOP 20 SLOWEST OPERATIONS
--------------------------------------------------------------------------------
  1.  1411.5 ms - Source: FastLED.h
  2.  1411.5 ms - Total Source: 
  3.   680.5 ms - Source: fl/task/executor.h
  4.   654.5 ms - Total ParseClass: 
  5.   507.5 ms - Source: fl/fastled.h
  6.   360.9 ms - Source: fl/task/scheduler.h
  7.   351.2 ms - Source: fl/stl/singleton.h
  8.   350.5 ms - Source: fl/stl/thread_local.h
  9.   349.3 ms - Source: fl/stl/thread.h
 10.   349.2 ms - Source: platforms/thread.h
 11.   349.1 ms - Source: platforms/stub/thread_stub.h
 12.   349.1 ms - Source: platforms/stub/thread_stub_stl.h
 13.   341.0 ms - Source: thread
 14.   308.1 ms - Source: crgb.h
 15.   306.9 ms - Source: fl/gfx/crgb.h
 16.   305.4 ms - Source: fl/task/promise.h
 17.   301.9 ms - Source: fl/math/ease.h
 18.   299.5 ms - Source: fl/math/fixed_point.h
 19.   255.3 ms - Source: fl/stl/function.h
 20.   234.4 ms - Total InstantiateFunction: 

PERFORMANCE FLAGS
--------------------------------------------------------------------------------
⚠️  SLOW HEADERS (>50.0ms):
    - FastLED.h (1411.5ms)
    - fl/task/executor.h (680.5ms)
    - fl/fastled.h (507.5ms)
    - fl/task/scheduler.h (360.9ms)
    - fl/stl/singleton.h (351.2ms)
    - fl/stl/thread_local.h (350.5ms)
    - fl/stl/thread.h (349.3ms)
    - platforms/thread.h (349.2ms)
    - platforms/stub/thread_stub.h (349.1ms)
    - platforms/stub/thread_stub_stl.h (349.1ms)

⚠️  Template instantiation time is high (35.0% of total)
✓  Lexing time is acceptable (<10% of total)

RECOMMENDATIONS
--------------------------------------------------------------------------------
1. Consider optimizing FastLED.h (1411.5ms)
2. Consider optimizing fl/task/executor.h (680.5ms)
3. Consider optimizing fl/fastled.h (507.5ms)

================================================================================

zackees added a commit that referenced this pull request Apr 19, 2026
…tive (#2254)

Restores WiFi / Ethernet / lwIP throughput on ESP32-S3 when the I2S
LCD_CAM channel driver (and any other driver that spin-waits on DMA via
`task::run(us, ExecFlags::SYSTEM)`) is active. Addresses **Issue 1** of
#2254.

Two regressions made the cooperative yield path degenerate back into
`taskYIELD()`, which does NOT yield to lower-priority tasks:

1. **Tick-rate truncation** in `pumpCoroutines()`. On the default
   ESP-IDF tick rate of 100 Hz, `tick_period_us = 10000`, so a sub-tick
   request such as `pumpCoroutines(1000)` computed `ticks = 0` and fell
   through to `taskYIELD()`. Arduino-ESP32 at 1000 Hz tick happened to
   work; ESP-IDF-native projects (MoonLight among them) hit the bad path
   and saw ~1 FPS websockets while LEDs rendered correctly.

2. **Over-narrow deep-yield gate** in `task::run(us, ExecFlags::SYSTEM)`.
   The SYSTEM yield only took the deep path when
   `esp_wifi_get_mode() != WIFI_MODE_NULL`. That condition misses:
   - Ethernet-only deployments (no WiFi mode, but lwIP is live).
   - The pre-`WiFi.begin()` window where the mode is still
     WIFI_MODE_NULL but network stacks may be initializing.
   - Weak-linkage edge cases where `esp_wifi_get_mode` resolves to
     nullptr even when WiFi is in use.

Fix:
- `src/platforms/esp/32/coroutine_esp32.impl.hpp`: `pumpCoroutines()`
  now rounds a non-zero microseconds request UP to at least 1 FreeRTOS
  tick. `us == 0` still just does `taskYIELD()`.
- `src/fl/task/executor.cpp.hpp`: `task::run(us, ExecFlags::SYSTEM)`
  takes the deep-yield path whenever `microseconds > 0`, independent of
  WiFi mode. This is the path used by every driver's DMA spin-wait (I2S,
  SPI, LCD_SPI, LCD_CLOCKLESS, LCD_RGB, PARLIO, RMT, UART, I2S_SPI) and
  by `FastLED.show()`'s minFPS wait.

Net effect: any spin-wait loop that calls `task::run(>0, SYSTEM)` now
guarantees at least one FreeRTOS tick of delay per iteration on ESP32,
freeing the CPU for lwIP / WiFi / Ethernet tasks.

Validation on attached ESP32-S3:
- `bash test --cpp`: 301/301 tests pass
- `bash autoresearch esp32s3 --net`: 3/3 HTTP loopback tests PASS
- `bash autoresearch esp32s3 --rmt --strip-sizes 100`: PASS (1 test, 103ms)
- `bash autoresearch esp32s3 --spi --strip-sizes 100`: PASS (2/2 frames)
- `bash autoresearch esp32s3 --lcd`: pre-existing harness RPC timeout
  (same behavior on master, unrelated to this fix)

This is a re-application of the diff from the previously-closed PR #2290.

Refs #2254

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the fix-esp32s3-i2s-websocket-starvation-2254 branch November 17, 2026 07:12
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