Skip to content

perf(comdelay): DIVIDER=0 passes comStatus straight through (TX-done-paced downlink) - #475

Draft
Mikefly123 wants to merge 1 commit into
feat/usp-radiofrom
perf/comdelay-divider0-passthrough
Draft

perf(comdelay): DIVIDER=0 passes comStatus straight through (TX-done-paced downlink)#475
Mikefly123 wants to merge 1 commit into
feat/usp-radiofrom
perf/comdelay-divider0-passthrough

Conversation

@Mikefly123

@Mikefly123 Mikefly123 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem

File downlink over the USP LoRa radio is throughput-capped by ComDelay: comStatusIn_handler only latches m_last_status, and run_handler (10 Hz via rateGroup10Hz -> downlinkDelay.run, topology.fpp:233) releases at most one comStatus per tick even when DIVIDER=0 — a ~10 frames/s ceiling (~2 kB/s at 248 B frames) regardless of air rate.

Fix

DIVIDER == 0 -> forward comStatusIn to comStatusOut immediately (TX-done-paced, no rate-group quantization). DIVIDER > 0 -> existing latched/tick-paced behavior unchanged.

Coherence: in passthrough mode the valid flag is never set, so a status cannot also be emitted by run_handler (no double emit). A status latched under DIVIDER > 0 before a runtime switch to 0 is still consumed by run_handler's compare_exchange (no loss). ComDelay is passive, so the forward executes on the radio-side caller thread — safe because comStatusOut feeds ComQueue's async input (enqueue only). A grep-able image-currency marker string is included (comdelay-div0-passthrough-20260723).

No existing ComDelay UT harness in the repo (CMakeLists UT block is the commented template), so no UT was added per scope; behavior was bench-validated instead.

HWIL A/B (2026-07-23, v5e flight + GRC-USP ground, P4_GFSK_75K both ends)

Radio-only downlink path (downlinkRepeater.CHANNEL_ENABLED=[DISABLED,ENABLED,ENABLED], downlinkDelay.DIVIDER=0), 178,704 B file via FileDownlink.SendFile, timed SendStarted->FileSent; flashed image currency verified by reading the marker string back from board flash (0x100b3b87).

Run Image Duration Effective B/s
baseline latched (fork b7931b1) 90.19 s 1981
passthrough #1 this PR 69.75 s 2562
passthrough #2 this PR 71.47 s 2500

~1.28x speedup; the link is now air-rate/TX-done-limited instead of tick-limited. Received files byte-identical to baseline (identical cksum). No QueueOverflow storms (baseline itself showed one benign ComCcsdsLora QueueOverflow; passthrough runs showed none), no panics/wedges/reboots. Cycle-slip warnings rose 42 -> ~200 per run (warnings only, known under RF+TM load). Regression checks on the passthrough image: DIVIDER=9 still tick-paces (~0.8 frame/s observed on a 3 kB partial), profile sweep P1->P2->P3->P4 + NO_OP all green.

🤖 Generated with Claude Code


Stack note (2026-07-30): rebased onto post-#477 feat/usp-radio (patch-collapse; now at c6df588), resolving the stale base. This PR is now the bottom of a native GitHub stack: feat/usp-radio <- #475 <- #479. The passthrough unit-test coverage lives in #479 (which stacks on this branch and ports the passthrough into ComDelayLogic).

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e9020091-026f-4cd5-8fba-50c41d36899d

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

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.

Problem: file downlink over the USP LoRa radio is throughput-capped by
ComDelay. comStatusIn_handler only latched the radio's comStatus, and
run_handler (10 Hz via rateGroup10Hz -> downlinkDelay.run) released at
most one status per tick even with DIVIDER=0, quantizing the whole
downlink to ~10 frames/s (~2 kB/s at 248 B frames) regardless of air
rate.

Mechanism/fix: when DIVIDER == 0, comStatusIn_handler now forwards the
status to comStatusOut immediately instead of latching it, so ComQueue
is paced purely by radio TX-done. DIVIDER > 0 keeps the existing
latched/tick-paced behavior unchanged. Coherence: in passthrough mode
the valid flag is never set, so a status can't also be emitted by
run_handler (no duplication); a status latched under DIVIDER > 0 before
a runtime switch to 0 is still consumed by run_handler's
compare_exchange (no loss). ComDelay is passive, so the forward runs on
the radio-side caller thread; that is safe because comStatusOut feeds
ComQueue's async input (enqueue only). A grep-able image-currency
marker string is included.

HWIL A/B on the v5e + GRC-USP bench (P4_GFSK_75K both ends, radio-only
downlink path, 178,704 B FileDownlink SendFile, SendStarted->FileSent):
- baseline (latched, DIVIDER=0): 90.19 s = 1981 B/s (matches the ~105 s
  / 200 kB manual measurement)
- passthrough: 69.75 s = 2562 B/s and 71.47 s = 2500 B/s  (~1.28x)
- received files byte-identical to baseline (same cksum); no
  QueueOverflow storms, no panics/wedges; DIVIDER=9 still tick-paces
  (~0.8 frame/s observed); profile sweep + NO_OP commanding unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mikefly123 added a commit that referenced this pull request Jul 31, 2026
Adds the passthrough test cases that belong with
perf/comdelay-divider0-passthrough (#475), mirroring the coverage
intended by closed PR #478:

- divider-0 forwards immediately (both SUCCESS and FAILURE values)
  without ever setting the latch, so run ticks cannot double-emit
- divider 0 -> N runtime transition latches/tick-paces again
- N -> 0 transition with a status already latched neither loses the
  latched status nor double-emits it (exactly one tick emission)
- invalid DIVIDER parameter falls back to the nonzero default and
  therefore latches, never passthroughs

Kept as a separate commit so the extraction/refactor layer diff of
this branch stays reviewable on its own.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Mikefly123
Mikefly123 force-pushed the perf/comdelay-divider0-passthrough branch from 3f89a2a to e6d22bc Compare July 31, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant