RFR(s): Improving performance of Windows socket connect on the loopback adapter

Alan Bateman Alan.Bateman at oracle.com
Fri Jul 31 17:28:50 UTC 2020



On 28/07/2020 15:03, Nikola Grcevski wrote:
> Hi Alan,
>
> Thanks again for testing this change. I dug deep into the issue yesterday and got some answers from the Windows Networking team.
>
> The issue is that the flag TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS, which we passed in to completely eliminate the network delay, isn't defined (or checked) on Windows 10 versions prior to RS3 (Redstone 3). The flag was interpreted as TCP_INITIAL_RTO_DEFAULT_MAX_SYN_RETRANSMISSIONS, causing a retry of 255 times, each one taking 500ms. This made each individual connect delay take 128 seconds in total.
>
> I was advised to change the code to perform a runtime check on the exact Windows version and unless it's Windows 10RS3 or later, we should set the retransmissions to 1. Strangely enough, we can't set it to 0, which is a special value interpreted as use the default. With retransmission count of 1, we speed up the localhost connects on older versions of Windows by factor of 2.
>
> I have prepared a new webrev with the runtime check for review here:
> http://cr.openjdk.java.net/~adityam/nikola/fast_connect_loopback_4/
>
> For the Windows version check function I followed the naming standards the SDK uses in:
> https://docs.microsoft.com/en-us/windows/win32/api/versionhelpers/
>
> If it's not a suitable function name please let me know. They have added this helper function for .NET 4.8 but it's not there yet for Win32. Hopefully, it comes provided by Microsoft in a future SDK update and we can remove the helper. I attempted to use IsWindowsVersionOrGreater, but unfortunately that API doesn't allow me to specify the build number to detect RS3.
>
What cheap is VerifyVersionInfoW? The check is done everytime but the 
overhead might be in the noise. Overall it looks good to me.

-Alan


More information about the net-dev mailing list