Skip to content

ESP32-P4 PARLIO: FastLED.show() appears to block for ~16.7 ms before WS2812 data burst begins #2493

Closed

Description

@4wheeljive

Board / MCU

Other

LED Chipset

WS2812B / NeoPixel

FastLED Version

0a4ff47

Arduino / PlatformIO version

pioarduino 1.4.4

Operating System

Windows

Description

Report authored by ChatGPT

Summary

I’m using the FastLED ESP32-P4 PARLIO driver with WS2812B output and seeing behavior that suggests FastLED.show() is blocking for a fixed ~16.7 ms period, even though the actual WS2812 data burst for 256 LEDs is only ~7.6 ms, as expected.

The observed behavior looks like a fixed ~60 Hz wait / pacing / synchronization interval inside FastLED.show(), rather than time spent actively transmitting LED data.

This is significant because the FastLED.show() stage appears to block the main animation loop for ~16.7 ms regardless of whether I add a delay after show(), which effectively caps or strongly limits the overall frame rate.


Hardware / setup

  • MCU: ESP32-P4
  • LED type: WS2812B
  • Driver: FastLED PARLIO driver
  • LED arrangement: 12 parallel strips of 256 LEDs each
  • Scope: FNIRSI DPOS350P
  • CH1: profiling GPIO pin
  • CH2: LED data pin for one strip
  • Grounds connected to system ground
  • FastLED commit: 3.10.3+sha.0a4ff47
  • Board: EPS32-P4

Expected behavior

For a 256-pixel WS2812B strip:

256 LEDs × 24 bits × ~1.25 µs/bit ≈ 7680 µs

So the actual data burst per strip should be approximately:

~7.6–7.8 ms

With 12 strips driven in parallel, the expected data push time should still be roughly the same as for one 256-LED strip, assuming the PARLIO output is truly parallel.

I would therefore expect FastLED.show() to either:

  1. block for approximately the actual data transmission time, around ~7.6–7.8 ms, or
  2. queue an asynchronous transfer and return relatively quickly, depending on intended driver design.

Instead, I’m observing a consistent ~16.7 ms FastLED.show() duration.


Profiling code

I wrapped FastLED.show() with both my software profiler and a GPIO pin:

PROFILE_START("led_show");

digitalWrite(PROFILE_PIN, HIGH);
FastLED.show();
digitalWrite(PROFILE_PIN, LOW);

PROFILE_END();

I also tested with delays after show():

PROFILE_START("led_show");

digitalWrite(PROFILE_PIN, HIGH);
FastLED.show();
digitalWrite(PROFILE_PIN, LOW);

PROFILE_END();

delay(50);

I tried several different post-show delays, including approximately:

delay(5);
delay(20);
delay(50);
delay(100);

The measured FastLED.show() duration remained approximately ~16.7 ms in all cases.


Oscilloscope observations

Using the oscilloscope:

  • CH1 is connected to PROFILE_PIN
  • CH2 is connected to one WS2812B data line

Observed:

CH1 HIGH duration:  ~16.7 ms
CH2 LED data burst: ~7.6 ms

The CH2 data burst duration is exactly what I would expect for 256 WS2812B LEDs.

However, the LED data burst does not begin near the start of the FastLED.show() profiling window. Instead, it begins very near the end of the CH1 HIGH period.

More specifically:

CH2 LED burst starts roughly ~300 µs before CH1 drops LOW.
CH2 LED burst continues after FastLED.show() returns.

Approximate timeline:

CH1 PROFILE:  █████████████████
CH2 DATA:                 ████████
                           ↑ starts ~300 µs before FastLED.show() returns

So the actual LED data transmission appears to be mostly occurring after FastLED.show() has already returned, or at least after most of the show() blocking interval has elapsed.


Interpretation

This suggests that the ~16.7 ms FastLED.show() duration is not the WS2812 data transmission time.

Instead, it appears that FastLED.show() spends most of its time waiting / blocking / pacing / synchronizing, then starts or queues the PARLIO/DMA transfer near the end of the call, and returns shortly after the data burst begins.

The 16.7 ms duration is suspicious because:

16.7 ms ≈ 1 / 60 Hz

This looks like a fixed 60 Hz pacing interval, refresh limiter, or synchronization wait.


Why this matters

From the main animation loop’s perspective, this appears to be real blocking time.

Even though PARLIO/DMA may continue outputting data after FastLED.show() returns, the main sketch cannot begin computing the next animation frame until FastLED.show() returns.

So the effective minimum frame time becomes approximately:

render/update time + ~16.7 ms

For example, if rendering takes ~5 ms, the expected total frame time becomes:

16.7 ms + 5 ms ≈ 21.7 ms/frame ≈ 46 FPS

That matches the kind of frame rates I’m seeing in practice.


Key result

The LED wire timing itself appears correct:

Actual 256-LED WS2812 data burst: ~7.6 ms

But FastLED.show() consistently blocks for:

~16.7 ms

regardless of post-show delay.

This suggests that the issue is probably not WS2812 bit timing or PARLIO output speed, but a driver / FastLED-layer wait, throttle, frame pacing behavior, or synchronization point.


Questions

  1. Is the ESP32-P4 PARLIO driver intentionally enforcing a ~60 Hz update interval?
  2. Is there a max refresh rate / pacing mechanism active by default for this driver path?
  3. Should FastLED.setMaxRefreshRate(0) or similar disable this behavior?
  4. Is FastLED.show() expected to return before the PARLIO/DMA transfer is complete?
  5. If so, should the blocking/wait happen before queuing the next transfer?
  6. Would it be possible for the next frame to be computed while the previous transfer is still in progress?
  7. Is there currently a known synchronization/wait path in the PARLIO driver that could explain the fixed ~16.7 ms behavior?

Additional notes

The most important oscilloscope result is:

PROFILE_PIN high around FastLED.show(): ~16.7 ms
LED data burst on PARLIO output:        ~7.6 ms
LED burst begins near end of show():    ~300 µs before show() returns

This makes it look like the extra time is not actual LED transmission overhead, but a pre-transfer wait or pacing interval inside the FastLED.show() / PARLIO path.

Steps to reproduce

Not sure how to answer this.

Minimal sketch

Serial / debug output

Checklist

  • I have searched existing issues for duplicates
  • I have tested with the latest FastLED release or git master
  • I can reproduce this with a minimal sketch

Activity

  1. added
    status: triage
    type: bug
    on May 19, 2026
  2. 4wheeljive commented on May 20, 2026

    @4wheeljive
    ContributorAuthor

    Some more, interesting PARLIO data. The attached image shows test results based on the number of 256-led strips engaged (data other than FPS in microseconds):
    Notes and observations:

    • Stair-step performance drops between 4->5 strips and 8->9 strips
    • In the 5-8 strip tranche, total frame times and led_show times fluctuated much more widely than for the other tranches
    • For some reason, at 8 pins the average FastLED.show() time of 7200-7600 ms really is less than the LED data burst of ~7700
    • For some reason, at 5 pins the FPS seems to fluctuate a fair amount

    This pretty much disproves ChatGPT's theory about a fixed 16.7 ms wait being related to a 60 Hz cycle or something, but there is definitely some interesting stuff happening within the PARLIO algorithm.

    Image
  3. zackees commented on May 21, 2026

    @zackees
    Member

    Cross-reference: same root cause as #2420, originated as the fix for #2254

    The 16.7 ms ≈ ~16 × vTaskDelay(1) ticks on ESP32-P4 (CONFIG_FREERTOS_HZ=1000, set in ci/compiler/pio.py:205).

    Call chain inside FastLED.show():

    CFastLED::show()
     └─ onBeginFrame()
         └─ ChannelManager::waitForReady()                          // src/fl/channels/manager.cpp.hpp:417
             └─ waitForCondition() busy-loop
                 └─ task::run(250, ExecFlags::SYSTEM)               // src/fl/channels/manager.cpp.hpp:351
                     └─ pumpCoroutines(1000)                        // src/fl/task/executor.cpp.hpp:137
                         └─ vTaskDelay(max(1, us / tick_period))    // src/platforms/esp/32/coroutine_esp32.impl.hpp:83-86
                                = vTaskDelay(1) ≈ 1 ms minimum
    

    For 256 LEDs × 12 strips WS2812B, DMA drain ≈ 7.6 ms. The poll loop sleeps one tick per iteration, so the wait for the prior frame's DMA to complete costs ~8 × 1 ms + the 7.6 ms DMA = ~15–16 ms. The data burst can only launch after this wait — matching the scope trace where the burst starts ~300 µs before show() returns.

    The deep-yield was added on purpose to fix #2254 (I2S/PARLIO loops starving WiFi/lwIP — Bluetooth-style ~1 ms wait so the network task layer gets CPU). #2420 reports the same root cause from a different angle: 50 ms compounded drift over a 2500 ms sketch loop at 1 kHz tick rate; ~500 ms drift at the ESP-IDF default 100 Hz tick rate (10 ms per vTaskDelay(1)). @zackees identified the same ChannelManager per-frame floor in #2420 and proposed #2428 (compile-time Bus binding) as the structural fix — that decouples the default show() path from ChannelManager's polling entirely.

    Short-term workaround until #2428 lands: in ChannelManager::waitForCondition (src/fl/channels/manager.cpp.hpp:351) and IChannelDriver::waitForCondition (src/fl/channels/driver.cpp.hpp:22), replace task::run(250, SYSTEM) with task::run(0, SYSTEM) for a fast taskYIELD() instead of vTaskDelay(1). The deep-yield was about I2S audio busy-wait paths (#2254 Issue 1) — the PARLIO poll loop doesn't have the same WiFi-starvation risk because PARLIO DMA runs entirely in hardware/ISR after the first buffer submit, so the host CPU is free to yield among equal-priority tasks via taskYIELD() without monopolizing the scheduler.

  4. zackees commented on May 21, 2026

    @zackees
    Member

    I want to add here that this hack to get @ewowi working with bluetooth is completely unnecessary on the p4 because it doesn't have a network stack at all.

    So if you were to take all these waits and gate it behind a single function and that function was ifdef'd out specifically for

    #ifdef FL_IS_ESPP4 (is that the right fled define?)

    Then the risk would be minimal and would be an excellent stop gap until I make this part of the code automatic. The only reason it's in there is to allow vTaskDelay to run which is the minimal threshold for the Bluetooth coroutine task to engage

  5. added a commit that references this issue on May 21, 2026
  6. 4wheeljive commented on May 21, 2026

    @4wheeljive
    ContributorAuthor

    Thanks for the quick, deep dive on this. Very complicated stuff!!

    At this point, I still don't think the issue involves the 60 Hz theory.

    First, logically, under that theory, wouldn't there be a 16.7 mS delay/wait for all strip counts (not just 12)?

    Second, when I manually set FastLED.setMaxRefreshRate(60), I got ~58 FPS and FastLED.show() ~5900 uS. I got this after first switching to a newer commit: 36abcfb(from 260512) vs 0a4ff47 (from 260422). Before that, setting FastLED.setMaxRefreshRate(0) didn't change anything. After that, I got ~70 FPS and FastLED.show() ~3100 uS. That roughly matches the median 3028 figure you reported for 12x256 with no rate cap.

    So it seems that something else changed between 0a4ff47 (4/22) and 36abcfb (5/12) that addressed that lag.

    However, when I tried running 36abcfb(from 260512) on my S3/22x22/RMT/1x484 setup, the serial log monitor indicated 172 FPS and FastLED.show() at ~1400 uS, but no data was being pushed to the display (it stayed frozen on whatever is was showing during the reload). I tried the latest master (18eafd7) and got the same result. So I returned to 0a4ff47 (from 260422), and it displayed fine.

    Returning to the P4, I wanted to get some more performance data points at different pin numbers. I tried testing at 5 pins and the FPS jumped to 176, which was very surprising. I don't recall what the show() time was, but I decided to check things again with the scope and discovered that no LED data was actually being pushed. There was some voltage coming off the data pin that (if I recall correctly) bounced up and down between around +285mV and +365mV, but no obvious binary "bursts" like before. I tried different pins and numerous other tests (including at the latest master 18eafd7), but I could not get any good LED data. I realized that that's basically what happened when I tried the S3 on the later builds: FPS>170, but no actual LED data.

    Do you know if any users have gotten actual LED displays to work using any of the master commits since the latest Channel refactoring started around two weeks ago?

  7. zackees commented on May 22, 2026

    @zackees
    Member

    ignore the 60hz stuff, i don't know why the ai posted that.

    I'm nearly 100% sure it's the vTaskDelay(1ms) that's doing it. That's the minimal time slice for the esp to run a different task from the main thread., See the other referenced items for why i put this in. It needs to be enhanced, or just if def'd out for esp32p4. we dont' need them in the p4 because the p4 doesn't have network. keeping the cpu too busy starves the network.

  8. 4wheeljive commented on May 22, 2026

    @4wheeljive
    ContributorAuthor

    I replaced the two task::run(250, SYSTEM) with task::run(0, SYSTEM) as suggested above, and it didn’t fix anything. That was using 0a4ff47 (4/22). I tried that also with two more recent commits (as noted above), but I don’t get any LED data bursts at all. That’s why I asked if you know if anyone has successfully used any of the recent master builds with physical LED strips. It’s not clear to me whether the channel engine is actually working at all right now.

  9. zackees commented on May 22, 2026

    @zackees
    Member

    there is a vTaskSleep(1ms) in there, 250us seems low and not on master. Are you on a fork? This 250 is what the value used to be

  10. 4wheeljive commented on May 23, 2026

    @4wheeljive
    ContributorAuthor

    I’ve been using 0a4ff47 (4/22). I tried using two more recent commits (as noted above), but I don’t get any LED data bursts at all. That’s why I asked if you know if anyone has successfully used any of the recent master builds with physical LED strips. It’s not clear to me whether the channel engine is actually working at all right now.

  11. 4wheeljive commented on May 23, 2026

    @4wheeljive
    ContributorAuthor

    And it’s not just P4/PARLIO. As I mentioned, the master is not working for my S3/ RMT setup either. According to the serial monitor, it’s looping fine. But it’s not pushing any data out the pins.

  12. 4wheeljive commented on May 23, 2026

    @4wheeljive
    ContributorAuthor

    And I’m not sure if you caught what I mentioned several posts ago regarding the P4: when I have tried several recent commits, the lag is totally gone, without any other changes. But the pins are not pushing any data.

  13. zackees commented on May 23, 2026

    @zackees
    Member

    ok this is good info, i'll run auto research and try to narrow down the commit test for this

  14. 4wheeljive commented on May 23, 2026

    @4wheeljive
    ContributorAuthor

    Cool. Thx. One other issue I spotted that I wasn’t sure was worth mentioning, but might be after reading #2498…I wondered yesterday if my issue might relate to my use of the legacy addLeds<>. I looked into trying the new channel config approach, but I couldn’t find anything indicating that there is any way to set up pins as an offset continuation of a single CRGB leds (i.e., no overload with 2 numbers for #leds and starting #). Is that possible yet with the channel config method?

  15. 14 remaining items

  16. 4wheeljive commented on May 27, 2026

    @4wheeljive
    ContributorAuthor

    https://github.com/4wheeljive/FastFluid/blob/main/sdkconfig.defaults

    It occurred to me there might be something in my P4 config that helps you crack some things on your end. Note that my device is the Waveshare P4-WIFI6, so be sure to keep that in mind.

    In case it’s helpful, here’s my ini:
    https://github.com/4wheeljive/FastFluid/blob/main/platformio_p4.ini

  17. zackees commented on May 28, 2026

    @zackees
    Member

    Split the current missing-output regression into #2513 so this thread can stay focused on the original FastLED.show() timing/wait investigation. The new issue is scoped to the later report that P4/PARLIO on recent master is not pushing LED data and has no serial metrics: #2513

  18. zackees commented on May 28, 2026

    @zackees
    Member

    I'm clud, an AI working on behalf of @zackees.

    I split the complete ESP32-P4 PARLIO no-output report out into #2513 and fixed the driver-selection cause in #2515, which is now merged to master.

    Root cause: this was not the earlier ~16 ms FastLED.show() wait issue. On ESP32-P4, the default bus for clockless chipsets already intended to use PARLIO, but the legacy FastLED.addLeds<WS2812B, PIN, ...>() path still selected RMT when RMT support existed. In a sketch that first selected PARLIO with FastLED.setExclusiveDriver(...), the later RMT channel registration was disabled by exclusive-driver mode and PARLIO had never been registered for those legacy channels. The result was queued LED data with no enabled driver left to transmit it at frame end, matching the running-but-no-PARLIO-output failure.

    Fix: #2515 adds a legacy ClocklessPARLIO wrapper and routes ESP32-P4/C6/H2/C5 legacy clockless addLeds<> controllers through PARLIO. Master has that fix now.

    I also completed the fbuild prerequisite: fbuild v2.2.7 is released and FastLED now pins it on master via #2516. The fbuild-backed ESP32-P4 AutoResearch compile succeeds on master. A hardware AutoResearch run now deploys with fbuild, but still fails at the serial/RPC ping layer with invalid headers and HP_SYS_HP_WDT_RESET before it can execute the PARLIO test; I recorded that remaining validation blocker on #2513/#2510 separately from the fixed PARLIO no-output cause.

    Relevant links:

  19. zackees commented on May 28, 2026

    @zackees
    Member

    Current-state PARLIO timing check on master: the 16ms+ FastLED.show() symptom is still happening, although the old vTaskDelay(1) explanation is not the current code path.

    Test setup:

    • FastLED master: dc586bf368
    • Board: ESP32-P4 EV on COM25
    • Driver path: legacy FastLED.addLeds<WS2812B, PIN, GRB>() on 12 lanes, each 256 LEDs
    • Pins: 2,27,3,26,4,23,5,22,49,21,50,20
    • FastLED.setExclusiveDriver(fl::Bus::PARLIO) after registering strips returned 1
    • FastLED.setMaxRefreshRate(0, false)
    • Measurement: 48 back-to-back FastLED.show() calls, skipping the first 8 warmup samples, no serial printing inside the measured loop

    Serial result:

    exclusive_parlio=1
    frames=48
    skip=8
    samples=40
    show_min_us=23976
    show_avg_us=23990
    show_max_us=24004
    show_over_14ms=40
    PARLIO_TIMING_CHECK_DONE
    

    So the current answer is: yes, the user-visible 16ms+ blocking symptom is still present; on this current master check it is closer to 24ms steady-state for 12 x 256. The P4 wait loops already compile to task::run(0, SYSTEM) in both ChannelManager::waitForCondition() and IChannelDriver::waitForCondition(), so this result should not be attributed to the previous vTaskDelay(1) tick-floor theory without more instrumentation. It is now a remaining PARLIO timing/flush behavior issue.

    I also filed #2517 for the separate missing diagnostic discovered during the no-output investigation: when LED data is queued but no enabled driver will execute it, emit a loud FL_ERROR instead of silently dropping the frame.

  20. zackees commented on May 28, 2026

    @zackees
    Member

    Created the canonical umbrella for the remaining ESP32-P4 PARLIO timing/perf work: #2518. It links the current 24 ms measurement, the perf tracing PRs #2494 and #2508, the merged wait-loop mitigation #2503, the no-output fix #2515, fbuild release/bump work #2514/#2516, and the remaining AutoResearch blocker #2510.

  21. zackees commented on May 28, 2026

    @zackees
    Member

    I'm narrowing down to the culprit and it's look like it's scattered memory access to PSRAM and that a more sophisticated scheme needs to land to do computation in a scratch SRAM buffer then memcpy the whole thing to PSRAM. This will increase SRAM usage but should push performance toward the theoretical maximum.

  22. 4wheeljive commented on May 28, 2026

    @4wheeljive
    ContributorAuthor

    Awesome. Thanks for the update and all the hard work on this. I’ve been following along as best I can. Pretty amazing process!

  23. zackees commented on May 29, 2026

    @zackees
    Member

    It turns out not to be PSRAM slowness, it's actually transpose efficiency!! The AI is figuring out major speed improvements but I'm trying to hammer this in even more with SIMD for esp32p4

    The issue is that we the parlio driver needs to convert between N bit streams into 1 bit stream by reordering the data bits so that the driver can understand it.

  24. 4wheeljive commented on May 29, 2026

    @4wheeljive
    ContributorAuthor

    I'm not even close to understanding the technical issues on this, but it's been very interesting to watch the process and see the potential speed gains!

    FYI, I just tested the latest master 5ba7e6b on my P4/PARLIO 12x256 setup. It's racing along at ~50 FPS with a show() time of ~8400 uS, and it's pushing good LED data bursts per the scope!

  25. zackees commented on May 29, 2026

    @zackees
    Member

    It works like this:

    You have lanes of LED data each representing a strip like this:

    A1,A2,...
    B1,B2,...

    These numbers represent bits.

    But parlio wants just one lane that's transposed like this:

    A1,B1,A2,B2,...

    So a 16 lane will look like this:

    A1,B1,C1,D1,E1,F1,G1,H1,I1,J1,K1,L1,M1,N1,O1,P1,A2,....

    A technical detail is that each bit expands to 8 to represent the waveform through time, cut up into slots of ~125ns. So thats... a lot of bits.

    So there ways to do this fast, and ways that are slower. All the AI issues being filed right now on this is investigating are ways to make this as fast possible by exploring which strategies produce the fastest times.

  26. zackees commented on May 30, 2026

    @zackees
    Member

    Hi @4wheeljive — clud here, working for @zackees. Your oscilloscope observation was exactly right and it pointed at a real bug. Fixed, just merged to master. Details below.

    Your diagnosis was correct

    Your timeline:

    CH1 PROFILE:  █████████████████   (~16.7 ms show() block)
    CH2 DATA:                 ████████   (~7.6 ms WS2812 burst)
                               ↑ starts ~300 µs before show() returns
    

    That ~16.7 ms was NOT 60 Hz pacing — it was the engine doing all the encoding work before kicking off the DMA transmit, then the actual transmit started ~300 µs before show() returned because the engine submitted the first DMA buffer at the very end of beginTransmission(). The remainder of the TX happened in the background after show() returned — exactly what you observed.

    We instrumented this and reproduced your finding on our P4 rig with the same canonical 16-lane × 256-LED WS2812B workload:

    master (pre-fix) steady state, 16-lane × 256-LED WS2812B:
      total_us  =  16 995    (you measured ~16.7 ms — matches)
      show_us   =   9 439    (encode + driver setup happen here, BEFORE TX)
      wait_us   =   7 556    (TX, matches the 7 680 µs floor you computed)
    

    The "encode → submit-first → TX → wait" was strictly serial within a frame. Encode work and TX time were stacked, not overlapped.

    What landed (chronological, all on master)

    This is the full perf chain that fixed it:

    PR What it does Impact
    #2553 L2 — write transpose directly into DMA buffer (skip the 128 B stack + memcpy round-trip) +3.5 % encode
    #2555 pipe2 — 2-position software pipelining inside the transpose, lets the in-order RV32 P4 fill load-use stalls from position N with ALU ops from position N+1 +26 % encode
    #2557 pipe4 — empirical peak of the cross-position ILP curve (pipe6/pipe8 spilled the 32-GPR budget and regressed) +41 % encode
    #2559 BF1 — chipset-aware direct encode. Bypasses the 256-entry byte_lut entirely by exploiting the algebraic identity that Wave8 expansion is just bit-wise selection between two chipset constants (W0=bit0_pattern, W1=bit1_pattern). The bit-transpose of input bytes is already what spread_transpose16_symbol computes if you pass it input bytes directly — so we call the existing primitive ONCE per byte-position instead of 8× (once per symbol) 5.5× encode (1.75 ms / 16×256 frame, vs 9.65 ms baseline)
    #2564 eager-queue + breakdown instrumentation — added the parlioStreamValidate RPC and the FL_PARLIO_EAGER_QUEUE flag; verified that the engine WAS pre-encoding then serial-submitting (opt-in)
    #2565 eager-queue default ON — submits all pre-encoded buffers to the IDF TX queue immediately (which holds up to FL_ESP_PARLIO_HARDWARE_QUEUE_DEPTH=3). The PARLIO hardware then chains them via DMA descriptors with no inter-buffer ISR-latency gap encode/TX now interleaved by default

    How the encoder got fast enough to fit under the TX

    The Wave8 16-lane encode work per frame on 256 LEDs used to be ~9.65 ms. That was larger than the WS2812B 16-lane TX budget of 7.68 ms (256 LEDs × 24 bits × 1.25 µs/bit), so the CPU couldn't keep ahead of the DMA drain and ISR-chunked streaming couldn't actually overlap encode with TX even if you queued perfectly. BF1 + pipe4 cut encode to 1.75 ms — that's 4.4× faster than the TX. Suddenly the CPU has massive slack to encode during TX.

    The macro insight for BF1: the byte_lut builder in buildWave8ExpansionLUT literally does for each input bit, pick bit0_waveform or bit1_waveform. The whole 256×8 = 2 KB LUT is encoding redundant information — every entry is just bit-wise selection between two chipset constants. So:

    output_bit(symbol s, pulse p, lane L) = M0_p XOR (input_bit_(7-s)_of_lane_L AND D_p)
    
    where:
      M0_p = (W0 >> (7-p)) & 1   // bit-0 waveform's p-th pulse bit
      D_p  = M0_p XOR M1_p       // 1 if pulse is input-dependent, 0 if constant
    

    For typical WS2812B Wave8 (T1=400/T2=450/T3=400): W0=0xE0, W1=0xF8, D=0x18 → only 2 of 8 pulses are input-dependent, the other 6 are pure constants (0xFF or 0x00) regardless of LED color data. We were computing those redundantly 768 times per frame.

    The bit-transpose of input lane bytes (giving the per-symbol column bytes the OR-tree needs) is the same operation as spread_transpose16_symbol(input_bytes, cols). By happy coincidence the spread-LUT output layout is exactly what BF1's emit step needs. So one call to the existing primitive per byte-position replaces the previous 8 calls plus 16 byte_lut expansions.

    Op count per byte-position:

    • Before: 8 spread transposes + 16 byte_lut loads + memcpy = ~752 ops
    • After (BF1+pipe4): 1 spread transpose + 128 AND/XOR/store per 4 byte-positions, with pipe4 ILP filling the in-order P4 pipeline bubbles = ~150 effective cycles per position

    The interleaving fix (PR #2565)

    With encode under control, the remaining bug was the engine itself. The pre-fill loop in ParlioEngine::beginTransmission() encoded all ring buffers before calling mPeripheral->transmit(), then submitted exactly the first one to the IDF queue and relied on the txDoneCallback ISR to submit subsequent buffers. Even though FL_ESP_PARLIO_HARDWARE_QUEUE_DEPTH = 3 would have let the IDF chain multiple transmits via hardware DMA descriptors, the engine never exercised this.

    Fix: after the pre-fill loop, eagerly submit every pre-encoded buffer to the IDF queue. The IDF holds them in its queue (depth 3 covers our 2-buffer case) and the hardware chains them via DMA descriptors — no inter-buffer ISR-latency gap, no show() waiting for TX to finish before returning.

    What you should see now (16-lane × 256-LED WS2812B, current master)

    total_us  =  12 920   (was 16 995 — your ~16.7 ms drops to ~12.9 ms)
    show_us   =  11 277   (was 9 439 — slightly longer because TX is running here)
    wait_us   =   1 643   (was 7 556 — only TX tail remains when wait() is called)
    

    So:

    • FastLED.show() block: was ~16.7 ms → now ~11.3 ms (-32 %).
    • DMA burst on the wire: still ~7.68 ms, but now starts ~3 ms into show() instead of near the end. By the time show() returns, ~8 ms of the 7.68 ms TX has already happened, so FastLED.wait() only needs to block for ~1.6 ms.
    • Total frame budget (show() + wait()): was ~17 ms → now ~12.9 ms, a 24 % reduction.

    The remaining ~11 ms in show() is mostly FastLED's per-LED brightness/color-order processing for your 16 (or 12) × 256 = 3 072–4 096 CRGB elements before the PARLIO driver gets called. That's framework-level and unrelated to PARLIO.

    Answers to your specific questions

    1. Is the ESP32-P4 PARLIO driver intentionally enforcing a ~60 Hz update interval? No — the 16.7 ms was a coincidence with 1/60 Hz. It was the encode + serial-submit cost.
    2. Max refresh rate / pacing mechanism? No PARLIO-specific one; FastLED.setMaxRefreshRate(0) doesn't affect this path.
    3. Is show() expected to return before TX completes? Yes — and with the fix it now returns ~1.6 ms before TX completes, instead of ~300 µs before.
    4. If so, should the blocking/wait happen before queuing the next transfer? No — that's FastLED.wait() and you control when (if at all) you call it.
    5. Would it be possible for the next frame to be computed while the previous transfer is still in progress? Yes, and now it is. After show() returns, the previous frame's TX is still running for ~1.6 ms; you can start computing the next frame immediately. If your next-frame compute takes less than 1.6 ms, you have nothing to wait for.
    6. Known synchronization/wait path explaining the fixed 16.7 ms? Yes — the engine's pre-fill loop encoded the whole frame before submitting any DMA buffer. Fixed in perf(parlio): #2548 enable eager-queue by default — encode/TX now interleaved #2565.

    Try it

    Pull master and re-run your profiler. Your CH1 HIGH should drop from ~16.7 ms to ~12.9 ms (or ~11.3 ms if you wrap just show() without wait()), and the CH2 data burst should now start near the beginning of the CH1 HIGH window instead of the end. Effective max frame rate at 16×256 WS2812B is now ~78 FPS (up from ~60), and you have ~1.6 ms of CPU headroom during TX for animation logic.

    If you see WS2812 glitches from the inter-buffer DMA chaining on your specific board, -DFL_PARLIO_EAGER_QUEUE=0 reverts to the conservative one-submit-per-txDone pattern (which gives you back ~16.7 ms show() but eliminates any chaining risk).

    Let us know what your scope shows on master.

  27. zackees commented on May 31, 2026

    @zackees
    Member

    Closing as resolved. PARLIO show()/encode optimizations landed via #2553, #2555, #2557, #2559, #2564, #2565. Encode time reduced ~5.5x; frame total dropped from ~17 ms to ~12.9 ms. Reopen if regression appears.

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

    status: triagetype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions