1 // Copyright 2018 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_TASK_TASK_FEATURES_H_ 6 #define BASE_TASK_TASK_FEATURES_H_ 7 8 #include "base/base_export.h" 9 #include "base/feature_list.h" 10 #include "base/metrics/field_trial_params.h" 11 #include "build/build_config.h" 12 13 namespace base { 14 15 // Fixed amount of threads that will be used as a cap for thread pools. 16 BASE_EXPORT BASE_DECLARE_FEATURE(kThreadPoolCap2); 17 18 extern const BASE_EXPORT base::FeatureParam<int> kThreadPoolCapRestrictedCount; 19 20 // Under this feature, a utility_thread_group will be created for 21 // running USER_VISIBLE tasks. 22 BASE_EXPORT BASE_DECLARE_FEATURE(kUseUtilityThreadGroup); 23 24 // Under this feature, worker threads are not reclaimed after a timeout. Rather, 25 // only excess workers are cleaned up immediately after finishing a task. 26 BASE_EXPORT BASE_DECLARE_FEATURE(kNoWorkerThreadReclaim); 27 28 // This feature controls whether ThreadPool WorkerThreads should hold off waking 29 // up to purge PartitionAlloc within the first minute of their lifetime. See 30 // base::internal::GetSleepDurationBeforePurge. 31 BASE_EXPORT BASE_DECLARE_FEATURE(kDelayFirstWorkerWake); 32 33 // Under this feature, a non-zero leeway is added to delayed tasks. Along with 34 // DelayPolicy, this affects the time at which a delayed task runs. 35 BASE_EXPORT BASE_DECLARE_FEATURE(kAddTaskLeewayFeature); 36 #if BUILDFLAG(IS_WIN) 37 constexpr TimeDelta kDefaultLeeway = Milliseconds(16); 38 #else 39 constexpr TimeDelta kDefaultLeeway = Milliseconds(8); 40 #endif // #if !BUILDFLAG(IS_WIN) 41 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kTaskLeewayParam; 42 43 // We consider that delayed tasks above |kMaxPreciseDelay| never need 44 // DelayPolicy::kPrecise. The default value is slightly above 30Hz timer. 45 constexpr TimeDelta kDefaultMaxPreciseDelay = Milliseconds(36); 46 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kMaxPreciseDelay; 47 48 // Under this feature, wake ups are aligned at a 8ms boundary when allowed per 49 // DelayPolicy. 50 BASE_EXPORT BASE_DECLARE_FEATURE(kAlignWakeUps); 51 52 // Under this feature, slack is added on mac message pumps that support it when 53 // allowed per DelayPolicy. 54 BASE_EXPORT BASE_DECLARE_FEATURE(kTimerSlackMac); 55 56 // Under this feature, tasks that need high resolution timer are determined 57 // based on explicit DelayPolicy rather than based on a threshold. 58 BASE_EXPORT BASE_DECLARE_FEATURE(kExplicitHighResolutionTimerWin); 59 60 // Under this feature, the Windows UI pump uses a WaitableEvent to wake itself 61 // up when not in a native nested loop. It also uses different control flow, 62 // calling Win32 MessagePump functions less often. 63 BASE_EXPORT BASE_DECLARE_FEATURE(kUIPumpImprovementsWin); 64 65 // Feature to run tasks by batches before pumping out messages. 66 BASE_EXPORT BASE_DECLARE_FEATURE(kRunTasksByBatches); 67 68 // Controls the max number of delayed tasks that can run before selecting an 69 // immediate task in sequence manager. 70 BASE_EXPORT BASE_DECLARE_FEATURE(kMaxDelayedStarvationTasks); 71 extern const BASE_EXPORT base::FeatureParam<int> 72 kMaxDelayedStarvationTasksParam; 73 74 // Feature to use ThreadGroupSemaphore instead of ThreadGroupImpl. 75 BASE_EXPORT BASE_DECLARE_FEATURE(kThreadGroupSemaphore); 76 extern const BASE_EXPORT base::FeatureParam<int> kMaxNumWorkersCreated; 77 78 } // namespace base 79 80 #endif // BASE_TASK_TASK_FEATURES_H_ 81