Bug 1830918 - Provide a mechanism to disable the forcing of the tcp send buffer size on http/2 uploads r=necko-reviewers,valentin

In Bug 1596576 we will disable by default the forcing of tcp send buffer sizes on http/2 uploads.
This provides a mechanism for users to test early.

Differential Revision: https://phabricator.services.mozilla.com/D176927
This commit is contained in:
Andrew Creskey 2023-05-03 19:27:26 +00:00
parent 737b7ddeb3
commit cccc2a3121
2 changed files with 11 additions and 4 deletions

View File

@ -21,6 +21,7 @@
#include "Http2Stream.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Telemetry.h"
#include "nsAlgorithm.h"
#include "nsHttp.h"
@ -554,19 +555,25 @@ void Http2StreamBase::UpdateTransportReadEvents(uint32_t count) {
void Http2StreamBase::UpdateTransportSendEvents(uint32_t count) {
mTotalSent += count;
// Setting the TCP send buffer, introduced in
// https://bugzilla.mozilla.org/show_bug.cgi?id=790184, which the following
// comment refers to, is being removed once we verify no increases in error
// rate.
//
// normally on non-windows platform we use TCP autotuning for
// the socket buffers, and this works well (managing enough
// buffers for BDP while conserving memory) for HTTP even when
// it creates really deep queues. However this 'buffer bloat' is
// a problem for http/2 because it ruins the low latency properties
// necessary for PING and cancel to work meaningfully.
//
// If this stream represents a large upload, disable autotuning for
// the session and cap the send buffers by default at 128KB.
// (10Mbit/sec @ 100ms)
//
uint32_t bufferSize = gHttpHandler->SpdySendBufferSize();
if ((mTotalSent > bufferSize) && !mSetTCPSocketBuffer) {
if (StaticPrefs::network_http_http2_send_buffer_size() > 0 &&
(mTotalSent > bufferSize) && !mSetTCPSocketBuffer) {
mSetTCPSocketBuffer = 1;
mSocketTransport->SetSendBufferSize(bufferSize);
}

View File

@ -1388,8 +1388,8 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
1));
}
// The amount of seconds to wait for a http2 ping response before
// closing the session.
// If http2.send-buffer-size is non-zero, the size to set the TCP
// sendbuffer to once the stream has surpassed this number of bytes uploaded
if (PREF_CHANGED(HTTP_PREF("http2.send-buffer-size"))) {
mSpdySendBufferSize = (uint32_t)clamped(
StaticPrefs::network_http_http2_send_buffer_size(), 1500, 0x7fffffff);