Repository navigation
Description
Summary
The ESP32 PARLIO clockless driver encodes any timing that isn't Wave3-eligible using Wave8 (8 ticks/bit). Wave8 is the maximum resolution — the driver has only two modes (Wave3 = 3 ticks, Wave8 = 8 ticks) and jumps straight to Wave8 when Wave3 can't represent the timing. For common WS2812 variants this triples DMA memory and roughly quadruples encode time versus what an intermediate tick count would cost.
Measured on ESP32-P4, 16 lanes × 256 LEDs, WS2812B_V5, PlatformIO -O2 (see #2522 for full data):
| Wave3 | Wave8 (current) | Wave4 (proposed) | |
|---|---|---|---|
| DMA bytes / frame | 36864 | 98880 | ~49440 |
| encode time | 3.6 ms | 14.6 ms | ~7 ms (est.) |
| ring alloc (3 buffers) | ~110 KB | ~340 KB | ~170 KB |
PSRAM is not the bottleneck — strided gather and the full transpose measured ×1.00 SRAM-vs-PSRAM on the P4 (cache hides it). The cost scales purely with ticks-per-bit.
Root cause
canUseWave3(timing) (src/fl/channels/wave3.cpp.hpp) quantizes the timing to 3 ticks and requires T0H→1 tick and T1H→2 ticks (distinct). WS2812B_V5 (T1=225, T2=355, T3=645, period 1225) gives:
T0H/period = 0.184 → ×3 = 0.55 → 1 tick
T1H/period = 0.474 → ×3 = 1.42 → 1 tick (same → not Wave3-eligible)
So the driver (correctly) falls back to Wave8 in ParlioEngine setup (parlio_engine.cpp.hpp ~L1426: mUseWave3 = canUseWave3(...), else mClockFreqHz = FL_ESP_PARLIO_CLOCK_FREQ_HZ = 8 MHz / Wave8). There is no in-between.
At 4 ticks the two levels separate cleanly (T0H→1, T1H→2), and 4 ticks is half of 8:
| N | T0H ticks | T1H ticks | usable | cost vs Wave8 |
|---|---|---|---|---|
| 4 | 1 | 2 | ✅ | 0.50× |
| 5 | 1 | 2 | ✅ | 0.625× |
| 6 | 1 | 3 | ✅ | 0.75× |
| 8 | 1 | 4 | ✅ (current) | 1.0× |
Proposed fix
Generalize the encoder from {Wave3, Wave8} to a WaveN that selects the minimum tick count (3..8) whose quantization gives distinct, in-range T0H/T1H ticks, then sizes the DMA buffer and clock accordingly. For WS2812B_V5 that picks N=4, halving DMA RAM and encode time vs Wave8.
Tasks
- Add
minWaveTicks(timing)returning the smallest N in [3,8] with distinct T0H/T1H ticks (generalizecanUseWave3). - Generalize the wave3/wave8 transpose+LUT into a WaveN path (or add Wave4/Wave5/Wave6 variants), keeping the 16-lane transpose as optimized as
wave3Transpose_16(Wave8 is currently ~1.5× less efficient per byte than wave3 — also worth closing). - Pick clock =
N × 1e9 / period; size ring buffer =samples × bytesPerSample. - Validate signal integrity on hardware via RX loopback (
bash autoresearch --parlio,mismatchedLeds == 0) at the chosen N — the lower tick count widens per-tick quantization error, so confirm it stays within WS2812 tolerance before lowering N. - Re-measure
encode_us+alloc_psram_bytesviameasureParlioand confirm the ~2× reduction.
Notes
- Complementary to perf(parlio): umbrella for ESP32-P4 PARLIO output and show timing work #2518 (ISR stream-encoding hides encode latency behind the transmission gap); WaveN reduces the latency at the source. Both help.
- Investigation, micro-benchmark (
benchMem), and full measurements are in perf(parlio): investigate why wave3 encode measures ~6µs/LED (LUT vs bit-swizzle vs gather vs logging) #2522. Instrumentation lives on branchfeat/parlio-pingpong-overlap.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(parlio bench): #2548 Phase 3 — register-cached fused v2 (negativ…
perf(parlio bench): #2548 Phase 3 — register-cached fused v2 (negativ…
perf(parlio bench): #2548 add pipe2 — 2-position software pipelining …
perf(parlio): #2548 pipe2 — 2-position software pipelining (+26%, BEA…
perf(parlio bench): #2548 Phase 3 — register-cached fused v2 (negativ…
perf(parlio bench): #2548 add pipe2 — 2-position software pipelining …
perf(parlio bench): #2548 Phase 3 — register-cached fused v2 (negativ…
perf(parlio bench): #2548 add pipe2 — 2-position software pipelining …
zackees commentedon Jun 2, 2026
Closing this as superseded by the merged PARLIO Wave8 optimization stack rather than as a WaveN implementation.
Evidence:
So the original latency/streaming reason to add WaveN/Wave4 is no longer blocking: the current Wave8 path has substantially more headroom than the proposed Wave4 target. I also re-ran the focused host coverage today with
bash test wave8, which passes.Important distinction: this does not mean the driver now has a generalized WaveN encoder or the DMA-RAM reduction proposed here. If the memory-footprint/tick-format goal becomes independently important, it should be reopened or split into a fresh issue scoped to DMA RAM reduction rather than encode latency.