-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
pool async state in SslStream #69418
Conversation
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue Detailsfixes #68467 I had simple test code like using (var sslClient = new SslStream(_client, leaveInnerStreamOpen: true, delegate { return true; }))
using (var sslServer = new SslStream(_server, leaveInnerStreamOpen: true, delegate { return true; }))
{
await Task.WhenAll(
sslClient.AuthenticateAsClientAsync(clientOptions),
sslServer.AuthenticateAsServerAsync(serverOptions));
for (int j = 0; j < 100; j++)
{
var t = sslClient.ReadAsync(_clientBuffer, CancellationToken.None);
await sslServer.WriteAsync(_serverBuffer, CancellationToken.None);
await t;
}
} before the change it would allocate after the change
|
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
Outdated
Show resolved
Hide resolved
If you want to use it here, go ahead. But FWIW I think this case is a little more suspect. Pooling the read method objects seems fairly reasonable, as in general we expect the SslStreams themselves to be relatively long-lived, pooled themselves as part of a connection pool. One of the difficulties with object pooling is that it can create artificial references from gen2 to gen0, and so if the state you're using is itself likely to be gen2, this negative aspect of pooling mostly goes away. With Connection: close, though, that suggests this is a scenario where these streams aren't being pooled and are much less likely to be gen2, and as such it's more likely that pooling the state machines will end up creating gen2 to gen0 references. |
The |
The changeset now seems to include #69527, was this intentional? |
no, it was not intentional @rzikm. |
Nice! Are the other allocations the handshake? |
There are some @davidfowl. Some are easy to avoid some of them are more tricky. It would be great if you can share any real workload you care about. With that we can investigate allocations as well as other runtime parts. |
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.
LGTM
Failing Quic tests are unrelated and will be fixed by #69709 (msquic upgrade) |
fixes #68467
I had simple test code like
before the change it would allocate
after the change
EnsureFullTlsFrameAsync
is also used in handshake so it should help little withConnection: close
as well.