Use TCP fast open and false start to reduce RTT from 3 to 1, when using WinHttp on latest Windows OS. (#2253)

* Use TCP fast open and false start to reduce RTT from 3 to 1, when using WinHttp on latest Windows OS.

* Address PR feedback - Remove logging the error.
This commit is contained in:
Ahson Khan 2021-06-22 16:06:24 -07:00 committed by GitHub
parent 70c3e72763
commit 1950e6d655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -220,6 +220,28 @@ void WinHttpTransport::CreateSessionHandle(std::unique_ptr<_detail::HandleManage
// ERROR_NOT_ENOUGH_MEMORY
GetErrorAndThrow("Error while getting a session handle.");
}
// These options are only available starting from Windows 10 Version 2004, starting 06/09/2020.
// These are primarily round trip time (RTT) performance optimizations, and hence if they don't get
// set successfully, we shouldn't fail the request and continue as if the options don't exist.
// Therefore, we just ignore the error and move on.
#ifdef WINHTTP_OPTION_TCP_FAST_OPEN
BOOL tcp_fast_open = TRUE;
WinHttpSetOption(
handleManager->m_sessionHandle,
WINHTTP_OPTION_TCP_FAST_OPEN,
&tcp_fast_open,
sizeof(tcp_fast_open));
#endif
#ifdef WINHTTP_OPTION_TLS_FALSE_START
BOOL tcp_false_start = TRUE;
WinHttpSetOption(
handleManager->m_sessionHandle,
WINHTTP_OPTION_TLS_FALSE_START,
&tcp_false_start,
sizeof(tcp_false_start));
#endif
}
void WinHttpTransport::CreateConnectionHandle(