Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 2 | // 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 Elo | a7745f4 | 2022-10-18 18:41:22 | [diff] [blame] | 7 | #include <atomic> |
| 8 | |
David Sanders | 6e70994 | 2022-04-05 06:49:26 | [diff] [blame] | 9 | #include "base/base_export.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 10 | #include "base/feature_list.h" |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 11 | #include "build/build_config.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 12 | |
| 13 | namespace base { |
| 14 | |
Gabriel Charette | dfad599 | 2022-10-28 17:57:17 | [diff] [blame] | 15 | // 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 Wang | f8950ab6 | 2022-12-09 05:33:42 | [diff] [blame] | 25 | BASE_FEATURE(kUseUtilityThreadGroup, |
| 26 | "UseUtilityThreadGroup", |
| 27 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 28 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 29 | BASE_FEATURE(kNoWorkerThreadReclaim, |
| 30 | "NoWorkerThreadReclaim", |
Etienne Pierre-doray | b01338b | 2023-03-13 15:44:53 | [diff] [blame] | 31 | base::FEATURE_ENABLED_BY_DEFAULT); |
Francois Doray | a20b6df2 | 2019-06-27 15:04:19 | [diff] [blame] | 32 | |
Gabriel Charette | dfad599 | 2022-10-28 17:57:17 | [diff] [blame] | 33 | BASE_FEATURE(kDelayFirstWorkerWake, |
| 34 | "DelayFirstWorkerWake", |
Olivier Li | 0c5572d | 2024-02-28 18:52:10 | [diff] [blame] | 35 | base::FEATURE_ENABLED_BY_DEFAULT); |
Gabriel Charette | dfad599 | 2022-10-28 17:57:17 | [diff] [blame] | 36 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 37 | BASE_FEATURE(kAddTaskLeewayFeature, |
| 38 | "AddTaskLeeway", |
| 39 | base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 40 | |
| 41 | const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature, |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 42 | "leeway", kDefaultLeeway}; |
Etienne Pierre-doray | 77474c90 | 2023-09-27 20:23:09 | [diff] [blame] | 43 | const base::FeatureParam<TimeDelta> kMaxPreciseDelay{ |
| 44 | &kAddTaskLeewayFeature, "max_precise_delay", kDefaultMaxPreciseDelay}; |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 45 | |
Etienne Pierre-doray | cea9909 | 2023-07-20 20:31:14 | [diff] [blame] | 46 | BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", base::FEATURE_DISABLED_BY_DEFAULT); |
Etienne Pierre-doray | 048472eb | 2022-02-07 16:24:48 | [diff] [blame] | 47 | |
Etienne Pierre-doray | 1f2b04e | 2023-09-05 20:23:56 | [diff] [blame] | 48 | BASE_FEATURE(kTimerSlackMac, |
| 49 | "TimerSlackMac", |
| 50 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 51 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 52 | BASE_FEATURE(kExplicitHighResolutionTimerWin, |
| 53 | "ExplicitHighResolutionTimerWin", |
Etienne Pierre-doray | d5cdda49 | 2023-07-05 18:20:14 | [diff] [blame] | 54 | base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | ae2c15a | 2022-04-29 18:50:59 | [diff] [blame] | 55 | |
Sean Maher | bff1adc | 2024-04-10 20:33:43 | [diff] [blame] | 56 | BASE_FEATURE(kUIPumpImprovementsWin, |
| 57 | "UIPumpImprovementsWin", |
Sean Maher | acb46d7 | 2024-05-16 17:22:15 | [diff] [blame^] | 58 | base::FEATURE_ENABLED_BY_DEFAULT); |
| 59 | |
| 60 | BASE_FEATURE(kPumpFastToSleepAndroid, |
| 61 | "PumpFastToSleepAndroid", |
Sean Maher | bff1adc | 2024-04-10 20:33:43 | [diff] [blame] | 62 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 63 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 64 | BASE_FEATURE(kRunTasksByBatches, |
| 65 | "RunTasksByBatches", |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 66 | #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) |
| 67 | base::FEATURE_ENABLED_BY_DEFAULT); |
| 68 | #else |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 69 | base::FEATURE_DISABLED_BY_DEFAULT); |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 70 | #endif |
| 71 | |
Edgar Arriaga | 453bcb1 | 2023-09-12 23:09:01 | [diff] [blame] | 72 | BASE_FEATURE(kThreadPoolCap2, |
| 73 | "ThreadPoolCap2", |
Edgar Arriaga | d096f40 | 2023-05-02 15:39:24 | [diff] [blame] | 74 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 75 | |
| 76 | const base::FeatureParam<int> kThreadPoolCapRestrictedCount{ |
Edgar Arriaga | 453bcb1 | 2023-09-12 23:09:01 | [diff] [blame] | 77 | &kThreadPoolCap2, "restricted_count", 3}; |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 78 | |
Etienne Pierre-doray | e9957c9c | 2023-03-15 20:54:16 | [diff] [blame] | 79 | BASE_FEATURE(kMaxDelayedStarvationTasks, |
| 80 | "MaxDelayedStarvationTasks", |
| 81 | base::FEATURE_ENABLED_BY_DEFAULT); |
| 82 | |
| 83 | const base::FeatureParam<int> kMaxDelayedStarvationTasksParam{ |
| 84 | &kMaxDelayedStarvationTasks, "count", 3}; |
| 85 | |
Sean Maher | eabe41ee | 2024-01-30 21:43:23 | [diff] [blame] | 86 | BASE_FEATURE(kThreadGroupSemaphore, |
| 87 | "ThreadGroupSemaphore", |
| 88 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 89 | const base::FeatureParam<int> kMaxNumWorkersCreated{ |
| 90 | &kThreadGroupSemaphore, "max_num_workers_created", 2}; |
| 91 | |
Francois Doray | 5b44e33f | 2018-11-09 22:08:13 | [diff] [blame] | 92 | } // namespace base |