Repository navigation
Description
Board / MCU
Other
LED Chipset
WS2812B / NeoPixel
FastLED Version
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:
- block for approximately the actual data transmission time, around ~7.6–7.8 ms, or
- 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
- Is the ESP32-P4 PARLIO driver intentionally enforcing a ~60 Hz update interval?
- Is there a max refresh rate / pacing mechanism active by default for this driver path?
- Should
FastLED.setMaxRefreshRate(0)or similar disable this behavior? - Is
FastLED.show()expected to return before the PARLIO/DMA transfer is complete? - If so, should the blocking/wait happen before queuing the next transfer?
- Would it be possible for the next frame to be computed while the previous transfer is still in progress?
- 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
4wheeljive commentedon May 20, 2026
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:
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.
zackees commentedon May 21, 2026
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 inci/compiler/pio.py:205).Call chain inside
FastLED.show():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 sameChannelManagerper-frame floor in #2420 and proposed #2428 (compile-timeBusbinding) as the structural fix — that decouples the defaultshow()path fromChannelManager's polling entirely.Short-term workaround until #2428 lands: in
ChannelManager::waitForCondition(src/fl/channels/manager.cpp.hpp:351) andIChannelDriver::waitForCondition(src/fl/channels/driver.cpp.hpp:22), replacetask::run(250, SYSTEM)withtask::run(0, SYSTEM)for a fasttaskYIELD()instead ofvTaskDelay(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 viataskYIELD()without monopolizing the scheduler.zackees commentedon May 21, 2026
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
debug(parlio): #2493 empirical replication — flash-based timing logger
4wheeljive commentedon May 21, 2026
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?
zackees commentedon May 22, 2026
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.
4wheeljive commentedon May 22, 2026
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.
zackees commentedon May 22, 2026
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
4wheeljive commentedon May 23, 2026
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.
4wheeljive commentedon May 23, 2026
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.
4wheeljive commentedon May 23, 2026
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.
zackees commentedon May 23, 2026
ok this is good info, i'll run auto research and try to narrow down the commit test for this
4wheeljive commentedon May 23, 2026
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?
14 remaining items
4wheeljive commentedon May 27, 2026
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
zackees commentedon May 28, 2026
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
zackees commentedon May 28, 2026
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 legacyFastLED.addLeds<WS2812B, PIN, ...>()path still selected RMT when RMT support existed. In a sketch that first selected PARLIO withFastLED.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
ClocklessPARLIOwrapper and routes ESP32-P4/C6/H2/C5 legacy clocklessaddLeds<>controllers through PARLIO. Master has that fix now.I also completed the fbuild prerequisite: fbuild
v2.2.7is 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 andHP_SYS_HP_WDT_RESETbefore 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:
zackees commentedon May 28, 2026
Current-state PARLIO timing check on master: the 16ms+
FastLED.show()symptom is still happening, although the oldvTaskDelay(1)explanation is not the current code path.Test setup:
dc586bf368FastLED.addLeds<WS2812B, PIN, GRB>()on 12 lanes, each 256 LEDs2,27,3,26,4,23,5,22,49,21,50,20FastLED.setExclusiveDriver(fl::Bus::PARLIO)after registering strips returned1FastLED.setMaxRefreshRate(0, false)FastLED.show()calls, skipping the first 8 warmup samples, no serial printing inside the measured loopSerial result:
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 bothChannelManager::waitForCondition()andIChannelDriver::waitForCondition(), so this result should not be attributed to the previousvTaskDelay(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_ERRORinstead of silently dropping the frame.zackees commentedon May 28, 2026
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.
zackees commentedon May 28, 2026
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.
4wheeljive commentedon May 28, 2026
Awesome. Thanks for the update and all the hard work on this. I’ve been following along as best I can. Pretty amazing process!
zackees commentedon May 29, 2026
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.
4wheeljive commentedon May 29, 2026
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!
zackees commentedon May 29, 2026
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.
zackees commentedon May 30, 2026
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:
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 ofbeginTransmission(). The remainder of the TX happened in the background aftershow()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:
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:
spread_transpose16_symbolcomputes if you pass it input bytes directly — so we call the existing primitive ONCE per byte-position instead of 8× (once per symbol)parlioStreamValidateRPC and theFL_PARLIO_EAGER_QUEUEflag; verified that the engine WAS pre-encoding then serial-submittingFL_ESP_PARLIO_HARDWARE_QUEUE_DEPTH=3). The PARLIO hardware then chains them via DMA descriptors with no inter-buffer ISR-latency gapHow 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
buildWave8ExpansionLUTliterally doesfor 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: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:
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 callingmPeripheral->transmit(), then submitted exactly the first one to the IDF queue and relied on thetxDoneCallbackISR to submit subsequent buffers. Even thoughFL_ESP_PARLIO_HARDWARE_QUEUE_DEPTH = 3would 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)
So:
FastLED.show()block: was ~16.7 ms → now ~11.3 ms (-32 %).show()instead of near the end. By the timeshow()returns, ~8 ms of the 7.68 ms TX has already happened, soFastLED.wait()only needs to block for ~1.6 ms.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
FastLED.setMaxRefreshRate(0)doesn't affect this path.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.FastLED.wait()and you control when (if at all) you call it.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.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()withoutwait()), 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=0reverts to the conservative one-submit-per-txDone pattern (which gives you back ~16.7 msshow()but eliminates any chaining risk).Let us know what your scope shows on master.
zackees commentedon May 31, 2026
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.
perf(channels): runtime NetworkDetector-gated yield in waitForConditi…
fix(core): adaptive yield in show()'s refresh throttle (FastLED#3762, f…