Commit 499ef40d authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[Responsiveness metrics] Update queue time when reenqueing deferred non-nestable tasks

Without this some metrics and trace events report jank for
deferred non-nestable tasks.
See bug for all expected side-effects of this change.

Drive-by: Fixed incoherent use of anonymous-namespaces in
          sequence_manager_impl_unittest.cc

R=altimin@chromium.org, fdoray@chromium.org

Bug: 1152095
Change-Id: I0ab9e52c508e6244e6263260918298deb70449a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555900
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831063}
parent b3ea38c9
......@@ -47,11 +47,13 @@ struct BASE_EXPORT PendingTask {
base::TimeTicks delayed_run_time;
// The time at which the task was queued. For SequenceManager tasks and
// ThreadPool non-delayed tasks, this happens at post time. For
// ThreadPool delayed tasks, this happens some time after the task's delay
// has expired. This is not set for SequenceManager tasks if
// SetAddQueueTimeToTasks(true) wasn't call. This defaults to a null TimeTicks
// if the task hasn't been inserted in a sequence yet.
// ThreadPool non-delayed tasks, this happens at post time. For ThreadPool
// delayed tasks, this happens some time after the task's delay has expired.
// For deferred non-nestable tasks, this is reset when the nested loop exits
// and the deferred tasks are pushed back at the front of the queue. This is
// not set for SequenceManager tasks if SetAddQueueTimeToTasks(true) wasn't
// called. This defaults to a null TimeTicks if the task hasn't been inserted
// in a sequence yet.
TimeTicks queue_time;
// Chain of symbols of the parent tasks which led to this one being posted.
......
......@@ -460,9 +460,18 @@ void SequenceManagerImpl::OnExitNestedRunLoop() {
// While we were nested some non-nestable tasks may have been deferred.
// We push them back onto the *front* of their original work queues,
// that's why we iterate |non_nestable_task_queue| in FIFO order.
LazyNow exited_nested_now(controller_->GetClock());
while (!main_thread_only().non_nestable_task_queue.empty()) {
internal::TaskQueueImpl::DeferredNonNestableTask& non_nestable_task =
main_thread_only().non_nestable_task_queue.back();
if (!non_nestable_task.task.queue_time.is_null()) {
// Adjust the deferred tasks' queue time to now so that intentionally
// deferred tasks are not unfairly considered as having been stuck in
// the queue for a while. Note: this does not affect task ordering as
// |enqueue_order| is untouched and deferred tasks will still be pushed
// back to the front of the queue.
non_nestable_task.task.queue_time = exited_nested_now.Now();
}
auto* const task_queue = non_nestable_task.task_queue;
task_queue->RequeueDeferredNonNestableTask(std::move(non_nestable_task));
main_thread_only().non_nestable_task_queue.pop_back();
......
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