Commit 5b44e33f authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

TaskScheduler: Use a Feature to control whether all tasks are USER_BLOCKING.

Previously, we read a variation param from the "BrowserScheduler" study
to determine whether all tasks should have USER_BLOCKING priority.
With this CL, we instead use a base::Feature.

Benefits:
- Study that controls the feature doesn't have to be "BrowserScheduler".
- Enabling/disabling a feature is less verbose than setting a variation
  params with the new GCL config format.

Bug: 902441
Change-Id: Ib38dcfdf097c1ca92784a22c3501b644b077f744
Reviewed-on: https://chromium-review.googlesource.com/c/1321032
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606988}
parent 6296e827
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
namespace base { namespace base {
const base::Feature kMergeBlockingNonBlockingPools = { const Feature kAllTasksUserBlocking{"AllTasksUserBlocking",
FEATURE_DISABLED_BY_DEFAULT};
const Feature kMergeBlockingNonBlockingPools = {
"MergeBlockingNonBlockingPools", base::FEATURE_DISABLED_BY_DEFAULT}; "MergeBlockingNonBlockingPools", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace base } // namespace base
\ No newline at end of file
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
namespace base { namespace base {
struct Feature; struct Feature;
extern const BASE_EXPORT base::Feature kMergeBlockingNonBlockingPools;
extern const BASE_EXPORT Feature kAllTasksUserBlocking;
extern const BASE_EXPORT Feature kMergeBlockingNonBlockingPools;
} // namespace base } // namespace base
......
...@@ -115,10 +115,8 @@ void TaskSchedulerImpl::Start( ...@@ -115,10 +115,8 @@ void TaskSchedulerImpl::Start(
SchedulerWorkerObserver* scheduler_worker_observer) { SchedulerWorkerObserver* scheduler_worker_observer) {
// This is set in Start() and not in the constructor because variation params // This is set in Start() and not in the constructor because variation params
// are usually not ready when TaskSchedulerImpl is instantiated in a process. // are usually not ready when TaskSchedulerImpl is instantiated in a process.
if (base::GetFieldTrialParamValue("BrowserScheduler", if (FeatureList::IsEnabled(kAllTasksUserBlocking))
"AllTasksUserBlocking") == "true") {
all_tasks_user_blocking_.Set(); all_tasks_user_blocking_.Set();
}
const bool use_blocking_pools = const bool use_blocking_pools =
!base::FeatureList::IsEnabled(kMergeBlockingNonBlockingPools); !base::FeatureList::IsEnabled(kMergeBlockingNonBlockingPools);
......
...@@ -127,7 +127,7 @@ void VerifyTaskEnvironment(const TaskTraits& traits, SchedulerState state) { ...@@ -127,7 +127,7 @@ void VerifyTaskEnvironment(const TaskTraits& traits, SchedulerState state) {
? "Background" ? "Background"
: "Foreground")); : "Foreground"));
} }
// TaskScheduler only handles |kMergeBlockingNonBlockingPools| once started // TaskScheduler only handles |kMergeBlockingNonBlockingPools| once started
// (early task runners are not merged for this experiment). // (early task runners are not merged for this experiment).
// TODO(etiennep): Simplify this after the experiment. // TODO(etiennep): Simplify this after the experiment.
// Merging pools does not affect SingleThread workers. // Merging pools does not affect SingleThread workers.
...@@ -248,20 +248,17 @@ std::vector<TaskSchedulerImplTestParams> GetTaskSchedulerImplTestParams() { ...@@ -248,20 +248,17 @@ std::vector<TaskSchedulerImplTestParams> GetTaskSchedulerImplTestParams() {
class TaskSchedulerImplTest class TaskSchedulerImplTest
: public testing::TestWithParam<TaskSchedulerImplTestParams> { : public testing::TestWithParam<TaskSchedulerImplTestParams> {
protected: protected:
TaskSchedulerImplTest() : scheduler_("Test"), field_trial_list_(nullptr) { TaskSchedulerImplTest() : scheduler_("Test") {
if (GetParam().pool_config == PoolConfiguration::kMergeBlockingNonBlocking) feature_list_.emplace();
feature_list.InitWithFeatures({kMergeBlockingNonBlockingPools}, {}); feature_list_->InitWithFeatures(GetFeaturesEnabledByConstructor(), {});
} }
void EnableAllTasksUserBlocking() { void EnableAllTasksUserBlocking() {
constexpr char kFieldTrialName[] = "BrowserScheduler"; feature_list_.reset();
constexpr char kFieldTrialTestGroup[] = "DummyGroup"; feature_list_.emplace();
std::map<std::string, std::string> variation_params; std::vector<Feature> enabled_features = GetFeaturesEnabledByConstructor();
variation_params["AllTasksUserBlocking"] = "true"; enabled_features.push_back(kAllTasksUserBlocking);
base::AssociateFieldTrialParams(kFieldTrialName, kFieldTrialTestGroup, feature_list_->InitWithFeatures(enabled_features, {});
variation_params);
base::FieldTrialList::CreateFieldTrial(kFieldTrialName,
kFieldTrialTestGroup);
} }
void set_scheduler_worker_observer( void set_scheduler_worker_observer(
...@@ -296,8 +293,14 @@ class TaskSchedulerImplTest ...@@ -296,8 +293,14 @@ class TaskSchedulerImplTest
TaskSchedulerImpl scheduler_; TaskSchedulerImpl scheduler_;
private: private:
base::FieldTrialList field_trial_list_; std::vector<Feature> GetFeaturesEnabledByConstructor() {
base::test::ScopedFeatureList feature_list; if (GetParam().pool_config == PoolConfiguration::kMergeBlockingNonBlocking)
return {kMergeBlockingNonBlockingPools};
else
return {};
}
Optional<base::test::ScopedFeatureList> feature_list_;
SchedulerWorkerObserver* scheduler_worker_observer_ = nullptr; SchedulerWorkerObserver* scheduler_worker_observer_ = nullptr;
bool did_tear_down_ = false; bool did_tear_down_ = false;
......
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