Skip to content

Comms loop: handle inbound messages before sending queued outbound ones - #58

Merged
robdobsn merged 1 commit into
mainfrom
feature/comms-loop-inbound-first
Nov 16, 2026
Merged

robdobsn merged 1 commit into
mainfrom
feature/comms-loop-inbound-first

Conversation

@robdobsn

Copy link
Copy Markdown
Owner

CommsChannelManager::loop() sent queued outbound messages first and handled inbound ones second. A response to a request was therefore queued in one pass and not sent until the next: every response waited one main-loop period (about 2 ms) on every channel.

This handles inbound first, so the response goes out in the pass that handled the request.

Measured (ESP32-S3, Axiom)

Before After
Handler finished to response queued for sending 2.0 to 2.3 ms 0.12 to 0.16 ms
Request over USB serial, round trip 5.8 ms 3.9 ms
Request over WiFi (WebSocket), round trip 19 to 20 ms 17 to 19 ms (within noise)
File upload and download speeds unchanged

Tested

  • make check: 121 tests pass.
  • Requests, publishing and file transfers over WiFi and USB serial on the Axiom, and the raftpy device tests on a TinyS3.

Not tested

  • BLE with this change.

🤖 Generated with Claude Code

A response to a request was queued in one pass of the loop and sent in the next, because the outbound queue
was processed before the inbound one: every response waited a main-loop period (about 2 ms) on every channel.
Inbound is now handled first, so the response goes out in the pass that handled the request.

Measured on an ESP32-S3: the response was queued for sending 2.0 to 2.3 ms after the handler ran, now 0.12 to
0.16 ms; a USB serial request went from 5.8 ms to 3.9 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@robdobsn
robdobsn merged commit c59b812 into main Nov 16, 2026
1 check passed
@robdobsn
robdobsn deleted the feature/comms-loop-inbound-first branch November 16, 2026 01:05
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