Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve performance of SslStream reading and writing #12935
When SslStream didn't override Begin/EndRead/Write, we had to implement Read/WriteAsync with Task.Factory.FromAsync wrapping its internal Begin/End methods. But FromAsync has more overhead than the base Stream's ReadAsync/WriteAsync implementations, which uses TPL internals access to optimize the wrapping of the Begin/End methods. Now that SslStream does override Begin/EndReadWrite, we can delegate back to the base implementations.
Every call to each of EncryptMessage and DecryptMessage was allocating: - 4 SecurityBuffer instances - A SecurityBuffer - A SecBuffer - A GCHandle - A byte - A SecBufferDesc as well as creating 3 pinned GCHandles for EncryptMessage and 1 pinned GCHandle for DecryptMessage. This change removes all of that except for the 1 SecBufferDesc instance.
- Remove the Read/WriteAsync overloads that now just delegate to the base. They're not listed explicitly in the contract, so they're not needed. We can add them back if/when we do something more clever than the base does.
stephentoub merged commit
Oct 25, 2016
12 checks passed
12 checks passed
Innerloop CentOS7.1 Debug Build and Test Build finished.Details
Innerloop CentOS7.1 Release Build and Test Build finished.Details
Innerloop Linux ARM Emulator Debug Cross Build Build finished.Details
Innerloop Linux ARM Emulator Release Cross Build Build finished.Details
Innerloop OSX Debug Build and Test Build finished.Details
Innerloop OSX Release Build and Test Build finished.Details
Innerloop Ubuntu14.04 Debug Build and Test Build finished.Details
Innerloop Ubuntu14.04 Release Build and Test Build finished.Details
Innerloop Windows_NT Debug Build and Test Build finished.Details
Innerloop Windows_NT Release Build and Test Build finished.Details
OuterLoop Ubuntu14.04 Debug Build finished.Details
OuterLoop Windows_NT Debug Build finished.Details
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews.