mirror of https://github.com/qt/qtgrpc.git
Force the QAbstractSocket::LowDelayOption for Http2 channel
Reference gRPC channel does this, to disable the Nagle's algorithm
and reduce the latency for the small flow control frames like
WINDOW_UPDATE and PING.
TODO: We should probably allow to opt out this behavior using
QGrpcChannelOptions. See QTBUG-134428.
Task-number: QTBUG-134428
Task-number: QTBUG-133254
Pick-to: 6.9.0 6.8 6.8.3
Change-Id: I96efac97077c7e527198bae9ca00500629bd4800
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
(cherry picked from commit 921212c1f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
eb60c36657
commit
3d5eaa101d
|
|
@ -823,6 +823,17 @@ void QGrpcHttp2ChannelPrivate::createHttp2Connection()
|
|||
Q_ASSERT_X(m_connection == nullptr, "QGrpcHttp2ChannelPrivate::createHttp2Connection",
|
||||
"Attempt to create the HTTP/2 connection, but it already exists. This situation is "
|
||||
"exceptional.");
|
||||
|
||||
// Nagle's algorithm slows down gRPC communication when frequently sending small utility
|
||||
// HTTP/2 frames. Since an ACK is not sent until a predefined timeout if the TCP frame is
|
||||
// not full enough, communication hangs. In our case, this results in a 40ms delay when
|
||||
// WINDOW_UPDATE or PING frames are sent in a separate TCP frame.
|
||||
//
|
||||
// TODO: We should probably allow users to opt out of this using QGrpcChannelOptions,
|
||||
// see QTBUG-134428.
|
||||
if (QAbstractSocket *abstractSocket = qobject_cast<QAbstractSocket *>(m_socket.get()))
|
||||
abstractSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
|
||||
|
||||
m_connection = QHttp2Connection::createDirectConnection(m_socket.get(), {});
|
||||
|
||||
if (m_connection) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue