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 | |
Gabriel Charette | dfad599 | 2022-10-28 17:57:17 | [diff] [blame] | 29 | BASE_FEATURE(kDelayFirstWorkerWake, |
| 30 | "DelayFirstWorkerWake", |
Olivier Li | 0c5572d | 2024-02-28 18:52:10 | [diff] [blame] | 31 | base::FEATURE_ENABLED_BY_DEFAULT); |
Gabriel Charette | dfad599 | 2022-10-28 17:57:17 | [diff] [blame] | 32 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 33 | BASE_FEATURE(kAddTaskLeewayFeature, |
| 34 | "AddTaskLeeway", |
| 35 | base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 36 | |
| 37 | const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature, |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 38 | "leeway", kDefaultLeeway}; |
Etienne Pierre-doray | 77474c90 | 2023-09-27 20:23:09 | [diff] [blame] | 39 | const base::FeatureParam<TimeDelta> kMaxPreciseDelay{ |
| 40 | &kAddTaskLeewayFeature, "max_precise_delay", kDefaultMaxPreciseDelay}; |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 41 | |
Etienne Pierre-doray | cea9909 | 2023-07-20 20:31:14 | [diff] [blame] | 42 | BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", base::FEATURE_DISABLED_BY_DEFAULT); |
Etienne Pierre-doray | 048472eb | 2022-02-07 16:24:48 | [diff] [blame] | 43 | |
Etienne Pierre-doray | 1f2b04e | 2023-09-05 20:23:56 | [diff] [blame] | 44 | BASE_FEATURE(kTimerSlackMac, |
| 45 | "TimerSlackMac", |
| 46 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 47 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 48 | BASE_FEATURE(kExplicitHighResolutionTimerWin, |
| 49 | "ExplicitHighResolutionTimerWin", |
Etienne Pierre-doray | d5cdda49 | 2023-07-05 18:20:14 | [diff] [blame] | 50 | base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | ae2c15a | 2022-04-29 18:50:59 | [diff] [blame] | 51 | |
Sean Maher | bff1adc | 2024-04-10 20:33:43 | [diff] [blame] | 52 | BASE_FEATURE(kUIPumpImprovementsWin, |
| 53 | "UIPumpImprovementsWin", |
François Doray | 912128b | 2024-12-13 18:52:06 | [diff] [blame] | 54 | base::FEATURE_ENABLED_BY_DEFAULT); |
Sean Maher | acb46d7 | 2024-05-16 17:22:15 | [diff] [blame] | 55 | |
| 56 | BASE_FEATURE(kPumpFastToSleepAndroid, |
| 57 | "PumpFastToSleepAndroid", |
Sean Maher | bff1adc | 2024-04-10 20:33:43 | [diff] [blame] | 58 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 59 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 60 | BASE_FEATURE(kRunTasksByBatches, |
| 61 | "RunTasksByBatches", |
François Doray | 179b0a8 | 2024-12-13 20:52:57 | [diff] [blame^] | 62 | #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 63 | base::FEATURE_ENABLED_BY_DEFAULT); |
| 64 | #else |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 65 | base::FEATURE_DISABLED_BY_DEFAULT); |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 66 | #endif |
| 67 | |
Edgar Arriaga | 453bcb1 | 2023-09-12 23:09:01 | [diff] [blame] | 68 | BASE_FEATURE(kThreadPoolCap2, |
| 69 | "ThreadPoolCap2", |
Edgar Arriaga | d096f40 | 2023-05-02 15:39:24 | [diff] [blame] | 70 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 71 | |
| 72 | const base::FeatureParam<int> kThreadPoolCapRestrictedCount{ |
Edgar Arriaga | 453bcb1 | 2023-09-12 23:09:01 | [diff] [blame] | 73 | &kThreadPoolCap2, "restricted_count", 3}; |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 74 | |
Francois Doray | 5b44e33f | 2018-11-09 22:08:13 | [diff] [blame] | 75 | } // namespace base |