-
Notifications
You must be signed in to change notification settings - Fork 4.9k
implement synchronous completion support in Sockets #15141
Conversation
|
||
} | ||
|
||
private static readonly bool IsWindows7OrBefore; |
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: s_isWindows7OrBefore
|
||
private static readonly bool IsWindows7OrBefore; | ||
|
||
static Socket() |
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.
How about putting this into a static method that's then used to initialize the field rather than using an explicit cctor? e.g.
private static readonly bool s_isWindows7OrBefore = GetIsWindows7OrBefore();
private static bool GetIsWindows7OrBefore()
{
Version osVersion = Environment.OSVersion.Version;
return osVersion.Major < 6 || (osVersion.Major == 6 && osVersion.Minor <= 1);
}
Unless something's changed, having an explicit cctor prevents usage of beforefieldinit on the type.
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.
Will do. I need to rework this anyway because it appears to fail on UAP.
var tup = (Tuple<Action<IntPtr, byte[], int, SocketError>, IntPtr, byte[], int>)args; | ||
tup.Item1(tup.Item2, tup.Item3, tup.Item4, SocketError.Success); | ||
}, Tuple.Create(callback, acceptedFd, socketAddress, socketAddressLen)); | ||
} |
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.
Seeing this code get deleted makes me smile :)
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.
I know what you mean 👍
int bytesReceived; | ||
SocketFlags receivedFlags; | ||
bytesReceived = 0; | ||
receivedFlags = SocketFlags.None; |
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.
Should this initialization now be moved down to after the subsequent if? We don't need to set these prior to that, right?
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, good catch. Fixed.
int bytesReceived; | ||
SocketFlags receivedFlags; | ||
bytesReceived = 0; | ||
receivedFlags = SocketFlags.None; |
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.
Same question here (and anywhere else the same pattern applies).
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.
Nice job, @geoffkizer. Do you have any perf measurements you can share on the impact of this on some microbenchmarks? I'd expect it to be fairly significant. Once it's merged in I'll plan to rerun some of my experiments with the managed ClientWebSocket implementation; I'd seen some notable perf hits because of this, so hopefully it'll see some sizeable improvements.
I did preliminary perf runs a while back and they were quite good. I will rerun on this change to confirm and get the latest results. |
@dotnet-bot |
@dotnet-bot test outerloop Ubuntu14.04 debug |
Quick and dirty perf results on my machine: For my simple request/response test, req/s went from 61016 to 70101, or about 15% improvement. This is Windows, my crappy laptop, client GC, using SocketAsyncEventArgs. The improvement I previously saw on bigger hardware was larger, but I don't have access to that hardware at the moment. |
41cdba9
to
ea0b2e2
Compare
@dotnet-bot Innerloop Windows_NT Debug Build and Test |
@dotnet-bot test Innerloop Windows_NT Debug Build and Test |
…5141) Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
…5141) Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
…5141) Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
…5141) Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
implement synchronous completion support in Sockets Commit migrated from dotnet/corefx@684af05
We complete all I/O asynchronously, even when the underlying OS operation actually completed synchronously.
Fix this so that both Windows and Unix can do synchronous socket completions.
@stephentoub @CIPop @davidsh @Priya91