Bug 1703934 - P2: Use another parallel limit for backup speculative connection, r=dragana,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D112349
This commit is contained in:
Kershaw Chang 2021-04-27 08:37:25 +00:00
Родитель a508fefb70
Коммит 0855cd1e18
4 изменённых файлов: 36 добавлений и 45 удалений

Просмотреть файл

@ -9435,6 +9435,12 @@
value: 100
mirror: always
# The global half open sockets allowed for creating a backup connection.
- name: network.http.http3.parallel_fallback_conn_limit
type: RelaxedAtomicUint32
value: 32
mirror: always
# When true, a http request will be upgraded to https when HTTPS RR is
# available.
- name: network.dns.upgrade_with_https_rr

Просмотреть файл

@ -3304,7 +3304,8 @@ void nsHttpConnectionMgr::DoSpeculativeConnection(
} else {
LOG(
("OnMsgSpeculativeConnect Transport "
"not created due to existing connection count\n"));
"not created due to existing connection count:%d",
parallelSpeculativeConnectLimit));
}
}

Просмотреть файл

@ -3229,6 +3229,21 @@ void nsHttpTransaction::OnBackupConnectionReady(bool aHTTPSRRUsed) {
}
}
static void CreateBackupConnection(
nsHttpConnectionInfo* aBackupConnInfo, nsIInterfaceRequestor* aCallbacks,
uint32_t aCaps, std::function<void(bool)>&& aResultCallback) {
RefPtr<SpeculativeTransaction> trans = new SpeculativeTransaction(
aBackupConnInfo, aCallbacks, aCaps | NS_HTTP_DISALLOW_HTTP3,
std::move(aResultCallback));
uint32_t limit =
StaticPrefs::network_http_http3_parallel_fallback_conn_limit();
if (limit) {
trans->SetParallelSpeculativeConnectLimit(limit);
trans->SetIgnoreIdle(true);
}
gHttpHandler->ConnMgr()->DoSpeculativeConnection(trans, false);
}
void nsHttpTransaction::OnHttp3BackupTimer() {
LOG(("nsHttpTransaction::OnHttp3BackupTimer [%p]", this));
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
@ -3246,10 +3261,8 @@ void nsHttpTransaction::OnHttp3BackupTimer() {
}
};
RefPtr<SpeculativeTransaction> trans = new SpeculativeTransaction(
mBackupConnInfo, mCallbacks, mCaps | NS_HTTP_DISALLOW_HTTP3,
std::move(callback));
gHttpHandler->ConnMgr()->DoSpeculativeConnection(trans, false);
CreateBackupConnection(mBackupConnInfo, mCallbacks, mCaps,
std::move(callback));
}
void nsHttpTransaction::OnFastFallbackTimer() {
@ -3283,10 +3296,8 @@ void nsHttpTransaction::OnFastFallbackTimer() {
self->OnBackupConnectionReady(true);
};
RefPtr<SpeculativeTransaction> trans = new SpeculativeTransaction(
mBackupConnInfo, mCallbacks, mCaps | NS_HTTP_DISALLOW_HTTP3,
std::move(callback));
gHttpHandler->ConnMgr()->DoSpeculativeConnection(trans, false);
CreateBackupConnection(mBackupConnInfo, mCallbacks, mCaps,
std::move(callback));
}
void nsHttpTransaction::HandleFallback(

Просмотреть файл

@ -61,6 +61,9 @@ registerCleanupFunction(async () => {
);
Services.prefs.clearUserPref("network.http.http3.backup_timer_delay");
Services.prefs.clearUserPref("network.http.speculative-parallel-limit");
Services.prefs.clearUserPref(
"network.http.http3.parallel_fallback_conn_limit"
);
if (trrServer) {
await trrServer.stop();
}
@ -154,34 +157,6 @@ add_task(async function test_fast_fallback_with_speculative_connection() {
await fast_fallback_test();
});
let HTTPObserver = {
observeActivity(
aChannel,
aType,
aSubtype,
aTimestamp,
aSizeData,
aStringData
) {
aChannel.QueryInterface(Ci.nsIChannel);
if (aChannel.URI.spec == `https://foo.example.com:${h2Port}/`) {
if (
aType == Ci.nsIHttpActivityDistributor.ACTIVITY_TYPE_HTTP_TRANSACTION &&
aSubtype ==
Ci.nsIHttpActivityDistributor.ACTIVITY_SUBTYPE_REQUEST_HEADER
) {
// We need to enable speculative connection again, since the backup
// connection is done by using speculative connection.
Services.prefs.setIntPref("network.http.speculative-parallel-limit", 6);
let observerService = Cc[
"@mozilla.org/network/http-activity-distributor;1"
].getService(Ci.nsIHttpActivityDistributor);
observerService.removeObserver(HTTPObserver);
}
}
},
};
// Test the case when speculative connection is disabled. In this case, when the
// back connection is ready, the http transaction is already activated,
// but the socket is not ready to write.
@ -193,11 +168,6 @@ add_task(async function test_fast_fallback_without_speculative_connection() {
Services.obs.notifyObservers(null, "network:reset-http3-excluded-list");
Services.prefs.setIntPref("network.http.speculative-parallel-limit", 0);
let observerService = Cc[
"@mozilla.org/network/http-activity-distributor;1"
].getService(Ci.nsIHttpActivityDistributor);
observerService.addObserver(HTTPObserver);
await fast_fallback_test();
Services.prefs.clearUserPref(
@ -647,9 +617,10 @@ add_task(async function testH3FallbackWithMultipleTransactions() {
// Disable fast fallback.
Services.prefs.setIntPref(
"network.dns.httpssvc.http3_fast_fallback_timeout",
"network.http.http3.parallel_fallback_conn_limit",
0
);
Services.prefs.setIntPref("network.http.speculative-parallel-limit", 0);
await trrServer.registerDoHAnswers("test.multiple_trans.org", "HTTPS", {
answers: [
@ -684,8 +655,10 @@ add_task(async function testH3FallbackWithMultipleTransactions() {
let promises = [];
for (let i = 0; i < 2; ++i) {
let chan = makeChan(`https://test.multiple_trans.org:${h2Port}/server-timing`);
promises.push(channelOpenPromise(chan))
let chan = makeChan(
`https://test.multiple_trans.org:${h2Port}/server-timing`
);
promises.push(channelOpenPromise(chan));
}
let res = await Promise.all(promises);