Commit 26635539 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

Reland "[scheduler] Add task type and queue type to tracing."

This is a reland of 775612b8

Original change's description:
> [scheduler] Add task type and queue type to tracing.
> 
> R=skyostil@chromium.org
> 
> Change-Id: Id0aea377558e876c8178e82eb3a170f678c415cc
> Reviewed-on: https://chromium-review.googlesource.com/1140717
> Commit-Queue: Alexander Timin <altimin@chromium.org>
> Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#576201}

Change-Id: I8289cc417637e7e605dbb5f9df8cc6ea68fa457f
Reviewed-on: https://chromium-review.googlesource.com/1143224Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577159}
parent 917cf4f6
......@@ -293,6 +293,24 @@ void SequenceManagerImpl::SetNextDelayedDoWork(LazyNow* lazy_now,
}
Optional<PendingTask> SequenceManagerImpl::TakeTask() {
Optional<PendingTask> task = TakeTaskImpl();
if (!task)
return base::nullopt;
ExecutingTask& executing_task =
*main_thread_only().task_execution_stack.rbegin();
// It's important that there are no active trace events here which will
// terminate before we finish executing the task.
TRACE_EVENT_BEGIN2(TRACE_DISABLED_BY_DEFAULT("sequence_manager"),
"SequenceManager::RunTask", "queue_type",
executing_task.task_queue->GetName(), "task_type",
executing_task.task_type);
return task;
}
Optional<PendingTask> SequenceManagerImpl::TakeTaskImpl() {
CHECK(Validate());
DCHECK_CALLED_ON_VALID_THREAD(main_thread_checker_);
......@@ -357,6 +375,7 @@ Optional<PendingTask> SequenceManagerImpl::TakeTask() {
ExecutingTask& executing_task =
*main_thread_only().task_execution_stack.rbegin();
NotifyWillProcessTask(&executing_task, &lazy_now);
return std::move(executing_task.pending_task);
}
}
......@@ -365,6 +384,10 @@ void SequenceManagerImpl::DidRunTask() {
LazyNow lazy_now(controller_->GetClock());
ExecutingTask& executing_task =
*main_thread_only().task_execution_stack.rbegin();
TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("sequence_manager"),
"SequenceManagerImpl::RunTask");
NotifyDidProcessTask(&executing_task, &lazy_now);
main_thread_only().task_execution_stack.pop_back();
......
......@@ -171,16 +171,20 @@ class BASE_EXPORT SequenceManagerImpl
// selector interface is unaware of those. This struct keeps track off all
// task related state needed to make pairs of TakeTask() / DidRunTask() work.
struct ExecutingTask {
ExecutingTask(internal::TaskQueueImpl::Task&& pending_task,
ExecutingTask(internal::TaskQueueImpl::Task&& task,
internal::TaskQueueImpl* task_queue,
TaskQueue::TaskTiming task_timing)
: pending_task(std::move(pending_task)),
: pending_task(std::move(task)),
task_queue(task_queue),
task_timing(task_timing) {}
task_timing(task_timing),
task_type(pending_task.task_type()) {}
internal::TaskQueueImpl::Task pending_task;
internal::TaskQueueImpl* task_queue = nullptr;
TaskQueue::TaskTiming task_timing;
// Save task metadata to use in after running a task as |pending_task|
// won't be available then.
int task_type;
};
struct MainThreadOnly {
......@@ -286,6 +290,10 @@ class BASE_EXPORT SequenceManagerImpl
bool ShouldRecordCPUTimeForTask();
// Helper to terminate all scoped trace events to allow starting new ones
// in TakeTask().
Optional<PendingTask> TakeTaskImpl();
// Determines if wall time or thread time should be recorded for the next
// task.
TaskQueue::TaskTiming InitializeTaskTiming(
......
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