You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(rmt5): single-channel fast path in beginTransmission (#5382) - #5419
A frame containing one RMT5 strip now acquires and submits its hardware channel directly, avoiding temporary shared_ptr copies, sorting, and pending-queue insertion/removal. Multi-strip frames retain their existing ordering and queue scheduling. Both paths share acquisition, pooled-buffer submission, and failure cleanup. Pending entries retain their ChannelData owner and read its immutable pin/timing rather than duplicating that metadata.
Initial measurements against master da963db, using fbuild 2.5.53+git.e21167a56700:
Measurement
Before
After
ESP32-C6 legacy RMT instructions/show
10,529
9,868
ESP32-C6 mean show()
112.5 µs
154.6 µs
ESP32-S3 Blink image_flash
318,787 B
318,695 B
The initial instruction saving is 661/show (6.3%). The initial +42.1 µs wall-time result triggered a merge hold despite passing the 280 µs gate. Attributed S3 RAM remains 22,499 B. The flash ratchet falls from 318,783 B to 318,695 B; budget ceilings remain unchanged.
The hold is now resolved by the alternating investigation below. No additional RMT driver change was needed.
Alternating C6 investigation, 2026-11-22: flash BEFORE da963db, AFTER 5b832b6, BEFORE, AFTER, applying the identical temporary diagnostic probe from stash diag5382 to both revisions. Each image passed:
After each image's normal gate, call timingDriftTest through the fbuild-backed RPC bench with {"pin":0,"numLeds":35,"iterations":2,"countInstructions":true}, then the same arguments with countInstructions:false. Every row is 554 shows, 35 LEDs, legacy RMT, 160 MHz, serial 8C:BF:EA:CF:87:B4. Instruction and real-cycle counts require separate runs: InstructionCounter temporarily repurposes IDF's cycle counter. Real cycles below are read with instruction counting disabled, not calculated from wall time. Timing includes the same micros probes in both modes; real-cycle intervals also include their small timestamp overhead. Post-show polling and histogram updates occur outside the measured interval.
Alternating image
Counter mode
Instructions/show
Real cycles/show
Mean µs
p50 µs
Max µs
DRAINING / READY after show
BEFORE1
instr
10547.9
-
139.7
140
173
554 / 0
BEFORE1
cycle
-
22160.6
137.4
137
149
554 / 0
AFTER1
instr
9870.1
-
155.5
156
167
554 / 0
AFTER1
cycle
-
24253.7
149.6
149
165
554 / 0
BEFORE2
instr
10536.0
-
139.6
140
171
554 / 0
BEFORE2
cycle
-
22152.2
137.3
137
149
554 / 0
AFTER2
instr
9869.1
-
155.4
155
168
554 / 0
AFTER2
cycle
-
24259.1
149.7
149
167
554 / 0
Diagnosis: the counter-off mean difference is +12.3 µs in the first pair and +12.4 µs in the second pair, within the accepted ±10–20 µs code-layout band. Counter-on differences are approximately +15.8 µs in both pairs. All 4,432 observed shows return DRAINING, never READY: the direct path does not wait for the transmission to complete. Source review confirms the hardware acquire, buffer copy, encoder reset, cache sync, and transmit operations are extracted unchanged from the pending path; no wait was added, and the success branch returns immediately after submission. Real cycles track elapsed time rather than exposing a separate serialization effect. The mean stays far below the roughly 1,050 µs LED wire time.
The original +42 µs is not reproduced under identical instrumentation and alternation. It is benchmark/code-layout sensitivity, not evidence of a new transmit wait. An earlier identical histogram-only probe on both revisions even reversed the sign (BEFORE 172.6 µs, AFTER 163.6 µs, twice). These experiments establish the accepted within-noise result; they do not identify a specific original instruction address or cache stall. Instructions remain consistently lower (about 10,542 to 9,870/show in this alternation). Merge hold released on this evidence.
Diagnostic changes are excluded from this PR. Real-cycle and post-show state controls landed separately in #5421, after removing the temporary 4 KiB histogram and isolating platform access.
Validation:
RED before implementation in quick and debug: the padding callback observed 4 ChannelData owners instead of the 2 caller/enqueued owners. The test checks initial hardware allocation, idle-channel reuse, exact transmitted bytes, DRAINING, completion, and READY.
Strengthened the existing two-strip/one-hardware-channel test to verify queued transmission pins and lengths.
GREEN: bash test channel_driver_rmt --debug (ASAN/UBSAN).
bash test --cpp.
bash lint.
uv run pytest -q ci/tests -n auto.
C6 AutoResearch and S3 bloat passed; independent code review approved.
This investigation: four alternating C6 AutoResearch passes plus eight raw RPC counter/state runs; independent source review found no added wait.
Submit a lone strip directly and share hardware submission with queued strips. Verify ownership and queue behavior, and lower the measured S3 flash ratchet.
Refs #5375, #5356.
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review.
Walkthrough
The RMT5 driver now uses shared transmission setup for direct and queued submissions. When one channel is submitted with no pending work, beginTransmission attempts it directly. Tests cover repeated single-channel frames and channel-limit transmission details.
Changes: RMT5 transmission
Layer / File(s)
Summary
Shared transmission setup and queued processing src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp, tests/unit/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp
Pending entries now store channel data pointers. The shared transmission function handles acquisition, buffer preparation, channel setup, DMA cache synchronization, and submission. Queued processing retains items for retry and tests verify transmission pins and buffer sizes.
Single-channel direct submission src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp, tests/unit/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp, tests/data/esp32s3_bloat_baseline.txt
A single channel is attempted directly when no work is pending. Tests check two successive frames, shared-owner counts, transmitted bytes, and driver state. The ESP32-S3 baseline records a 92 B reduction and a 318,695 B image.
Issue 5356: The single-channel direct path removes pending-queue bookkeeping for that case, addressing part of the issue’s stated goal of reducing per-frame channel bookkeeping.
Merge Risk: Minimal · up to 5b832
This change adds a direct submission path for single-strip RMT5 frames and keeps queued behavior for multi-strip frames. No actionable merge-blocking risk was found. The author reports the relevant tests and the flash ratchet passing.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "perf(rmt5): single-channel fast path in beginTransmission (#5382)" names the primary change. The summary and objectives describe a direct submission path for single-strip RMT5 frames in beg…
Linked Issues check
[#5382] The objective is a single-channel fast path in ChannelEngineRMTImpl::beginTransmission() that acquires and submits one hardware channel directly, without the shared_ptr copy, sort, and pending…
Out of Scope Changes check
The changed files are the RMT5 channel driver implementation, its unit test file, and the ESP32-S3 bloat baseline in tests/data/esp32s3_bloat_baseline.txt. The driver and test changes implement the #5…
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title "perf(rmt5): single-channel fast path in beginTransmission (#5382)" names the primary change. The summary and objectives describe a direct submission path for single-strip RMT5 frames in beginTransmission, which the title covers. The title uses a conventional prefix and an issue reference, and it is specific enough for a teammate scanning history. The title does not mention the shared transmitTransmitChannel refactor or the test additions, which is acceptable because the title need not cover every detail.
Full details: Linked Issues check
Explanation
[#5382] The objective is a single-channel fast path in ChannelEngineRMTImpl::beginTransmission() that acquires and submits one hardware channel directly, without the shared_ptr copy, sort, and pending-queue round trip, while multi-strip frames keep the queued path. The PR summary and description state that this path exists. The supporting code is in src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp, which introduces transmitChannel() as a shared acquisition and submission helper. The new test in tests/unit/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp checks that the padding callback sees 2 caller and enqueued owners instead of 4, and checks hardware allocation, idle-channel reuse, transmitted bytes, DRAINING, completion, and READY. This covers the required host test for a single-channel frame. The strengthened two-strip test checks queued pins and lengths, which covers the constraint that multi-strip behavior is preserved. Limitation: the beginTransmission() body was not read directly. The repository read was truncated at 16000 bytes and the focused diff reads failed, so the fast-path logic rests on the PR summary and the test's owner-count assertion. The ESP32-C6 instruction counts, S3 flash size, and latency gate results are reported by the author and were not reproduced. These are non-coding gates and were not assessed as coding requirements.
Full details: Out of Scope Changes check
Explanation
The changed files are the RMT5 channel driver implementation, its unit test file, and the ESP32-S3 bloat baseline in tests/data/esp32s3_bloat_baseline.txt. The driver and test changes implement the #5382 fast path and its test. The baseline change lowers the flash ratchet to match the reported image size and documents the change. It does not alter budget ceilings, according to the PR description and summary. The PR description states that the pending-entry change, which stores only ChannelDataPtr and reads pin and timing from ChannelData, supports the shared submission path. No unrelated behavior change was identified in the available evidence. Limitation: the full diff of the driver file could not be read, so this verdict rests on the PR summary.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Fix failing CI checks
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 22, 2026
Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).
github-actionsBot
added
sanitized
Title, body and conversation screened; review text requires separate screening.
and removed
sanitized
Title, body and conversation screened; review text requires separate screening.
labels
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5382; part of #5375 / #5356.
A frame containing one RMT5 strip now acquires and submits its hardware channel directly, avoiding temporary shared_ptr copies, sorting, and pending-queue insertion/removal. Multi-strip frames retain their existing ordering and queue scheduling. Both paths share acquisition, pooled-buffer submission, and failure cleanup. Pending entries retain their ChannelData owner and read its immutable pin/timing rather than duplicating that metadata.
Initial measurements against master da963db, using fbuild 2.5.53+git.e21167a56700:
The initial instruction saving is 661/show (6.3%). The initial +42.1 µs wall-time result triggered a merge hold despite passing the 280 µs gate. Attributed S3 RAM remains 22,499 B. The flash ratchet falls from 318,783 B to 318,695 B; budget ceilings remain unchanged.
The hold is now resolved by the alternating investigation below. No additional RMT driver change was needed.
Alternating C6 investigation, 2026-11-22: flash BEFORE da963db, AFTER 5b832b6, BEFORE, AFTER, applying the identical temporary diagnostic probe from stash
diag5382to both revisions. Each image passed:bash autoresearch esp32c6 --legacy --rmt --upload-port /dev/ttyACM1 --skip-lint --timeout 5mAfter each image's normal gate, call
timingDriftTestthrough the fbuild-backed RPC bench with{"pin":0,"numLeds":35,"iterations":2,"countInstructions":true}, then the same arguments withcountInstructions:false. Every row is 554 shows, 35 LEDs, legacy RMT, 160 MHz, serial8C:BF:EA:CF:87:B4. Instruction and real-cycle counts require separate runs: InstructionCounter temporarily repurposes IDF's cycle counter. Real cycles below are read with instruction counting disabled, not calculated from wall time. Timing includes the same micros probes in both modes; real-cycle intervals also include their small timestamp overhead. Post-show polling and histogram updates occur outside the measured interval.Diagnosis: the counter-off mean difference is +12.3 µs in the first pair and +12.4 µs in the second pair, within the accepted ±10–20 µs code-layout band. Counter-on differences are approximately +15.8 µs in both pairs. All 4,432 observed shows return DRAINING, never READY: the direct path does not wait for the transmission to complete. Source review confirms the hardware acquire, buffer copy, encoder reset, cache sync, and transmit operations are extracted unchanged from the pending path; no wait was added, and the success branch returns immediately after submission. Real cycles track elapsed time rather than exposing a separate serialization effect. The mean stays far below the roughly 1,050 µs LED wire time.
The original +42 µs is not reproduced under identical instrumentation and alternation. It is benchmark/code-layout sensitivity, not evidence of a new transmit wait. An earlier identical histogram-only probe on both revisions even reversed the sign (BEFORE 172.6 µs, AFTER 163.6 µs, twice). These experiments establish the accepted within-noise result; they do not identify a specific original instruction address or cache stall. Instructions remain consistently lower (about 10,542 to 9,870/show in this alternation). Merge hold released on this evidence.
Diagnostic changes are excluded from this PR. Real-cycle and post-show state controls landed separately in #5421, after removing the temporary 4 KiB histogram and isolating platform access.
Validation:
bash test channel_driver_rmt --debug(ASAN/UBSAN).bash test --cpp.bash lint.uv run pytest -q ci/tests -n auto.Flash command:
bash bloat esp32s3 --build.