fix: use mutable output buffer - #1
Merged
Merged
Conversation
brady-saronic
approved these changes
Jul 30, 2026
brady-saronic
left a comment
There was a problem hiding this comment.
Whoop Whoop! Good work @alexleensar !
There was a problem hiding this comment.
Pull request overview
This PR improves outbound socket transmission efficiency by replacing immutable bytes concatenation with a dedicated mutable output queue (OutputBuffer), and enhances Marti routing debug logs with more actionable context.
Changes:
- Introduces
OutputBuffer(deque-backed) and migrates socket TX paths to queue/appends + partial-write removal. - Updates Marti routing debug logging to include event UID, source callsign, and destinations.
- Adds unit tests covering ordering, batching, partial/blocked writes, and zero-progress disconnect behavior for both TAK and mgmt sockets.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_takclient.py | Adds unit tests for OutputBuffer immutability enforcement and socket TX ordering/batching/partial-write behaviors. |
| tests/test_mgmt.py | Adds unit test ensuring management responses are transmitted in-order via the updated buffering approach. |
| taky/cot/router.py | Improves Marti debug logging with UID/source/destinations context while preserving routing behavior. |
| taky/cot/mgmt.py | Switches management response buffering from bytes += ... to OutputBuffer.append(...). |
| taky/cot/client.py | Implements OutputBuffer and migrates SocketClient/SocketTAKClient TX buffering to avoid repeated bytes copying. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nickc-saronic
approved these changes
Jul 31, 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
bytes. Appending data and retaining the unsent portion repeatedly copies queued bytes, increasing CPU cost as the backlog grows.Unaddressed
Unbounded queue growth. This is a preexisting issue that can lead to a memory leak. Will fix in another PR.
Solution
OutputBufferbacked by adeque. It usesmemoryviewfor a single chunk, combines up to 4,096 bytes of small chunks per socket write, and removes only bytes accepted by the socket.Testing