bug 1124717 - 3/4 make h2/spdy default peer max concurrent setting configurable r=hurley
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1314,16 +1314,17 @@ pref("network.http.spdy.chunk-size", 160
pref("network.http.spdy.timeout", 180);
pref("network.http.spdy.coalesce-hostnames", true);
pref("network.http.spdy.persistent-settings", false);
pref("network.http.spdy.ping-threshold", 58);
pref("network.http.spdy.ping-timeout", 8);
pref("network.http.spdy.send-buffer-size", 131072);
pref("network.http.spdy.allow-push", true);
pref("network.http.spdy.push-allowance", 131072);
+pref("network.http.spdy.default-concurrent", 100);
// alt-svc allows separation of transport routing from
// the origin host without using a proxy.
pref("network.http.altsvc.enabled", true);
pref("network.http.altsvc.oe", true);
pref("network.http.diagnostics", false);
--- a/netwerk/protocol/http/ASpdySession.h
+++ b/netwerk/protocol/http/ASpdySession.h
@@ -45,16 +45,18 @@ public:
const static uint32_t kTCPSendBufferSize = 131072;
// until we have an API that can push back on receiving data (right now
// WriteSegments is obligated to accept data and buffer) there is no
// reason to throttle with the rwin other than in server push
// scenarios.
const static uint32_t kInitialRwin = 256 * 1024 * 1024;
+ const static uint32_t kDefaultMaxConcurrent = 100;
+
// soft errors are errors that terminate a stream without terminating the
// connection. In general non-network errors are stream errors as well
// as network specific items like cancels.
bool SoftStreamError(nsresult code)
{
if (NS_SUCCEEDED(code) || code == NS_BASE_STREAM_WOULD_BLOCK) {
return false;
}
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -84,17 +84,16 @@ Http2Session::Http2Session(nsISocketTran
, mContinuedPromiseStream(0)
, mShouldGoAway(false)
, mClosed(false)
, mCleanShutdown(false)
, mTLSProfileConfirmed(false)
, mGoAwayReason(NO_HTTP_ERROR)
, mGoAwayID(0)
, mOutgoingGoAwayID(0)
- , mMaxConcurrent(kDefaultMaxConcurrent)
, mConcurrent(0)
, mServerPushedResources(0)
, mServerInitialStreamWindow(kDefaultRwin)
, mLocalSessionWindow(kDefaultRwin)
, mServerSessionWindow(kDefaultRwin)
, mOutputQueueSize(kDefaultQueueSize)
, mOutputQueueUsed(0)
, mOutputQueueSent(0)
@@ -114,17 +113,17 @@ Http2Session::Http2Session(nsISocketTran
LOG3(("Http2Session::Http2Session %p serial=0x%X\n", this, mSerial));
mInputFrameBuffer = new char[mInputFrameBufferSize];
mOutputQueueBuffer = new char[mOutputQueueSize];
mDecompressBuffer.SetCapacity(kDefaultBufferSize);
mDecompressor.SetCompressor(&mCompressor);
mPushAllowance = gHttpHandler->SpdyPushAllowance();
-
+ mMaxConcurrent = gHttpHandler->DefaultSpdyConcurrent();
mSendingChunkSize = gHttpHandler->SpdySendingChunkSize();
SendHello();
mLastDataReadEpoch = mLastReadEpoch;
mPingThreshold = gHttpHandler->SpdyPingThreshold();
mNegotiatedToken.AssignLiteral(HTTP2_DRAFT_LATEST_TOKEN);
--- a/netwerk/protocol/http/Http2Session.h
+++ b/netwerk/protocol/http/Http2Session.h
@@ -130,17 +130,16 @@ public:
const static uint32_t kDefaultBufferSize = 2048;
// kDefaultQueueSize must be >= other queue size constants
const static uint32_t kDefaultQueueSize = 32768;
const static uint32_t kQueueMinimumCleanup = 24576;
const static uint32_t kQueueTailRoom = 4096;
const static uint32_t kQueueReserved = 1024;
- const static uint32_t kDefaultMaxConcurrent = 100;
const static uint32_t kMaxStreamID = 0x7800000;
// This is a sentinel for a deleted stream. It is not a valid
// 31 bit stream ID.
const static uint32_t kDeadStreamID = 0xffffdead;
// below the emergency threshold of local window we ack every received
// byte. Above that we coalesce bytes into the MinimumToAck size.
--- a/netwerk/protocol/http/SpdySession31.cpp
+++ b/netwerk/protocol/http/SpdySession31.cpp
@@ -58,17 +58,16 @@ SpdySession31::SpdySession31(nsISocketTr
, mInputFrameDataLast(false)
, mInputFrameDataStream(nullptr)
, mNeedsCleanup(nullptr)
, mShouldGoAway(false)
, mClosed(false)
, mCleanShutdown(false)
, mDataPending(false)
, mGoAwayID(0)
- , mMaxConcurrent(kDefaultMaxConcurrent)
, mConcurrent(0)
, mServerPushedResources(0)
, mServerInitialStreamWindow(kDefaultRwin)
, mLocalSessionWindow(kDefaultRwin)
, mRemoteSessionWindow(kDefaultRwin)
, mOutputQueueSize(kDefaultQueueSize)
, mOutputQueueUsed(0)
, mOutputQueueSent(0)
@@ -84,17 +83,17 @@ SpdySession31::SpdySession31(nsISocketTr
LOG3(("SpdySession31::SpdySession31 %p serial=0x%X\n", this, mSerial));
mInputFrameBuffer = new char[mInputFrameBufferSize];
mOutputQueueBuffer = new char[mOutputQueueSize];
zlibInit();
mPushAllowance = gHttpHandler->SpdyPushAllowance();
-
+ mMaxConcurrent = gHttpHandler->DefaultSpdyConcurrent();
mSendingChunkSize = gHttpHandler->SpdySendingChunkSize();
GenerateSettings();
mLastDataReadEpoch = mLastReadEpoch;
mPingThreshold = gHttpHandler->SpdyPingThreshold();
}
--- a/netwerk/protocol/http/SpdySession31.h
+++ b/netwerk/protocol/http/SpdySession31.h
@@ -129,17 +129,16 @@ public:
const static uint32_t kDefaultBufferSize = 2048;
// kDefaultQueueSize must be >= other queue size constants
const static uint32_t kDefaultQueueSize = 32768;
const static uint32_t kQueueMinimumCleanup = 24576;
const static uint32_t kQueueTailRoom = 4096;
const static uint32_t kQueueReserved = 1024;
- const static uint32_t kDefaultMaxConcurrent = 100;
const static uint32_t kMaxStreamID = 0x7800000;
// This is a sentinel for a deleted stream. It is not a valid
// 31 bit stream ID.
const static uint32_t kDeadStreamID = 0xffffdead;
// below the emergency threshold of local window we ack every received
// byte. Above that we coalesce bytes into the MinimumToAck size.
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -189,16 +189,17 @@ nsHttpHandler::nsHttpHandler()
, mCoalesceSpdy(true)
, mSpdyPersistentSettings(false)
, mAllowPush(true)
, mEnableAltSvc(true)
, mEnableAltSvcOE(true)
, mSpdySendingChunkSize(ASpdySession::kSendingChunkSize)
, mSpdySendBufferSize(ASpdySession::kTCPSendBufferSize)
, mSpdyPushAllowance(32768)
+ , mDefaultSpdyConcurrent(ASpdySession::kDefaultMaxConcurrent)
, mSpdyPingThreshold(PR_SecondsToInterval(58))
, mSpdyPingTimeout(PR_SecondsToInterval(8))
, mConnectTimeout(90000)
, mParallelSpeculativeConnectLimit(6)
, mRequestTokenBucketEnabled(true)
, mRequestTokenBucketMinParallelism(6)
, mRequestTokenBucketHz(100)
, mRequestTokenBucketBurst(32)
@@ -1282,16 +1283,24 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
rv = prefs->GetIntPref(HTTP_PREF("spdy.push-allowance"), &val);
if (NS_SUCCEEDED(rv)) {
mSpdyPushAllowance =
static_cast<uint32_t>
(clamped(val, 1024, static_cast<int32_t>(ASpdySession::kInitialRwin)));
}
}
+ if (PREF_CHANGED(HTTP_PREF("spdy.default-concurrent"))) {
+ rv = prefs->GetIntPref(HTTP_PREF("spdy.default-concurrent"), &val);
+ if (NS_SUCCEEDED(rv)) {
+ mDefaultSpdyConcurrent =
+ static_cast<uint32_t>(std::max<int32_t>(std::min<int32_t>(val, 9999), 1));
+ }
+ }
+
// The amount of seconds to wait for a spdy ping response before
// closing the session.
if (PREF_CHANGED(HTTP_PREF("spdy.send-buffer-size"))) {
rv = prefs->GetIntPref(HTTP_PREF("spdy.send-buffer-size"), &val);
if (NS_SUCCEEDED(rv))
mSpdySendBufferSize = (uint32_t) clamped(val, 1500, 0x7fffffff);
}
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -100,16 +100,17 @@ public:
bool IsHttp2DraftEnabled() { return mHttp2DraftEnabled; }
bool IsHttp2Enabled() { return mHttp2DraftEnabled && mHttp2Enabled; }
bool EnforceHttp2TlsProfile() { return mEnforceHttp2TlsProfile; }
bool CoalesceSpdy() { return mCoalesceSpdy; }
bool UseSpdyPersistentSettings() { return mSpdyPersistentSettings; }
uint32_t SpdySendingChunkSize() { return mSpdySendingChunkSize; }
uint32_t SpdySendBufferSize() { return mSpdySendBufferSize; }
uint32_t SpdyPushAllowance() { return mSpdyPushAllowance; }
+ uint32_t DefaultSpdyConcurrent() { return mDefaultSpdyConcurrent; }
PRIntervalTime SpdyPingThreshold() { return mSpdyPingThreshold; }
PRIntervalTime SpdyPingTimeout() { return mSpdyPingTimeout; }
bool AllowPush() { return mAllowPush; }
bool AllowAltSvc() { return mEnableAltSvc; }
bool AllowAltSvcOE() { return mEnableAltSvcOE; }
uint32_t ConnectTimeout() { return mConnectTimeout; }
uint32_t ParallelSpeculativeConnectLimit() { return mParallelSpeculativeConnectLimit; }
bool CriticalRequestPrioritization() { return mCriticalRequestPrioritization; }
@@ -482,16 +483,17 @@ private:
uint32_t mEnableAltSvcOE : 1;
// Try to use SPDY features instead of HTTP/1.1 over SSL
SpdyInformation mSpdyInfo;
uint32_t mSpdySendingChunkSize;
uint32_t mSpdySendBufferSize;
uint32_t mSpdyPushAllowance;
+ uint32_t mDefaultSpdyConcurrent;
PRIntervalTime mSpdyPingThreshold;
PRIntervalTime mSpdyPingTimeout;
// The maximum amount of time to wait for socket transport to be
// established. In milliseconds.
uint32_t mConnectTimeout;
// The maximum number of current global half open sockets allowable