Commit 996df584 authored by Alexander Timin's avatar Alexander Timin Committed by Chromium LUCI CQ

[scheduler] Add crash keys to sweeping delayed tasks.

R=shaseley@chromium.org
BUG=1155905

Change-Id: I80c643923a0c607f49e48a3e8813d197f696ec2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580524
Commit-Queue: Alexander Timin <altimin@chromium.org>
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Auto-Submit: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarScott Haseley <shaseley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835048}
parent 0bd47bdc
...@@ -1056,7 +1056,8 @@ void TaskQueueImpl::UpdateCrossThreadQueueStateLocked() { ...@@ -1056,7 +1056,8 @@ void TaskQueueImpl::UpdateCrossThreadQueueStateLocked() {
void TaskQueueImpl::ReclaimMemory(TimeTicks now) { void TaskQueueImpl::ReclaimMemory(TimeTicks now) {
if (main_thread_only().delayed_incoming_queue.empty()) if (main_thread_only().delayed_incoming_queue.empty())
return; return;
main_thread_only().delayed_incoming_queue.SweepCancelledTasks(); main_thread_only().delayed_incoming_queue.SweepCancelledTasks(
sequence_manager_);
// Also consider shrinking the work queue if it's wasting memory. // Also consider shrinking the work queue if it's wasting memory.
main_thread_only().delayed_work_queue->MaybeShrinkQueue(); main_thread_only().delayed_work_queue->MaybeShrinkQueue();
...@@ -1399,13 +1400,17 @@ void TaskQueueImpl::DelayedIncomingQueue::swap(DelayedIncomingQueue* rhs) { ...@@ -1399,13 +1400,17 @@ void TaskQueueImpl::DelayedIncomingQueue::swap(DelayedIncomingQueue* rhs) {
std::swap(queue_, rhs->queue_); std::swap(queue_, rhs->queue_);
} }
void TaskQueueImpl::DelayedIncomingQueue::SweepCancelledTasks() { void TaskQueueImpl::DelayedIncomingQueue::SweepCancelledTasks(
SequenceManagerImpl* sequence_manager) {
// Under the hood a std::priority_queue is a heap and usually it's built on // Under the hood a std::priority_queue is a heap and usually it's built on
// top of a std::vector. We poke at that vector directly here to filter out // top of a std::vector. We poke at that vector directly here to filter out
// canceled tasks in place. // canceled tasks in place.
bool task_deleted = false; bool task_deleted = false;
auto it = queue_.c.begin(); auto it = queue_.c.begin();
while (it != queue_.c.end()) { while (it != queue_.c.end()) {
// TODO(crbug.com/1155905): Remove after figuring out the cause of the
// crash.
sequence_manager->RecordCrashKeys(*it);
if (it->task.IsCancelled()) { if (it->task.IsCancelled()) {
if (it->is_high_res) if (it->is_high_res)
pending_high_res_tasks_--; pending_high_res_tasks_--;
......
...@@ -324,7 +324,9 @@ class BASE_EXPORT TaskQueueImpl { ...@@ -324,7 +324,9 @@ class BASE_EXPORT TaskQueueImpl {
return pending_high_res_tasks_; return pending_high_res_tasks_;
} }
void SweepCancelledTasks(); // TODO(crbug.com/1155905): we pass SequenceManager to be able to record
// crash keys. Remove this parameter after chasing down this crash.
void SweepCancelledTasks(SequenceManagerImpl* sequence_manager);
std::priority_queue<Task> TakeTasks() { return std::move(queue_); } std::priority_queue<Task> TakeTasks() { return std::move(queue_); }
Value AsValue(TimeTicks now) const; Value AsValue(TimeTicks now) const;
......
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