Commit 2f05a7bb authored by gab's avatar gab Committed by Commit bot

Add a TaskPriority cap to the SWP redirection to experiment with no redirections at USER_BLOCKING.

BUG=622400

Review-Url: https://codereview.chromium.org/2574403002
Cr-Commit-Position: refs/heads/master@{#438966}
parent 2d3fdfb8
......@@ -75,6 +75,8 @@ enum class AllPoolsState {
// debug::DumpWithoutCrashing() in case of waterfall failures.
AllPoolsState g_all_pools_state = AllPoolsState::USE_WORKER_POOL;
TaskPriority g_max_task_priority = TaskPriority::HIGHEST;
struct SequencedTask : public TrackingInfo {
SequencedTask()
: sequence_token_id(0),
......@@ -644,7 +646,10 @@ SequencedWorkerPool::Inner::Inner(SequencedWorkerPool* worker_pool,
cleanup_idlers_(0),
cleanup_cv_(&lock_),
testing_observer_(observer),
task_priority_(task_priority) {
task_priority_(static_cast<int>(task_priority) <=
static_cast<int>(g_max_task_priority)
? task_priority
: g_max_task_priority) {
DCHECK_GT(max_threads_, 1U);
}
......@@ -1422,13 +1427,15 @@ void SequencedWorkerPool::EnableForProcess() {
}
// static
void SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess() {
void SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(
TaskPriority max_task_priority) {
// TODO(fdoray): Uncomment this line. It is initially commented to avoid a
// revert of the CL that adds debug::DumpWithoutCrashing() in case of
// waterfall failures.
// DCHECK_EQ(AllPoolsState::POST_TASK_DISABLED, g_all_pools_state);
DCHECK(TaskScheduler::GetInstance());
g_all_pools_state = AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER;
g_max_task_priority = max_task_priority;
}
// static
......
......@@ -188,11 +188,13 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
static void EnableForProcess();
// Same as EnableForProcess(), but tasks are redirected to the registered
// TaskScheduler. There must be a registered TaskScheduler when this is
// TaskScheduler. All redirections' TaskPriority will be capped to
// |max_task_priority|. There must be a registered TaskScheduler when this is
// called.
// TODO(gab): Remove this if http://crbug.com/622400 fails
// (SequencedWorkerPool will be phased out completely otherwise).
static void EnableWithRedirectionToTaskSchedulerForProcess();
static void EnableWithRedirectionToTaskSchedulerForProcess(
TaskPriority max_task_priority = TaskPriority::HIGHEST);
// Disables posting tasks to this process' SequencedWorkerPools. Calling this
// while there are active SequencedWorkerPools is not supported. This is not
......
......@@ -136,7 +136,20 @@ void MaybePerformBrowserTaskSchedulerRedirection() {
switches::kDisableBrowserTaskScheduler) &&
sequenced_worker_pool_param != variation_params.end() &&
sequenced_worker_pool_param->second == "true") {
base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess();
// Check a variation that allows capping all redirections at USER_VISIBLE
// (no USER_BLOCKING) to observe the side-effects of multiple priority
// levels in the foreground IO pool.
const auto sequenced_worker_pool_cap_priority_param =
variation_params.find("CapSequencedWorkerPoolsAtUserVisible");
const base::TaskPriority max_task_priority =
sequenced_worker_pool_cap_priority_param != variation_params.end() &&
sequenced_worker_pool_cap_priority_param->second == "true"
? base::TaskPriority::USER_VISIBLE
: base::TaskPriority::HIGHEST;
base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(
max_task_priority);
} else {
base::SequencedWorkerPool::EnableForProcess();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment