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" |
| 11 | |
| 12 | namespace base { |
| 13 | |
Francois Doray | ee4a553 | 2021-03-30 00:17:17 | [diff] [blame] | 14 | #if HAS_NATIVE_THREAD_POOL() |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 15 | BASE_FEATURE(kUseNativeThreadPool, |
| 16 | "UseNativeThreadPool", |
| 17 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 18 | BASE_FEATURE(kUseBackgroundNativeThreadPool, |
| 19 | "UseBackgroundNativeThreadPool", |
| 20 | base::FEATURE_DISABLED_BY_DEFAULT); |
Aditya Keerthi | a41eda5 | 2019-04-01 15:03:25 | [diff] [blame] | 21 | #endif |
| 22 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 23 | BASE_FEATURE(kNoWorkerThreadReclaim, |
| 24 | "NoWorkerThreadReclaim", |
| 25 | base::FEATURE_DISABLED_BY_DEFAULT); |
Francois Doray | a20b6df2 | 2019-06-27 15:04:19 | [diff] [blame] | 26 | |
Patrick Monette | 6497eae | 2022-08-09 17:59:58 | [diff] [blame] | 27 | // static |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 28 | BASE_FEATURE(kNoWakeUpsForCanceledTasks, |
| 29 | "NoWakeUpsForCanceledTasks", |
| 30 | FEATURE_DISABLED_BY_DEFAULT); |
Patrick Monette | 6497eae | 2022-08-09 17:59:58 | [diff] [blame] | 31 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 32 | BASE_FEATURE(kRemoveCanceledTasksInTaskQueue, |
| 33 | "RemoveCanceledTasksInTaskQueue2", |
| 34 | base::FEATURE_DISABLED_BY_DEFAULT); |
Patrick Monette | eaaa238 | 2021-12-08 17:06:59 | [diff] [blame] | 35 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 36 | BASE_FEATURE(kAlwaysAbandonScheduledTask, |
| 37 | "AlwaysAbandonScheduledTask", |
| 38 | base::FEATURE_DISABLED_BY_DEFAULT); |
Patrick Monette | 4efba9c | 2022-08-18 16:41:32 | [diff] [blame] | 39 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 40 | BASE_FEATURE(kAddTaskLeewayFeature, |
| 41 | "AddTaskLeeway", |
| 42 | base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 43 | |
| 44 | const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature, |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 45 | "leeway", kDefaultLeeway}; |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 46 | |
Sergey Ulanov | 2523ae87 | 2022-09-29 19:20:46 | [diff] [blame] | 47 | BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | 048472eb | 2022-02-07 16:24:48 | [diff] [blame] | 48 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 49 | BASE_FEATURE(kExplicitHighResolutionTimerWin, |
| 50 | "ExplicitHighResolutionTimerWin", |
| 51 | base::FEATURE_DISABLED_BY_DEFAULT); |
Etienne Pierre-doray | ae2c15a | 2022-04-29 18:50:59 | [diff] [blame] | 52 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 53 | BASE_FEATURE(kRunTasksByBatches, |
| 54 | "RunTasksByBatches", |
| 55 | base::FEATURE_DISABLED_BY_DEFAULT); |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 56 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 57 | BASE_FEATURE(kBrowserPeriodicYieldingToNative, |
| 58 | "BrowserPeriodicYieldingToNative", |
| 59 | base::FEATURE_DISABLED_BY_DEFAULT); |
Stephen Nusko | 408b9a9 | 2022-09-15 10:03:57 | [diff] [blame] | 60 | |
| 61 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 62 | kBrowserPeriodicYieldingToNativeNormalInputAfterMsParam{ |
| 63 | &kBrowserPeriodicYieldingToNative, |
| 64 | "yield_to_android_looper_after_ms_normal_input", base::Milliseconds(8)}; |
| 65 | |
| 66 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 67 | kBrowserPeriodicYieldingToNativeFlingInputAfterMsParam{ |
| 68 | &kBrowserPeriodicYieldingToNative, |
| 69 | "yield_to_android_looper_after_ms_fling_input", base::Milliseconds(16)}; |
| 70 | |
| 71 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 72 | kBrowserPeriodicYieldingToNativeNoInputAfterMsParam{ |
| 73 | &kBrowserPeriodicYieldingToNative, |
| 74 | "yield_to_android_looper_after_ms_no_input", base::Milliseconds(100)}; |
| 75 | |
| 76 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 77 | kBrowserPeriodicYieldingToNativeDelay{&kBrowserPeriodicYieldingToNative, |
| 78 | "non_delayed_looper_defer_for_ns", |
| 79 | base::Nanoseconds(500000)}; |
| 80 | |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 81 | // Leeway value applied to delayed tasks. An atomic is used here because the |
| 82 | // value is queried from multiple threads. |
| 83 | std::atomic<TimeDelta> g_task_leeway{kDefaultLeeway}; |
| 84 | |
| 85 | BASE_EXPORT void InitializeTaskLeeway() { |
| 86 | g_task_leeway.store(kTaskLeewayParam.Get(), std::memory_order_relaxed); |
| 87 | } |
| 88 | |
| 89 | BASE_EXPORT TimeDelta GetTaskLeeway() { |
| 90 | return g_task_leeway.load(std::memory_order_relaxed); |
| 91 | } |
| 92 | |
Francois Doray | 5b44e33f | 2018-11-09 22:08:13 | [diff] [blame] | 93 | } // namespace base |