Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 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 | |
David Sanders | 6e70994 | 2022-04-05 06:49:26 | [diff] [blame] | 7 | #include "base/base_export.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 8 | #include "base/feature_list.h" |
| 9 | |
| 10 | namespace base { |
| 11 | |
Etienne Pierre-doray | 3ed4138 | 2019-02-06 04:40:47 | [diff] [blame] | 12 | const Feature kMayBlockWithoutDelay = {"MayBlockWithoutDelay", |
| 13 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 14 | |
Etienne Pierre-doray | ea2b21e | 2020-10-26 22:38:59 | [diff] [blame] | 15 | const Feature kDisableJobYield = {"DisableJobYield", |
| 16 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 17 | |
| 18 | const Feature kDisableFairJobScheduling = {"DisableFairJobScheduling", |
| 19 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 20 | |
| 21 | const Feature kDisableJobUpdatePriority = {"DisableJobUpdatePriority", |
| 22 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 23 | |
| 24 | const Feature kWakeUpStrategyFeature = {"WakeUpStrategyFeature", |
| 25 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 26 | |
| 27 | constexpr FeatureParam<WakeUpStrategy>::Option kWakeUpStrategyOptions[] = { |
| 28 | {WakeUpStrategy::kCentralizedWakeUps, "centralized-wakeups"}, |
| 29 | {WakeUpStrategy::kSerializedWakeUps, "serialized-wakeups"}, |
Etienne Pierre-doray | b5fe0b5f | 2021-01-29 18:37:27 | [diff] [blame] | 30 | {WakeUpStrategy::kExponentialWakeUps, "exponential-wakeups"}, |
| 31 | {WakeUpStrategy::kGreedyWakeUps, "greedy-wakeups"}}; |
Etienne Pierre-doray | ea2b21e | 2020-10-26 22:38:59 | [diff] [blame] | 32 | |
| 33 | const base::FeatureParam<WakeUpStrategy> kWakeUpStrategyParam{ |
| 34 | &kWakeUpStrategyFeature, "strategy", WakeUpStrategy::kExponentialWakeUps, |
| 35 | &kWakeUpStrategyOptions}; |
| 36 | |
| 37 | const Feature kWakeUpAfterGetWork = {"WakeUpAfterGetWork", |
| 38 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 39 | |
Francois Doray | ee4a553 | 2021-03-30 00:17:17 | [diff] [blame] | 40 | #if HAS_NATIVE_THREAD_POOL() |
Aditya Keerthi | a41eda5 | 2019-04-01 15:03:25 | [diff] [blame] | 41 | const Feature kUseNativeThreadPool = {"UseNativeThreadPool", |
| 42 | base::FEATURE_DISABLED_BY_DEFAULT}; |
Francois Doray | ee4a553 | 2021-03-30 00:17:17 | [diff] [blame] | 43 | const Feature kUseBackgroundNativeThreadPool = { |
| 44 | "UseBackgroundNativeThreadPool", base::FEATURE_DISABLED_BY_DEFAULT}; |
Aditya Keerthi | a41eda5 | 2019-04-01 15:03:25 | [diff] [blame] | 45 | #endif |
| 46 | |
Francois Doray | a20b6df2 | 2019-06-27 15:04:19 | [diff] [blame] | 47 | const Feature kUseFiveMinutesThreadReclaimTime = { |
| 48 | "UseFiveMinutesThreadReclaimTime", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 49 | |
Patrick Monette | 6497eae | 2022-08-09 17:59:58 | [diff] [blame^] | 50 | // static |
| 51 | const BASE_EXPORT Feature kNoWakeUpsForCanceledTasks{ |
| 52 | "NoWakeUpsForCanceledTasks", FEATURE_DISABLED_BY_DEFAULT}; |
| 53 | |
Patrick Monette | eaaa238 | 2021-12-08 17:06:59 | [diff] [blame] | 54 | const BASE_EXPORT Feature kRemoveCanceledTasksInTaskQueue = { |
Patrick Monette | d85b816 | 2022-01-27 00:23:23 | [diff] [blame] | 55 | "RemoveCanceledTasksInTaskQueue2", base::FEATURE_DISABLED_BY_DEFAULT}; |
Patrick Monette | eaaa238 | 2021-12-08 17:06:59 | [diff] [blame] | 56 | |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 57 | const BASE_EXPORT Feature kAddTaskLeewayFeature = { |
| 58 | "AddTaskLeeway", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 59 | |
| 60 | const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature, |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 61 | "leeway", kDefaultLeeway}; |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 62 | |
Etienne Pierre-doray | 048472eb | 2022-02-07 16:24:48 | [diff] [blame] | 63 | const BASE_EXPORT Feature kAlignWakeUps = {"AlignWakeUps", |
| 64 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 65 | |
Etienne Pierre-doray | ae2c15a | 2022-04-29 18:50:59 | [diff] [blame] | 66 | const BASE_EXPORT Feature kExplicitHighResolutionTimerWin = { |
| 67 | "ExplicitHighResolutionTimerWin", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 68 | |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 69 | const BASE_EXPORT Feature kRunTasksByBatches = { |
Alex Attar | 42c63be | 2022-06-02 18:58:12 | [diff] [blame] | 70 | "RunTasksByBatches", base::FEATURE_DISABLED_BY_DEFAULT}; |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 71 | |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 72 | // Leeway value applied to delayed tasks. An atomic is used here because the |
| 73 | // value is queried from multiple threads. |
| 74 | std::atomic<TimeDelta> g_task_leeway{kDefaultLeeway}; |
| 75 | |
| 76 | BASE_EXPORT void InitializeTaskLeeway() { |
|
|