blob: 3b827c9ab49a15e43e22a095dcb3ed007e66097d [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2018 The Chromium Authors
Leszek Swirski2987cc82018-11-05 15:19:282// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/task/task_features.h"
6
Hans-Filip Eloa7745f42022-10-18 18:41:227#include <atomic>
8
David Sanders6e709942022-04-05 06:49:269#include "base/base_export.h"
Leszek Swirski2987cc82018-11-05 15:19:2810#include "base/feature_list.h"
Olivier Li Shing Tat-Dupuisc42ff2e2023-10-13 15:43:0311#include "build/build_config.h"
Leszek Swirski2987cc82018-11-05 15:19:2812
13namespace base {
14
Gabriel Charettedfad5992022-10-28 17:57:1715// Note to implementers: thread pool code using task features must absolutely
16// not invoke FeatureList::IsEnabled outside of the main thread. Doing so
17// causes data races between worker threads and ~FeatureList when tests end
18// (crbug.com/1344573). A reliable moment to query and cache the feature state
19// is on ThreadPoolImpl::Start (and thus also on the first WorkerThread::Start,
20// not the later ones) as this is invoked from the main thread after
21// initializing the FeatureList. If caching the feature state in a static, you
22// must be aware that all tests sharing a process will have the same state,
23// regardless of future ScopedFeatureList instances.
24
Zhibo Wangf8950ab62022-12-09 05:33:4225BASE_FEATURE(kUseUtilityThreadGroup,
26 "UseUtilityThreadGroup",
27 base::FEATURE_DISABLED_BY_DEFAULT);
28
Daniel Cheng0fff5c232022-09-21 17:43:3429BASE_FEATURE(kNoWorkerThreadReclaim,
30 "NoWorkerThreadReclaim",
Etienne Pierre-dorayb01338b2023-03-13 15:44:5331 base::FEATURE_ENABLED_BY_DEFAULT);
Francois Doraya20b6df22019-06-27 15:04:1932
Gabriel Charettedfad5992022-10-28 17:57:1733BASE_FEATURE(kDelayFirstWorkerWake,
34 "DelayFirstWorkerWake",
Olivier Li0c5572d2024-02-28 18:52:1035 base::FEATURE_ENABLED_BY_DEFAULT);
Gabriel Charettedfad5992022-10-28 17:57:1736
Daniel Cheng0fff5c232022-09-21 17:43:3437BASE_FEATURE(kAddTaskLeewayFeature,
38 "AddTaskLeeway",
39 base::FEATURE_ENABLED_BY_DEFAULT);
Etienne Pierre-doraya8792732022-02-05 02:27:2540
41const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature,
Jiahe Zhang07cf33132022-08-09 09:42:4942 "leeway", kDefaultLeeway};
Etienne Pierre-doray77474c902023-09-27 20:23:0943const base::FeatureParam<TimeDelta> kMaxPreciseDelay{
44 &kAddTaskLeewayFeature, "max_precise_delay", kDefaultMaxPreciseDelay};
Etienne Pierre-doraya8792732022-02-05 02:27:2545
Etienne Pierre-doraycea99092023-07-20 20:31:1446BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", base::FEATURE_DISABLED_BY_DEFAULT);
Etienne Pierre-doray048472eb2022-02-07 16:24:4847
Etienne Pierre-doray1f2b04e2023-09-05 20:23:5648BASE_FEATURE(kTimerSlackMac,
49 "TimerSlackMac",
50 base::FEATURE_DISABLED_BY_DEFAULT);
51
Daniel Cheng0fff5c232022-09-21 17:43:3452BASE_FEATURE(kExplicitHighResolutionTimerWin,
53 "ExplicitHighResolutionTimerWin",
Etienne Pierre-dorayd5cdda492023-07-05 18:20:1454 base::FEATURE_ENABLED_BY_DEFAULT);
Etienne Pierre-dorayae2c15a2022-04-29 18:50:5955
Sean Maherbff1adc2024-04-10 20:33:4356BASE_FEATURE(kUIPumpImprovementsWin,
57 "UIPumpImprovementsWin",
Sean Maheracb46d72024-05-16 17:22:1558 base::FEATURE_ENABLED_BY_DEFAULT);
59
60BASE_FEATURE(kPumpFastToSleepAndroid,
61 "PumpFastToSleepAndroid",
Sean Maherbff1adc2024-04-10 20:33:4362 base::FEATURE_DISABLED_BY_DEFAULT);
63
Daniel Cheng0fff5c232022-09-21 17:43:3464BASE_FEATURE(kRunTasksByBatches,
65 "RunTasksByBatches",
Olivier Li Shing Tat-Dupuisc42ff2e2023-10-13 15:43:0366#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
67 base::FEATURE_ENABLED_BY_DEFAULT);
68#else
Daniel Cheng0fff5c232022-09-21 17:43:3469 base::FEATURE_DISABLED_BY_DEFAULT);
Olivier Li Shing Tat-Dupuisc42ff2e2023-10-13 15:43:0370#endif
71
Edgar Arriaga453bcb12023-09-12 23:09:0172BASE_FEATURE(kThreadPoolCap2,
73 "ThreadPoolCap2",
Edgar Arriagad096f402023-05-02 15:39:2474 base::FEATURE_DISABLED_BY_DEFAULT);
75
76const base::FeatureParam<int> kThreadPoolCapRestrictedCount{
Edgar Arriaga453bcb12023-09-12 23:09:0177 &kThreadPoolCap2, "restricted_count", 3};
Alex Attar9fcc01e2022-05-20 14:01:2778
Etienne Pierre-doraye9957c9c2023-03-15 20:54:1679BASE_FEATURE(kMaxDelayedStarvationTasks,
80 "MaxDelayedStarvationTasks",
81 base::FEATURE_ENABLED_BY_DEFAULT);
82
83const base::FeatureParam<int> kMaxDelayedStarvationTasksParam{
84 &kMaxDelayedStarvationTasks, "count", 3};
85
Sean Mahereabe41ee2024-01-30 21:43:2386BASE_FEATURE(kThreadGroupSemaphore,
87 "ThreadGroupSemaphore",
88 base::FEATURE_DISABLED_BY_DEFAULT);
89const base::FeatureParam<int> kMaxNumWorkersCreated{
90 &kThreadGroupSemaphore, "max_num_workers_created", 2};
91
Francois Doray5b44e33f2018-11-09 22:08:1392} // namespace base