diff options
author | Mårten Nordheim <[email protected]> | 2024-07-19 12:38:16 +0200 |
---|---|---|
committer | Mårten Nordheim <[email protected]> | 2024-08-21 16:56:51 +0200 |
commit | 1e57371695752d4112fa59c89d38e58b977d55bc (patch) | |
tree | ba2ef032a443e6176e4524e23d50591fe1b2b28e | |
parent | 94e8bb96304fd2ea2ddfdf2499f4024131a16a8a (diff) |
Http2: speed up window_update for many streams
By keeping a list of blocked streams we can query just those instead of
any and all open streams when we get additional data transfer budget.
In the future we could additionally sort them by priority, if we start
taking priority into account.
Pick-to: 6.8
Task-number: QTBUG-126772
Change-Id: Ieab250893e157d2c50b0db2fdc10aa2dc3c38048
Reviewed-by: Dennis Oberst <[email protected]>
-rw-r--r-- | src/network/access/qhttp2connection.cpp | 13 | ||||
-rw-r--r-- | src/network/access/qhttp2connection_p.h | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp index 03ae5935ace..7f1a776e1c0 100644 --- a/src/network/access/qhttp2connection.cpp +++ b/src/network/access/qhttp2connection.cpp @@ -476,6 +476,8 @@ void QHttp2Stream::maybeResumeUpload() isUploadBlocked()); if (isUploadingDATA() && !isUploadBlocked()) internalSendDATA(); + else + getConnection()->m_blockedStreams.insert(streamID()); } /*! @@ -891,6 +893,10 @@ QHttp2Stream *QHttp2Connection::createStreamInternal_impl(quint32 streamID) stream = new QHttp2Stream(this, streamID); stream->m_recvWindow = streamInitialReceiveWindowSize; stream->m_sendWindow = streamInitialSendWindowSize; + + connect(stream, &QHttp2Stream::uploadBlocked, this, [this, stream] { + m_blockedStreams.insert(stream->streamID()); + }); return stream; } @@ -1740,10 +1746,13 @@ void QHttp2Connection::handleWINDOW_UPDATE() if (!valid || qAddOverflow(sessionSendWindowSize, qint32(delta), &sum)) return connectionError(PROTOCOL_ERROR, "WINDOW_UPDATE invalid delta"); sessionSendWindowSize = sum; - for (const auto &stream : std::as_const(m_streams)) { + + // Stream may have been unblocked, so maybe try to write again: + const auto blockedStreams = std::exchange(m_blockedStreams, {}); + for (quint32 blockedStreamID : blockedStreams) { + const QPointer<QHttp2Stream> stream = m_streams.value(blockedStreamID); if (!stream || !stream->isActive()) continue; - // Stream may have been unblocked, so maybe try to write again if (stream->isUploadingDATA() && !stream->isUploadBlocked()) QMetaObject::invokeMethod(stream, &QHttp2Stream::maybeResumeUpload, Qt::QueuedConnection); diff --git a/src/network/access/qhttp2connection_p.h b/src/network/access/qhttp2connection_p.h index 8bb49176a60..aa7f046cea6 100644 --- a/src/network/access/qhttp2connection_p.h +++ b/src/network/access/qhttp2connection_p.h @@ -19,6 +19,7 @@ #include <QtCore/qobject.h> #include <QtCore/qhash.h> +#include <QtCore/qset.h> #include <QtCore/qvarlengtharray.h> #include <QtCore/qxpfunctional.h> #include <QtNetwork/qhttp2configuration.h> @@ -325,6 +326,7 @@ private: QHttp2Configuration m_config; QHash<quint32, QPointer<QHttp2Stream>> m_streams; + QSet<quint32> m_blockedStreams; QHash<QUrl, quint32> m_promisedStreams; QList<quint32> m_resetStreamIDs; |