Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 15, 2025

  • Explore repository structure and understand codebase
  • Run existing tests to verify current state
  • Add ordered_packets field to TCB struct
  • Modify consume_unordered_packets to move data to ordered_packets
  • Update get_recv_window to account for ordered packets
  • Modify AsyncRead implementation to read from ordered_packets directly
  • Remove channel-based data flow (data_tx/data_rx)
  • Update tests to verify new behavior
  • Run all tests to ensure no regressions
Original prompt

This section details on the original issue you should resolve

<issue_title>TCP Read Optimization</issue_title>
<issue_description>The current implementation shares contiguous bytes with an AsyncRead consumer through a channel. However, this approach prevents backpressure, which leads to significant memory consumption if the sending rate is too fast. Furthermore, because the buffered data is immediately sent to the channel, the TCP receive window does not shrink. This disables TCP-level flow control, further exacerbating memory accumulation.

The solution I've come up with is to create an ordered list of packets within the TCB. The consumption method, each time it's called, will move the contiguous packets into this list.
The window calculation will also be modified to determine the actual window size by accounting for the sizes of both the in-order (ordered) and out-of-order packets.
Then, in the AsyncRead implementation, it will get the TCB, pop the first packet from the ordered collection, and write it into the read buffer.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #74


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: SajjadPourali <20374762+SajjadPourali@users.noreply.github.com>
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.

TCP Read Optimization

2 participants