Commit 775612b8 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[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: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576201}
parent 30e38a44
...@@ -293,6 +293,22 @@ void SequenceManagerImpl::SetNextDelayedDoWork(LazyNow* lazy_now, ...@@ -293,6 +293,22 @@ void SequenceManagerImpl::SetNextDelayedDoWork(LazyNow* lazy_now,
} }
Optional<PendingTask> SequenceManagerImpl::TakeTask() { Optional<PendingTask> SequenceManagerImpl::TakeTask() {
Optional<PendingTask> task = TakeTaskImpl();
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()); CHECK(Validate());
DCHECK_CALLED_ON_VALID_THREAD(main_thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(main_thread_checker_);
...@@ -357,6 +373,7 @@ Optional<PendingTask> SequenceManagerImpl::TakeTask() { ...@@ -357,6 +373,7 @@ Optional<PendingTask> SequenceManagerImpl::TakeTask() {
ExecutingTask& executing_task = ExecutingTask& executing_task =
*main_thread_only().task_execution_stack.rbegin(); *main_thread_only().task_execution_stack.rbegin();
NotifyWillProcessTask(&executing_task, &lazy_now); NotifyWillProcessTask(&executing_task, &lazy_now);
return std::move(executing_task.pending_task); return std::move(executing_task.pending_task);
} }
} }
...@@ -365,6 +382,10 @@ void SequenceManagerImpl::DidRunTask() { ...@@ -365,6 +382,10 @@ void SequenceManagerImpl::DidRunTask() {
LazyNow lazy_now(controller_->GetClock()); LazyNow lazy_now(controller_->GetClock());
ExecutingTask& executing_task = ExecutingTask& executing_task =
*main_thread_only().task_execution_stack.rbegin(); *main_thread_only().task_execution_stack.rbegin();
TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("sequence_manager"),
"SequenceManagerImpl::RunTask");
NotifyDidProcessTask(&executing_task, &lazy_now); NotifyDidProcessTask(&executing_task, &lazy_now);
main_thread_only().task_execution_stack.pop_back(); main_thread_only().task_execution_stack.pop_back();
......
...@@ -171,16 +171,20 @@ class BASE_EXPORT SequenceManagerImpl ...@@ -171,16 +171,20 @@ class BASE_EXPORT SequenceManagerImpl
// selector interface is unaware of those. This struct keeps track off all // selector interface is unaware of those. This struct keeps track off all
// task related state needed to make pairs of TakeTask() / DidRunTask() work. // task related state needed to make pairs of TakeTask() / DidRunTask() work.
struct ExecutingTask { struct ExecutingTask {
ExecutingTask(internal::TaskQueueImpl::Task&& pending_task, ExecutingTask(internal::TaskQueueImpl::Task&& task,
internal::TaskQueueImpl* task_queue, internal::TaskQueueImpl* task_queue,
TaskQueue::TaskTiming task_timing) TaskQueue::TaskTiming task_timing)
: pending_task(std::move(pending_task)), : pending_task(std::move(task)),
task_queue(task_queue), 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 pending_task;
internal::TaskQueueImpl* task_queue = nullptr; internal::TaskQueueImpl* task_queue = nullptr;
TaskQueue::TaskTiming task_timing; 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 { struct MainThreadOnly {
...@@ -286,6 +290,10 @@ class BASE_EXPORT SequenceManagerImpl ...@@ -286,6 +290,10 @@ class BASE_EXPORT SequenceManagerImpl
bool ShouldRecordCPUTimeForTask(); 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 // Determines if wall time or thread time should be recorded for the next
// task. // task.
TaskQueue::TaskTiming InitializeTaskTiming( 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