Commit df14eaab authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[ThreadPool]: Add kFixedMaxBestEffortTasks

Feature to disable max_best_effort_tasks increases with ScopedBlockingCall.
This feature goes along with MayBlockWithoutDelay.
It was made a separate feature to enable multi-arm and detect possible
regressions from deadlock if all BEST_EFFORT tasks are blocked, although this
should not happen in practice.

Bug: 1026785, 1059767
Change-Id: I3a0cb71f0fec3b0dbe812b11084f4d391cba1c69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2116649Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753629}
parent 299fa614
......@@ -17,6 +17,9 @@ const Feature kNoDetachBelowInitialCapacity = {
const Feature kMayBlockWithoutDelay = {"MayBlockWithoutDelay",
base::FEATURE_DISABLED_BY_DEFAULT};
const Feature kFixedMaxBestEffortTasks = {"FixedMaxBestEffortTasks",
base::FEATURE_DISABLED_BY_DEFAULT};
#if defined(OS_WIN) || defined(OS_MACOSX)
const Feature kUseNativeThreadPool = {"UseNativeThreadPool",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -23,6 +23,12 @@ extern const BASE_EXPORT Feature kNoDetachBelowInitialCapacity;
// instead of waiting for a threshold in the foreground thread group.
extern const BASE_EXPORT Feature kMayBlockWithoutDelay;
// Under this feature, best effort capacity is never increased.
// While it's unlikely we'd ship this as-is, this experiment allows us to
// determine whether blocked worker replacement logic on best-effort tasks has
// any impact on guardian metrics.
extern const BASE_EXPORT Feature kFixedMaxBestEffortTasks;
#if defined(OS_WIN) || defined(OS_MACOSX)
#define HAS_NATIVE_THREAD_POOL() 1
#else
......
......@@ -417,8 +417,9 @@ void ThreadGroupImpl::Start(
DCHECK(!replacement_thread_group_);
in_start().may_block_without_delay =
FeatureList::IsEnabled(kMayBlockWithoutDelay) &&
priority_hint_ == ThreadPriority::NORMAL;
FeatureList::IsEnabled(kMayBlockWithoutDelay);
in_start().fixed_max_best_effort_tasks =
FeatureList::IsEnabled(kFixedMaxBestEffortTasks);
in_start().may_block_threshold =
may_block_threshold ? may_block_threshold.value()
: (priority_hint_ == ThreadPriority::NORMAL
......@@ -1217,16 +1218,20 @@ void ThreadGroupImpl::DecrementMaxTasksLockRequired(TaskPriority priority) {
DCHECK_GT(num_running_tasks_, 0U);
DCHECK_GT(max_tasks_, 0U);
--max_tasks_;
if (priority == TaskPriority::BEST_EFFORT)
if (priority == TaskPriority::BEST_EFFORT &&
!after_start().fixed_max_best_effort_tasks) {
--max_best_effort_tasks_;
}
UpdateMinAllowedPriorityLockRequired();
}
void ThreadGroupImpl::IncrementMaxTasksLockRequired(TaskPriority priority) {
DCHECK_GT(num_running_tasks_, 0U);
++max_tasks_;
if (priority == TaskPriority::BEST_EFFORT)
if (priority == TaskPriority::BEST_EFFORT &&
!after_start().fixed_max_best_effort_tasks) {
++max_best_effort_tasks_;
}
UpdateMinAllowedPriorityLockRequired();
}
......
......@@ -242,6 +242,7 @@ class BASE_EXPORT ThreadGroupImpl : public ThreadGroup {
WorkerThreadObserver* worker_thread_observer = nullptr;
bool may_block_without_delay;
bool fixed_max_best_effort_tasks;
// Threshold after which the max tasks is increased to compensate for a
// worker that is within a MAY_BLOCK ScopedBlockingCall.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment