- Notifications
You must be signed in to change notification settings - Fork4.9k
Reduce allocations in SslStream reading/writing by ~30%#13274
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Saves an allocation per read and write, ammortizing the costs across the whole stream's lifetime.
| internalvoidCompleteUser(objectuserResult) | ||
| internalvoidCompleteUser(intuserResult) | ||
| { |
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.
nit: capitalization
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.
nit: capitalization
Of what?
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.
Oh, in the debug message below? GitHub wasn't showing that on the comment view. Will lower-case the R.
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.
Yes, sorry for the confusion, I meant the R in the comment below.
geoffkizer commentedNov 2, 2016
LGTM. Nice work. I do think that longer-term we should revisit the async implementation pattern here and elsewhere. There are likely more wins to be had here. Even with your improvements, async objects account for ~80% of allocated bytes. |
stephentoub commentedNov 2, 2016
Absolutely. As you suggest, this is trying to make the best of the current design. Note that the SecBufferDesc allocation per operation can also be removed with a bit of work (see my comments in#12935), at which point all allocations per operation will be due to asynchrony. Once that's removed, we'll essentially have two allocations per read/write operation, one for the IAsyncResult and one for the Task wrapping it; it'll take some work, but we should be able to get that down to one, at which point I think that's generally the best we can do with the current API shape (though for some operations, we should be able to eliminate all allocations if they complete synchronously). |
benaadams commentedNov 2, 2016
LGTM - Excellent work! 👍 |
davidsh left a comment
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. Thanks@stephentoub !
- Change BufferAsyncResult to allow storing int result, without adding another field- Use that in both SslStream and NegotiateStream to avoid boxing an int per read and write- Also rename AsyncProtocolRequest.CompleteWithError to CompleteUserWithError, to avoid confusion and keep it consistent with the other CompleteUser methods.
stephentoub commentedNov 2, 2016
@dotnet-bot Test Outerloop Windows_NT Debug please |
stephentoub commentedNov 2, 2016
Thanks for the reviews, all. |
stephentoub commentedNov 2, 2016
@dotnet-bot Test OuterLoop Ubuntu14.04 Debug please ("arm32 emulator vms build and test on the main drive which is small. This is tracked with issuehttps://github.com/dotnet/coreclr/issues/6676") |
stephentoub commentedNov 2, 2016
@dotnet-bot Test OuterLoop Windows_NT Debug please (https://github.com/dotnet/corefx/issues/13281) |
stephentoub commentedNov 2, 2016
@dotnet-bot Test OuterLoop Windows_NT Debug please (https://github.com/dotnet/corefx/issues/13284) |
stephentoub commentedNov 3, 2016
@dotnet-bot Test OuterLoop Windows_NT Debug please (now thathttps://github.com/dotnet/corefx/issues/13284 is fixed) |
Uh oh!
There was an error while loading.Please reload this page.
#12935 reduced allocations in SslStream reading/writing by ~70%. This PR reduces it further by another ~30% from where it was after that PR.
Before (10K reads / 10K writes):

After (10K reads / 10K writes):

Main changes:
cc:@geoffkizer,@ericeil,@davidsh,@CIPop,@benaadams,@davidfowl
Contributes tohttps://github.com/dotnet/corefx/issues/11826