Reduce Sockets mainloop Send/Receive statemachine size#2376
Reduce Sockets mainloop Send/Receive statemachine size#2376davidfowl merged 3 commits intoaspnet:devfrom
Conversation
|
|
||
| private volatile bool _aborted; | ||
|
|
||
| private SequencePosition SendEnd; |
There was a problem hiding this comment.
This is pretty gross, can this be left as a local (that will get hoisted).
There was a problem hiding this comment.
Yeah :-/
But it means the main loop doesn't need error handling; so there is only the try catch from the statemachine itself.
Putting it back in the loop means the finally has to go back to ensure Output.AdvanceTo(End); is always called; even when its crashing out.
There was a problem hiding this comment.
Is a consequence of not doing https://github.com/dotnet/corefx/issues/27465?
There was a problem hiding this comment.
Oh... maybe its not needed? dotnet/corefx#27596
|
Don't think it likes second commit; Complete throws... |
|
Hmm... that's libuv, which is uneffected |
|
Also test pass/fail results seem to be ignoring it..? |
|
Removed from sending statemachine struct 16+16+16+16+8+8 = 80 bytes (5 object refs) So 56 byte reduction overall and 4 object refs (slower copies) removed. |
|
Any idea how this 56 byte async state machine reduction affects the techempower benchmarks? |
|
It also trims the Send MoveNext from 576 il to 380 il and drops 3
Alas I am between locations atm, is there a magic incantation you can run? (for sockets) |
|
I’ll run it for you |
|
Thanks @davidfowl. I'm not trying to make it harder for you to do free work for us @benaadams. 😄 I was just wondering if you already did your own RPS measurements. |
|
Looks like it's within noise range but it does clean up a code a bit (looks nicer). |


Removed from sending statemachine struct 16+16+16+16+8+8 = 80 bytes (5 object refs)
Added to sending statemachine struct 16+8 = 24 bytes (1 object ref)
So 56 byte reduction overall and 4 object refs (slower copies) removed.
Similar to #2313
Before
DoSend.MoveNext is 4
.trys deep in ilAfter
ProcessSends.MoveNext is 1
.trys deep in ilRemoved (larger due to padding/alignment):
ReadResult { ReadOnlySequence { 2 x SequencePosition { object, int } }, bool }ReadOnlySequence { 2 x SequencePosition { object, int } }ExceptionAdded
SequencePosition { object, int }bool