Skip to content

WIP perf(parlio): frame-level ping-pong overlap (negative result — does not pipeline; refs #2518) - #2521

Closed
zackees wants to merge 3 commits into
masterfrom
feat/parlio-pingpong-overlap
Closed

zackees wants to merge 3 commits into
masterfrom
feat/parlio-pingpong-overlap

Conversation

@zackees

@zackees zackees commented May 28, 2026

Copy link
Copy Markdown
Member

Draft / do-not-merge. Scaffolds Approach A from #2518 (frame-level ping-pong double-buffer) AND documents the hardware finding that it does not deliver the projected speedup, with the identified root cause.

What this does

  • parlio_engine: encode frame N into the inactive ping-pong slot while frame N-1 drains, reusing 2 of the 3 already-allocated full-frame DMA buffers (zero new memory). Guarded by mOverlapArmed so only the single-full-frame fast path overlaps; the multi-chunk streaming path is byte-identical to before. Safety: frame N never encodes into the in-flight buffer.
  • examples/AutoResearch: adds a measureParlio pipelined_per_frame_us metric (tight show() loop, single drain) to measure overlap directly, plus free_sram/free_psram on ping.

Hardware result (ESP32-P4, 16×256, debug build) — NO speedup

pipelined_per_frame_us = 31772   ==   total_avg_us (serialized show+wait) = 31772
show_avg_us = 25449 (encode)     wait/wire ≈ 6.3ms

Every show() still costs encode(~25ms)+wire(~6ms). Frame N-1's DMA is not draining during frame N's encode, so the ping-pong buffers don't pipeline.

Root cause

beginTransmission() performs a mandatory per-frame disable()/enable() of the PARLIO peripheral ("required to reset the DMA state machine; without it consecutive transmissions silently fail"). That teardown serializes frames at the hardware level — N-1 cannot keep transmitting while N is reconfigured. Ping-pong buffering alone cannot overcome this.

Implications for #2518

  • The earlier "+24%" projection for Approach A is not realized; the current single-buffer path is effectively the practical maximum for the present driver structure + memory.
  • Real frame-level overlap needs a deeper change: avoid/relax the per-frame disable()/enable() so the peripheral can pipeline (or make the encoder faster via SIMD/2nd core). Tracked in perf(parlio): umbrella for ESP32-P4 PARLIO output and show timing work #2518.

Validation status

  • Compiles (host + P4). No regression: 60+ show() iterations stable, identical memory.
  • ⚠️ WS2812 signal correctness NOT validated — the EV board's RX loopback (GPIO5→6) is not wired. Required before any merge.

Stacks on #2519 (PARLIO buffer-sizing fix) and the autoresearch P4 enablement branch.

zackees added 3 commits May 28, 2026 02:12
… mem/timing probe

Route the AutoResearch console to HWCDC so `Serial` lands on the ESP32-P4-EV's
USB-Serial-JTAG port (the only connector on the dev board). The env had
ARDUINO_USB_MODE=1 but was missing ARDUINO_USB_CDC_ON_BOOT=1, so `Serial` went
to UART0 pins and no bytes reached the host — the core's HardwareSerial.h selects
HWCDCSerial only when both are set. This (with the fbuild bootloader-offset fix,
FastLED/fbuild#278) unblocks `bash autoresearch esp32p4 --parlio` (FastLED #2510).

Add a `measureParlio` RPC and free_sram/free_psram fields on `ping` so the
PARLIO DMA buffer-sizing fix (#2519) can be validated live: it reports the
internal-SRAM/PSRAM delta around channel allocation and steady-state show() us.

Refs #2510, #2519, FastLED/fbuild#278
…yet realized)

Implements Approach A from #2518: encode frame N into the inactive ping-pong
slot while frame N-1 drains, reusing 2 of the 3 already-allocated full-frame DMA
buffers (zero new memory). Guarded by mOverlapArmed so only the single-full-frame
fast path overlaps; the multi-chunk streaming path is byte-identical to before.

Adds a `measureParlio` pipelined_per_frame_us metric (tight show() loop, single
drain) to measure the overlap directly.

HARDWARE RESULT (ESP32-P4, 16x256, debug build): NO speedup yet.
  pipelined_per_frame_us = 31772  == total_avg_us (serialized) = 31772
Every show() still costs encode(~25ms)+wire(~6ms); frame N-1's DMA is NOT
draining during frame N's encode. Root cause appears to be the mandatory
per-frame peripheral disable()/enable() (reset of the PARLIO DMA state machine),
which prevents N-1 from transmitting while N is reconfigured/encoded. Ping-pong
buffers alone do not address this. No regression (60+ iterations stable, same
memory). DO NOT MERGE until the overlap is demonstrated and WS2812 signal
correctness is validated via RX loopback.

Refs #2518
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ccc42975-3541-4875-ab83-a9f348aad003

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/parlio-pingpong-overlap

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.

zackees added a commit that referenced this pull request May 30, 2026
…ter) (#2605)

All 9 binary-size workflows have been red on master since #2521
(`ci: make fbuild the default for board builds`). fbuild has two
deficiencies that compound here:

  - FastLED/fbuild#297 - fbuild does not emit build_info_<example>.json,
    so ci/compiled_size.py can never find it (the visible CI error).
  - FastLED/fbuild#304 - fbuild links framework .o files directly
    instead of archiving them, so unused ISR symbols (Tone.cpp on
    attiny85) get pulled in, inflating Blink by +10.1% (342 bytes).
    Even after #297 lands, the budget is already exceeded.

Both bugs are filed against fbuild. While they land, force
ci-check-compiled-size.py to use the platformio backend by
threading --backend platformio through to the inner ci.ci-compile
call. This restores green to attiny85_binary_size and the seven
check_teensy*_size + check_bluepill_size + check_uno_size workflows
with a single ~6-line YAML diff.

To revert once fbuild ships fixes: delete the three "--backend
platformio" tokens in build_template_binary_size.yml.
@zackees zackees closed this May 30, 2026
@zackees
zackees deleted the feat/parlio-pingpong-overlap 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