[Preconnect] Stop specially prioritizing preconnect tasks
This CL eliminates the execution of preconnect tasks on a custom high-priority task queue that was introduced in https://chromium-review.googlesource.com/c/chromium/src/+/1527536, reverting back to the behavior prior to that CL of executing these tasks on the default (priority-based) task queues. We have done experimentation and found that execution on the custom high-priority task queue brought no performance benefits over execution on the default priority-based task queues (summary in https://bugs.chromium.org/p/chromium/issues/detail?id=1257582#c28). Specifically, this CL is implementing the launch of the NoStandaloneQ arm of the experiment analyzed on that bug. The logic for why this is the case bears explicit mention: - NoStandaloneQ enables the "kTreatPreconnectTaskTypeAsDefault" base::Feature. - When this feature is enabled, invoking GetUIThreadTaskRunner({BrowserTaskType::kPreconnect}) returns the task runner for the task priority of the BrowserTaskTraits instance created via {BrowserTaskType::kPreconnect}. This task priority is USER_BLOCKING, since BrowserTaskTraits inherits the default value from TaskTraits and doesn't modify that default value. - In this CL, we simply stop passing a TaskRunner to the calls to BindNewPipeAndPassRemote() made in the preconnect code. When no TaskRunner is explicitly specified to these calls, they use SequencedTaskRunnerHandle::Get(). The task runner returned by SequencedTaskRunnerHandle::Get() on the UI thread (on which these calls are executing) is also the task runner for the USER_BLOCKING priority, i.e., the same task runner that is currently being passed when kTreatPreconnectTaskTypeAsDefault is enabled. This CL also eliminates the kPreconnect browser task trait, as there are now no uses of it in the codebase. Bug: 1257582 Change-Id: Idecfb145cd3299c38e5e479385e5dccdab2e0056 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698086 Reviewed-by: Ryan Sturm <ryansturm@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Commit-Queue: Colin Blundell <blundell@chromium.org> Reviewed-by: Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/main@{#1015858}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
062e3229f0
commit
d60aaeea80
chrome/browser/predictors
content
testing/variations
@@ -25,10 +25,8 @@ ProxyLookupClientImpl::ProxyLookupClientImpl(
|
||||
: callback_(std::move(callback)) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
proxy_lookup_start_time_ = base::TimeTicks::Now();
|
||||
network_context->LookUpProxyForURL(
|
||||
url, network_isolation_key,
|
||||
receiver_.BindNewPipeAndPassRemote(content::GetUIThreadTaskRunner(
|
||||
{content::BrowserTaskType::kPreconnect})));
|
||||
network_context->LookUpProxyForURL(url, network_isolation_key,
|
||||
receiver_.BindNewPipeAndPassRemote());
|
||||
receiver_.set_disconnect_handler(
|
||||
base::BindOnce(&ProxyLookupClientImpl::OnProxyLookupComplete,
|
||||
base::Unretained(this), net::ERR_ABORTED, absl::nullopt));
|
||||
|
@@ -36,11 +36,9 @@ ResolveHostClientImpl::ResolveHostClientImpl(
|
||||
parameters->purpose =
|
||||
network::mojom::ResolveHostParameters::Purpose::kPreconnect;
|
||||
resolve_host_start_time_ = base::TimeTicks::Now();
|
||||
network_context->ResolveHost(
|
||||
net::HostPortPair::FromURL(url), network_isolation_key,
|
||||
std::move(parameters),
|
||||
receiver_.BindNewPipeAndPassRemote(content::GetUIThreadTaskRunner(
|
||||
{content::BrowserTaskType::kPreconnect})));
|
||||
network_context->ResolveHost(net::HostPortPair::FromURL(url),
|
||||
network_isolation_key, std::move(parameters),
|
||||
receiver_.BindNewPipeAndPassRemote());
|
||||
receiver_.set_disconnect_handler(base::BindOnce(
|
||||
&ResolveHostClientImpl::OnConnectionError, base::Unretained(this)));
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ namespace content {
|
||||
constexpr base::TaskTraits traits = {BrowserThread::UI,
|
||||
BrowserThread::IO};
|
||||
#elif defined(NCTEST_BROWSER_TASK_TRAITS_MULTIPLE_TASK_TYPES) // [r"The traits bag contains multiple traits of the same type."]
|
||||
constexpr base::TaskTraits traits = {BrowserTaskType::kBootstrap, BrowserTaskType::kPreconnect};
|
||||
constexpr base::TaskTraits traits = {BrowserTaskType::kBootstrap, BrowserTaskType::kUserInput};
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -40,14 +40,6 @@ namespace features {
|
||||
constexpr base::Feature kBrowserPrioritizeInputQueue{
|
||||
"BrowserPrioritizeInputQueue", base::FEATURE_ENABLED_BY_DEFAULT};
|
||||
|
||||
// When TreatPreconnectAsDefault is enabled, the browser will execute tasks with
|
||||
// the kPreconnect task type on the default task queues (based on priority of
|
||||
// the task) rather than a dedicated high-priority task queue. Intended to
|
||||
// evaluate the impact of the already-launched prioritization of preconnect
|
||||
// tasks (crbug.com/1257582).
|
||||
const base::Feature kTreatPreconnectTaskTypeAsDefault{
|
||||
"TreatPreconnectAsDefault", base::FEATURE_DISABLED_BY_DEFAULT};
|
||||
|
||||
} // namespace features
|
||||
|
||||
namespace {
|
||||
@@ -154,17 +146,6 @@ QueueType BaseBrowserTaskExecutor::GetQueueType(
|
||||
// Note we currently ignore the priority for bootstrap tasks.
|
||||
return QueueType::kBootstrap;
|
||||
|
||||
case BrowserTaskType::kPreconnect:
|
||||
if (base::FeatureList::IsEnabled(
|
||||
features::kTreatPreconnectTaskTypeAsDefault)) {
|
||||
// Defer to traits.priority() below rather than executing this task on
|
||||
// the dedicated preconnect queue.
|
||||
break;
|
||||
}
|
||||
|
||||
// Note we currently ignore the priority for preconnection tasks.
|
||||
return QueueType::kPreconnection;
|
||||
|
||||
case BrowserTaskType::kUserInput:
|
||||
if (base::FeatureList::IsEnabled(
|
||||
features::kBrowserPrioritizeInputQueue)) {
|
||||
|
@@ -123,7 +123,7 @@ TEST_F(BrowserTaskExecutorTest, RunAllPendingTasksForTestingOnIOIsReentrant) {
|
||||
TEST_F(BrowserTaskExecutorTest, GetTaskRunnerWithBrowserTaskTraits) {
|
||||
StrictMockTask task_1;
|
||||
|
||||
GetUIThreadTaskRunner({BrowserTaskType::kPreconnect})
|
||||
GetUIThreadTaskRunner({BrowserTaskType::kUserInput})
|
||||
->PostTask(FROM_HERE, task_1.Get());
|
||||
|
||||
EXPECT_CALL(task_1, Run);
|
||||
@@ -154,8 +154,6 @@ TEST_F(BrowserTaskTraitsMappingTest, BrowserTaskTraitsMapToProperPriorities) {
|
||||
QueueType::kUserBlocking);
|
||||
EXPECT_EQ(BrowserTaskExecutor::GetQueueType({BrowserTaskType::kDefault}),
|
||||
QueueType::kUserBlocking);
|
||||
EXPECT_EQ(BrowserTaskExecutor::GetQueueType({BrowserTaskType::kPreconnect}),
|
||||
QueueType::kPreconnection);
|
||||
EXPECT_EQ(BrowserTaskExecutor::GetQueueType(
|
||||
{BrowserTaskType::kServiceWorkerStorageControlResponse}),
|
||||
QueueType::kServiceWorkerStorageControlResponse);
|
||||
|
@@ -56,8 +56,6 @@ const char* GetUITaskQueueName(BrowserTaskQueues::QueueType queue_type) {
|
||||
return "ui_best_effort_tq";
|
||||
case BrowserTaskQueues::QueueType::kBootstrap:
|
||||
return "ui_bootstrap_tq";
|
||||
case BrowserTaskQueues::QueueType::kPreconnection:
|
||||
return "ui_preconnection_tq";
|
||||
case BrowserTaskQueues::QueueType::kDefault:
|
||||
return "ui_default_tq";
|
||||
case BrowserTaskQueues::QueueType::kUserBlocking:
|
||||
@@ -79,8 +77,6 @@ const char* GetIOTaskQueueName(BrowserTaskQueues::QueueType queue_type) {
|
||||
return "io_best_effort_tq";
|
||||
case BrowserTaskQueues::QueueType::kBootstrap:
|
||||
return "io_bootstrap_tq";
|
||||
case BrowserTaskQueues::QueueType::kPreconnection:
|
||||
return "io_preconnection_tq";
|
||||
case BrowserTaskQueues::QueueType::kDefault:
|
||||
return "io_default_tq";
|
||||
case BrowserTaskQueues::QueueType::kUserBlocking:
|
||||
@@ -123,12 +119,6 @@ const char* GetDefaultQueueName(BrowserThread::ID thread_id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// When GivePreconnectTasksHighestPriority is enabled, the browser will give the
|
||||
// dedicated preconnect task queue highest priority rather than its default high
|
||||
// priority.
|
||||
const base::Feature kGivePreconnectTasksHighestPriority{
|
||||
"GivePreconnectTasksHighestPriority", base::FEATURE_DISABLED_BY_DEFAULT};
|
||||
|
||||
} // namespace
|
||||
|
||||
BrowserTaskQueues::Handle::~Handle() = default;
|
||||
@@ -245,17 +235,6 @@ void BrowserTaskQueues::PostFeatureListInitializationSetup() {
|
||||
// feature is enabled (see browser_task_executor.cc).
|
||||
GetBrowserTaskQueue(QueueType::kBootstrap)
|
||||
->SetQueuePriority(QueuePriority::kHighestPriority);
|
||||
|
||||
// Preconnection tasks are also important during startup so prioritize this
|
||||
// queue too. NOTE: This queue will not be used if the
|
||||
// |kTreatPreconnectAsDefault| feature is enabled (see
|
||||
// browser_task_executor.cc).
|
||||
QueuePriority preconnect_queue_priority =
|
||||
(base::FeatureList::IsEnabled(kGivePreconnectTasksHighestPriority))
|
||||
? QueuePriority::kHighestPriority
|
||||
: QueuePriority::kHighPriority;
|
||||
GetBrowserTaskQueue(QueueType::kPreconnection)
|
||||
->SetQueuePriority(preconnect_queue_priority);
|
||||
}
|
||||
|
||||
void BrowserTaskQueues::OnStartupComplete() {
|
||||
|
@@ -51,9 +51,6 @@ class CONTENT_EXPORT BrowserTaskQueues {
|
||||
// For tasks on the critical path up to issuing the initial navigation.
|
||||
kBootstrap,
|
||||
|
||||
// For preconnection-related tasks.
|
||||
kPreconnection,
|
||||
|
||||
// base::TaskPriority::kUserBlocking maps to this task queue. It's for tasks
|
||||
// that affect the UI immediately after a user interaction. Has the same
|
||||
// priority as kDefault.
|
||||
|
@@ -36,9 +36,6 @@ enum class BrowserTaskType {
|
||||
// Critical startup tasks.
|
||||
kBootstrap,
|
||||
|
||||
// A subset of network tasks related to preconnection.
|
||||
kPreconnect,
|
||||
|
||||
// A subset of tasks related to user input.
|
||||
kUserInput,
|
||||
|
||||
|
@@ -6629,29 +6629,6 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"PreconnectPriorities": [
|
||||
{
|
||||
"platforms": [
|
||||
"android",
|
||||
"chromeos",
|
||||
"chromeos_lacros",
|
||||
"linux",
|
||||
"mac",
|
||||
"windows"
|
||||
],
|
||||
"experiments": [
|
||||
{
|
||||
"name": "StandaloneHighestPriorityQ",
|
||||
"enable_features": [
|
||||
"GivePreconnectTasksHighestPriority"
|
||||
],
|
||||
"disable_features": [
|
||||
"TreatPreconnectAsDefault"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"PreconnectToSearchDesktop": [
|
||||
{
|
||||
"platforms": [
|
||||
|
Reference in New Issue
Block a user