Repository navigation
perf(autoresearch): collapse per-byte + per-edge FL_WARN dumps (fbuild#755) - #3342
Conversation
…ild#755) Three high-volume FL_WARN sites in AutoResearchTest.cpp were dominating the Teensy 4 UART TX FIFO and stalling autoresearch between patterns when the wrapper consumed serial output. Even with fbuild #750's daemon-side batching fix, the device-side TX backpressure remained measurable on bursty 100-LED tests. 1) Per-byte capture dump (was line 809-814): - BEFORE: 2 header FL_WARNs + 24 individual ` [N] = 0xff` lines = 26 FL_WARNs per pattern per run. 4-pattern test = 104 lines. - AFTER: single FL_WARN with space-separated hex string = 1 FL_WARN per pattern per run. 4-pattern test = 4 lines. - Diagnostic value preserved (same 24 bytes, same hex format, same per-pattern context). Drops UART output by ~2.0 KB per test. 2) Raw-edge dump on decode failures (3 callers): - BEFORE: `EdgeRange(0, 256)` -- up to 257 FL_WARN lines per failure path. UART totally swamped on a single decode error. - AFTER: `EdgeRange(0, 32)` -- 33 FL_WARN lines per failure. Still enough to see whether the first transition is a clean bit-0 or a glitch. ~8x reduction per failure. 3) `dumpRawEdgeTiming()` body itself (was line 64-71): - BEFORE: one FL_WARN per edge (1 + N lines). - AFTER: single collated FL_WARN with all edges in compact `H580 L640 H586 L640` notation. Reads the same; ships in one WebSocket frame instead of N. Net effect on a 4-pattern OBJECT_FLED test with one decode failure: Before: ~26*4 (per-byte) + ~257 (raw-edge) = ~360 FL_WARN lines. After: ~4 (per-byte) + ~33 (raw-edge) = ~37 FL_WARN lines. ~10x reduction in serial-line traffic per test. C++ lint passes. Hardware validation deferred -- there's a pre- existing fbuild prototype-generator linkage conflict on `startup_early_hook` that's blocking the autoresearch deploy path on this branch; unrelated to this change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThree independent changes are made: diagnostic logging in ChangesDebug Output Consolidation
RPC Session Send Tracking
FlexIO RX Timeout Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
…build#755) Adds `RpcClient._sent_count` that increments on every `send()` / `send_and_match()` attempt (including retries). Exposed via the public `sent_count` property; logged in verbose mode when `close()` runs. Lets us correlate "wrapper sent N requests" against device-reported "Remote handled M requests" to detect daemon-side drops at the fbuild WebSocket bridge. Cheap insurance: the only state added is a single `int` per RpcClient instance; the increment is one statement in two hot paths. No behavior change in the absence of dropped messages. Per fbuild#755 user-direction: "keep track of how many json rpc messages you've sent. This has been a consistent problem since ever." Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ated diagnostic (fbuild#755) Two issues addressed: 1) `wait()` returned `SUCCESS` when the completion ISR fired even though `transfers_done == 0` -- the same cheat the FlexPWM driver had pre-#3219 (caller decodes a stale/empty buffer, reports fake errors). The diagnostic comment in this file at iter 4 of #3066 documented the case: DMA can signal "complete" with CITER=BITER and an all-zero buffer when the shifter never fired but the ISR misfired. Now we re-classify that path as `TIMEOUT` so the caller bails honestly. 2) On both TIMEOUT and SUCCESS paths the function emitted 3 verbose FL_WARN_F diagnostics each (~9 KB of register-state dumps per call). Collapsed into ONE collated FL_WARN_F per path with the single most useful number (`transfers_done=N/M`) and a couple of register peeks. ~10x reduction in FlexIO RX diagnostic line volume. FlexIO RX is dead-end per #3066 iter 9 so the deep register dumps were already mostly for historical reference -- not worth the ongoing UART bandwidth cost. C++ lint passes. FlexIO RX has no host-unit-test coverage (compile- gated to FL_IS_TEENSY_4X) so this is verified by compile + lint only. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp`:
- Around line 657-659: The FL_WARN_F call in the FlexIO RX timeout warning is
using incorrect format specifiers. Replace the `%s` format specifiers with `%u`
for the integer values being passed: timeout_ms, transfers_done, biter, and the
result of (mDma.error() ? 1 : 0). The `%s` specifier expects a C-string pointer
while these are all unsigned 32-bit integers, which causes undefined behavior
and potential hard faults. Apply the same fix to the similar timeout warning at
line 675.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 207708ad-f058-48a0-87e4-ed896f729ac1
📒 Files selected for processing (1)
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp
| FL_WARN_F("[FlexIO RX] TIMEOUT %sms done=%s/%s err=%s SHIFTSTAT=0x%x", | ||
| timeout_ms, transfers_done, biter, | ||
| (mDma.error() ? 1 : 0), FLEXIO1_SHIFTSTAT); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify printf-style format placeholders in FL_WARN_F calls in this file.
rg -nP 'FL_WARN_F\(".*%s' src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hppRepository: FastLED/FastLED
Length of output: 448
🏁 Script executed:
sed -n '650,680p' src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hppRepository: FastLED/FastLED
Length of output: 1669
🏁 Script executed:
grep -n "timeout_ms" src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp | head -20Repository: FastLED/FastLED
Length of output: 285
🏁 Script executed:
rg -n "FLEXIO1_SHIFTSTAT" src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp | head -5Repository: FastLED/FastLED
Length of output: 280
Fix %s/integer format mismatch in timeout warnings (can crash on target).
Lines 657 and 675 pass integer values to %s, which expects a C-string pointer. This is undefined behavior and can hard-fault in these diagnostic paths.
timeout_ms,transfers_done,biterare allu32; format specifiers should be%u(mDma.error() ? 1 : 0)is an integer literal; use%u
Suggested patch
- FL_WARN_F("[FlexIO RX] TIMEOUT %sms done=%s/%s err=%s SHIFTSTAT=0x%x",
- timeout_ms, transfers_done, biter,
- (mDma.error() ? 1 : 0), FLEXIO1_SHIFTSTAT);
+ FL_WARN_F("[FlexIO RX] TIMEOUT %ums done=%u/%u err=%u SHIFTSTAT=0x%x",
+ timeout_ms, transfers_done, biter,
+ (mDma.error() ? 1u : 0u), FLEXIO1_SHIFTSTAT);
@@
- FL_WARN_F("[FlexIO RX] empty-buffer SUCCESS reclassified as TIMEOUT (transfers=0/%s)", biter);
+ FL_WARN_F("[FlexIO RX] empty-buffer SUCCESS reclassified as TIMEOUT (transfers=0/%u)", biter);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| FL_WARN_F("[FlexIO RX] TIMEOUT %sms done=%s/%s err=%s SHIFTSTAT=0x%x", | |
| timeout_ms, transfers_done, biter, | |
| (mDma.error() ? 1 : 0), FLEXIO1_SHIFTSTAT); | |
| FL_WARN_F("[FlexIO RX] TIMEOUT %ums done=%u/%u err=%u SHIFTSTAT=0x%x", | |
| timeout_ms, transfers_done, biter, | |
| (mDma.error() ? 1u : 0u), FLEXIO1_SHIFTSTAT); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp` around
lines 657 - 659, The FL_WARN_F call in the FlexIO RX timeout warning is using
incorrect format specifiers. Replace the `%s` format specifiers with `%u` for
the integer values being passed: timeout_ms, transfers_done, biter, and the
result of (mDma.error() ? 1 : 0). The `%s` specifier expects a C-string pointer
while these are all unsigned 32-bit integers, which causes undefined behavior
and potential hard faults. Apply the same fix to the similar timeout warning at
line 675.
Summary
Direct follow-up to FastLED/fbuild#755 ("audit and remove as much as possible FL_WARN in autoresearch") and the wrapper-side work merged in #3341. Cuts three high-volume FL_WARN sites in
examples/AutoResearch/AutoResearchTest.cppso the device's UART TX FIFO stops being the gating bottleneck on bursty autoresearch tests.Changes
EdgeRange(0, 256)EdgeRange(0, 32)dumpRawEdgeTiming()bodyNet effect
4-pattern OBJECT_FLED test with one decode failure:
Test plan
bash lint --cpp— greenstartup_early_hookthat's blocking the autoresearch deploy path right now. Unrelated to this change. Will validate once that's unblocked.Context
fbuild#755 calls out this exact
[CORRUPTION @ LED X]+ per-byte verbosity as the dominant UART backpressure source after fbuild#750 fixed the daemon-side bridge. This PR is the first step in that audit.🤖 Generated with Claude Code
Summary by CodeRabbit
sent_countproperty, with an optional verbose summary when the client closes.