Commit 37e26ab9 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

TaskScheduler: Remove TaskScheduler.BlockShutdownTasksPostedDuringShutdown.

The histogram shows that 99.9% of the time, less than
1000 BLOCK_SHUTDOWN tasks are posted during shutdown. This CL replaces
the histogram with a crash when the number is to high, which will be
more actionnable.

Note: Current histogram data shows that this crash will happen
less than 0.1% of the time.

Bug: 697731
Change-Id: I553caf93b0109a1bd44c5c841d0f557e6cad16cd
Reviewed-on: https://chromium-review.googlesource.com/c/1280670Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600892}
parent 9fdccb84
...@@ -133,17 +133,11 @@ HistogramBase* GetHistogramForTaskTraits( ...@@ -133,17 +133,11 @@ HistogramBase* GetHistogramForTaskTraits(
: 0]; : 0];
} }
// Upper bound for the // Maximum number of BLOCK_SHUTDOWN tasks that can be posted during shutdown. If
// TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram. // that many BLOCK_SHUTDOWN tasks are posted during shutdown, it is possible
constexpr HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = // that buggy code is posting an infinite number of tasks and that shutdown will
1000; // never complete. The mitigation is to induce a crash.
constexpr int kMaxBlockShutdownTasksPostedDuringShutdown = 1000;
void RecordNumBlockShutdownTasksPostedDuringShutdown(
HistogramBase::Sample value) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
"TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1,
kMaxBlockShutdownTasksPostedDuringShutdown, 50);
}
// Returns the maximum number of TaskPriority::BEST_EFFORT sequences that can be // Returns the maximum number of TaskPriority::BEST_EFFORT sequences that can be
// scheduled concurrently based on command line flags. // scheduled concurrently based on command line flags.
...@@ -707,20 +701,6 @@ void TaskTracker::PerformShutdown() { ...@@ -707,20 +701,6 @@ void TaskTracker::PerformShutdown() {
base::ThreadRestrictions::ScopedAllowWait allow_wait; base::ThreadRestrictions::ScopedAllowWait allow_wait;
shutdown_event_->Wait(); shutdown_event_->Wait();
} }
{
AutoSchedulerLock auto_lock(shutdown_lock_);
// Record TaskScheduler.BlockShutdownTasksPostedDuringShutdown if less than
// |kMaxBlockShutdownTasksPostedDuringShutdown| BLOCK_SHUTDOWN tasks were
// posted during shutdown. Otherwise, the histogram has already been
// recorded in BeforePostTask().
if (num_block_shutdown_tasks_posted_during_shutdown_ <
kMaxBlockShutdownTasksPostedDuringShutdown) {
RecordNumBlockShutdownTasksPostedDuringShutdown(
num_block_shutdown_tasks_posted_during_shutdown_);
}
}
} }
void TaskTracker::SetMaxNumScheduledSequences(int max_scheduled_sequences, void TaskTracker::SetMaxNumScheduledSequences(int max_scheduled_sequences,
...@@ -819,16 +799,8 @@ bool TaskTracker::BeforePostTask( ...@@ -819,16 +799,8 @@ bool TaskTracker::BeforePostTask(
} }
++num_block_shutdown_tasks_posted_during_shutdown_; ++num_block_shutdown_tasks_posted_during_shutdown_;
CHECK_LT(num_block_shutdown_tasks_posted_during_shutdown_,
if (num_block_shutdown_tasks_posted_during_shutdown_ == kMaxBlockShutdownTasksPostedDuringShutdown);
kMaxBlockShutdownTasksPostedDuringShutdown) {
// Record the TaskScheduler.BlockShutdownTasksPostedDuringShutdown
// histogram as soon as its upper bound is hit. That way, a value will
// be recorded even if an infinite number of BLOCK_SHUTDOWN tasks are
// posted, preventing shutdown to complete.
RecordNumBlockShutdownTasksPostedDuringShutdown(
num_block_shutdown_tasks_posted_during_shutdown_);
}
} }
return true; return true;
......
...@@ -109987,6 +109987,12 @@ uploading your change for review. ...@@ -109987,6 +109987,12 @@ uploading your change for review.
<histogram name="TaskScheduler.BlockShutdownTasksPostedDuringShutdown" <histogram name="TaskScheduler.BlockShutdownTasksPostedDuringShutdown"
units="tasks"> units="tasks">
<obsolete>
Deprecated 10/2018. Instead of recording a histogram with the number of
BLOCK_SHUTDOWN tasks posted during shutdown, we generate a crash when too
many BLOCK_SHUTDOWN tasks are posted during shutdown. A crash dump is more
actionnable than a histogram.
</obsolete>
<owner>fdoray@chromium.org</owner> <owner>fdoray@chromium.org</owner>
<summary> <summary>
Number of BLOCK_SHUTDOWN tasks that were posted to a base::TaskScheduler Number of BLOCK_SHUTDOWN tasks that were posted to a base::TaskScheduler
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