Skip to content

Conversation

@LPardue
Copy link
Contributor

@LPardue LPardue commented Jan 28, 2026

QUIC requires that stream data is presented to receivers as a contiguous byte
stream. The existing stream_recv() function allows applications to read
contiguous bytes from receive streams, copying data into an application-provided
slice.

Applications may have cases where they want to skip over data in a receive
stream without using it. stream_recv() could be used in these cases, at the cost
of copying.

This change adds a stream_discard function that acts similarly to stream_recv.
Callers indicate a maximum size of bytes to discard, and up to that many will be
discarded without a copy. The return values of this function are identical to
stream_recv, meaning that existing business logic and stream state management
can remain the same. Application can use either function interchangeably,
depending on their needs.

@LPardue LPardue requested a review from a team as a code owner January 28, 2026 03:37
@LPardue LPardue force-pushed the lucas/stream-discard branch from c5a3535 to 53f6bd5 Compare January 28, 2026 03:52
@jannes
Copy link

jannes commented Jan 28, 2026

i just wonder whether it's necessary to parameterize all those tests on emit/discard instead of some isolated discard tests

@LPardue
Copy link
Contributor Author

LPardue commented Jan 28, 2026

That's a good question. Many of the tests are intended to stress stream states or exercise flow control/congestion congestion as a result of taking data from streams. There's 60+ tests that were changed as part of this PR, I can't confidently tell if if its safe to not test the change if I don't test it. Future refactors may also cause unexpected breakages.

Given how critical streams are, and how many edge cases (or bugs) we've had to accommodate for, I don't really want to take risks.

QUIC requires that stream data is presented to receivers as a contiguous byte
stream. The existing stream_recv() function allows applications to read
contiguous bytes from receive streams, copying data into an application-provided
slice.

Applications may have cases where they want to skip over data in a receive
stream without using it. stream_recv() could be used in these cases, at the cost
of copying.

This change adds a stream_discard function that acts similarly to stream_recv.
Callers indicate a maximum size of bytes to discard, and up to that many will be
discarded without a copy. The return values of this function are identical to
stream_recv, meaning that existing business logic and stream state management
can remain the same. Application can use either function interchangeably,
depending on their needs.
@LPardue LPardue force-pushed the lucas/stream-discard branch from 53f6bd5 to a85e161 Compare January 28, 2026 17:28
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.

2 participants