-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a mode to the receive buffer to handle external buffers #4758
base: main
Are you sure you want to change the base?
Conversation
07dc4d9
to
06d5bcf
Compare
@@ -12,19 +12,31 @@ extern "C" { | |||
typedef enum QUIC_RECV_BUF_MODE { | |||
QUIC_RECV_BUF_MODE_SINGLE, // Only one receive with a single contiguous buffer at a time. | |||
QUIC_RECV_BUF_MODE_CIRCULAR, // Only one receive that may indicate two contiguous buffers at a time. | |||
QUIC_RECV_BUF_MODE_MULTIPLE // Multiple independent receives that may indicate up to two contiguous buffers at a time. | |||
QUIC_RECV_BUF_MODE_MULTIPLE, // Multiple independent receives that may indicate up to two contiguous buffers at a time. | |||
QUIC_RECV_BUF_MODE_EXTERNAL // Uses memory buffer provided by the app. Only one receive at a time, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think the fact that we use the word 'external' to mean the app currently has a reference to a chunk via a receive call might confuse things? One option is to all this _APP
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I wasn't very happy with the name already.
I might go with _APP_OWNED
(only _APP
seems a bit unclear to me).
194664c
to
3d390da
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4758 +/- ##
==========================================
- Coverage 87.00% 78.18% -8.82%
==========================================
Files 56 56
Lines 17400 17620 +220
==========================================
- Hits 15139 13777 -1362
- Misses 2261 3843 +1582 ☔ View full report in Codecov by Sentry. |
cd2c7e6
to
288ad7a
Compare
if (!!(Flags & QUIC_STREAM_OPEN_FLAG_EXTERNAL_BUFFERS) && | ||
Connection->Settings.StreamMultiReceiveEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if they want to use multi-receive for streams that don't use external buffers? I think we can't block that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would allow an "app buffer" stream when multi-receive is enabled?
The problem is that this stream would not support the multi-receive behavior (at least for now, we could make it happen), which could be confusing for the app.
And if app takes dependency on the fact that "app buffer" stream ignore multi-receive, then we can't add support without an API break or new flags.
// The allocation is done here to make the worker thread task failure free. | ||
// | ||
for (uint32_t i = 0; i < BufferCount; ++i) { | ||
QUIC_RECV_CHUNK* Chunk = CXPLAT_ALLOC_NONPAGED(sizeof(QUIC_RECV_CHUNK), QUIC_POOL_RECVBUF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use a pool allocator (to be stored in the worker, like the others) since this is (a) fixed size and (b) on the datapath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means each chunk will need a flag to track whether they are allocated from the pool or not then. The size of the chunk seems to be rather optimized (AllocLength restricted to 31bits to avoid a few extra bytes), is it ok to simply add a "flag" byte?
Which makes me realize I need to check the size of the app provided buffers won't override that bit.
@@ -103,6 +103,7 @@ typedef enum QUIC_TRACE_API_TYPE { | |||
QUIC_TRACE_API_DATAGRAM_SEND, | |||
QUIC_TRACE_API_CONNECTION_COMPLETE_RESUMPTION_TICKET_VALIDATION, | |||
QUIC_TRACE_API_CONNECTION_COMPLETE_CERTIFICATE_VALIDATION, | |||
QUIC_TRACE_API_STREAM_PROVIDE_RECEIVE_BUFFERS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our ETW plugin will need to be updated too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As well as the windbg plugin
TEST_EQUAL(ReceiveContext.ReceivedBytes, BufferSize); | ||
TEST_EQUAL(0, memcmp(SendDataBuffer, ReceiveDataBuffer, BufferSize)); | ||
} | ||
} | ||
#endif // QUIC_API_ENABLE_PREVIEW_FEATURES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be in the preview features section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done it yet, but I assumed the entire new API should go initially in the preview feature, until we treat it stable.
Let me know if I misunderstand what preview feature section is for and the new API doesn't need to be hidden behind it.
Co-authored-by: Nick Banks <nibanks@microsoft.com>
Co-authored-by: Nick Banks <nibanks@microsoft.com>
Description
As part of #4747, the receive buffer needs a mode to operate on buffers provided by the application.
This PR defines a new
QUIC_RECV_BUF_MODE_EXTERNAL
mode.QUIC_RECV_CHUNK
s now have a pointer to the actual buffer instead of an end-of-struct arrayTesting
Unit tests have been added
System test to be done.
Documentation
To be done