Skip to content
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

Implement Connection Pool API #4832

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

anrossi
Copy link
Contributor

@anrossi anrossi commented Feb 20, 2025

Description

Provide an API for pooling connections across multiple RSS cores

Testing

Manual testing

Documentation

Documentation will be updated with the new API

Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 32.61803% with 157 lines in your changes missing coverage. Please review.

Project coverage is 86.24%. Comparing base (d8ef601) to head (93fe6c7).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/core/connection_pool.c 30.22% 157 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4832      +/-   ##
==========================================
- Coverage   87.49%   86.24%   -1.26%     
==========================================
  Files          56       57       +1     
  Lines       17726    17956     +230     
==========================================
- Hits        15510    15486      -24     
- Misses       2216     2470     +254     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anrossi anrossi force-pushed the anrossi/connection-pool-api branch from 54be6ca to 47753f0 Compare February 25, 2025 09:07
@anrossi anrossi force-pushed the anrossi/connection-pool-api branch from d22ce49 to acd61c6 Compare March 5, 2025 09:14
@anrossi anrossi marked this pull request as ready for review March 5, 2025 09:14
@anrossi anrossi requested a review from a team as a code owner March 5, 2025 09:14
Config->CibirIds ? Config->CibirIds[i] : NULL,
&Connections[i]);
if (QUIC_FAILED(Status)) {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If QuicConnAlloc() is successful inside QuicConnPoolTryCreateConnection, then should you free that memory and close connection here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if the QuicConnAlloc is successful, but an error is returned by a later operation inside TryCreateConnection, then TryCreateConnection should clean up the connection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think QuicConnPoolTryCreateConnection() is not cleaning up the connection, in cases like QuicConnParamSet() fails then "goto Error" is hit; pls check.

} QUIC_CONNECTION_POOL_FLAGS;

typedef struct QUIC_CONNECTION_POOL_CONFIG {
_In_ HQUIC Registration;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix up all the SAL annotations here to match the header.

_At_buffer_(_Curr_, _Iter_, NumberOfConnections, _Field_size_(CibirIdLength))
_Field_size_opt_(NumberOfConnections)
uint8_t** CibirIds; // Optional
_In_ uint8_t CibirIdLength; // Optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, you must set this to zero if not using CIBIR, so it's not strictly optional. Please make sure to update msquic.h too if necessary.


`Configuration`

An opened Configuration that provides the settings used to create each connection in the pool.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An opened Configuration that provides the settings used to create each connection in the pool.
The valid handle to an open and loaded configuration object that is used to create each connection in the pool.

This is more inline with the wording we use in ConnectionStart.md

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend you do pretty much the same for the rest of the parameters, so we can have consistent docs.


`Registration`

An opened Registration for creating the connection in.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An opened Registration for creating the connection in.
The valid handle to an open registration object.

Copied from ConnectionOpen.md


`CibirIdLength`

The number of bytes in each CIBIR ID. Not allowed to be zero if `CibirIds` is non-NULL.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say we should simply ignore CibirIds if this is zero. No need to be over restrictive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that brings up an interesting question about our API: do we test if the pointer is NULL, or do we look at the length field?

)
{
CXPLAT_SOCKET* Socket = NULL;
CXPLAT_UDP_CONFIG UdpConfig = { .RemoteAddress = RemoteAddress, };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CXPLAT_UDP_CONFIG UdpConfig = { .RemoteAddress = RemoteAddress, };
CXPLAT_UDP_CONFIG UdpConfig = { .RemoteAddress = RemoteAddress, 0 };

Let's be a bit more specific here

goto Error;
}
(*Connection)->ClientCallbackHandler = Handler;
if (Context != NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real need to check if NULL here.

Comment on lines +372 to +373


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

"[ lib] ERROR, %u, %s.",
Status,
"Connection Pool Parameter");
return Status;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not logging API exit by doing a return now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for below.

// The connection either owns the ServerNameCopy, or it was freed.
//
ServerNameCopy = NULL;
if (Status == QUIC_STATUS_OUT_OF_MEMORY) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I wouldn't special case out of memory errors. For one, they may be transient, and two there might be many errors you could special case, but it unnecessarily complicates the logic for such rare edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants