KEMBAR78
avoid ProtocolToken allocations in TLS handshake by wfurt · Pull Request #86163 · dotnet/runtime · GitHub
Skip to content

Conversation

@wfurt
Copy link
Member

@wfurt wfurt commented May 12, 2023

ProtocolToken are somewhat high for 1000 TLS handshakes:
ProtocolToken

Since that is basically just container for status and buffet it seems unnecessary. There may be further optimizations but for now I turn it into struct and pass ref to it. To pass that across async boundary ReceiveBlobAsync no longer calls crypto e.g. it does only IO and ProcessTlsFrame (former ProcessBlob) is called explicit to process it.

AFAIK this is last low hanging fruit -> closes #68951

@wfurt wfurt added this to the 8.0.0 milestone May 12, 2023
@wfurt wfurt requested a review from a team May 12, 2023 17:58
@wfurt wfurt self-assigned this May 12, 2023
@wfurt wfurt marked this pull request as ready for review May 12, 2023 17:59
@ghost
Copy link

ghost commented May 12, 2023

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

ProtocolToken are somewhat high for 1000 TLS handshakes:
ProtocolToken

Since that is basically just container for status and buffet it seems unnecessary. There may be further optimizations but for now I turn it into struct and pass ref to it. To pass that across async boundary ReceiveBlobAsync no longer calls crypto e.g. it does only IO and ProcessTlsFrame (former ProcessBlob) is called explicit to process it.

AFAIK this is last low hanging fruit -> closes #68951

Author: wfurt
Assignees: wfurt
Labels:

area-System.Net.Security

Milestone: 8.0.0

}

private bool TryGetRemoteCertificateValidationResult(out SslPolicyErrors sslPolicyErrors, out X509ChainStatusFlags chainStatus, out ProtocolToken? alertToken, out bool isValid)
private bool TryGetRemoteCertificateValidationResult(out SslPolicyErrors sslPolicyErrors, out X509ChainStatusFlags chainStatus, ref ProtocolToken alertToken, out bool isValid)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: A bunch of these look like they could remain as out (e.g., NextMessage, ProcessTlsFrame)

Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Other than the pending comments, LGTM.

@wfurt wfurt merged commit 16fc92f into dotnet:main May 18, 2023
@wfurt wfurt deleted the token branch May 18, 2023 05:42
@ghost ghost locked as resolved and limited conversation to collaborators Jun 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce unnecessary allocations in TLS handshake (windows)

4 participants