We have extensive metric coverage and understanding of types of work being run on the renderer main thread. Our understanding of work being done on other renderer threads, on the other hand, is very limited.
As a first step, we need to add a metric to compare total CPU usage of the main thread tasks with CPU usage coming from non-main thread tasks.
The main entrypoint for main thread metrics is RendererSchedulerImpl::OnTaskCompleted (and RendererMetricsHelper::RecordTaskMetrics which is being called from the abovementioned function). The RendererSchedulerImpl::OnTaskCompleted is plumbed through MainThreadTaskQueue::OnTaskCompleted, which is called via a callback (task_queue_impl->SetOnTaskCompletedHandler in the constructor of MainThreadTaskQueue).
It is proposed to add similar infrastructure for WorkerTaskQueue and WorkerScheduler and record RendererScheduler.TaskDurationPerThreadType with kMainThread, kWorkerThread and kCompositorThread as thread types. kMainThread-related part can be recorded on the main thread, similar to existing metrics like RendererScheduler.TaskDurationPerQueueType. kWorkerThread and kCompositor thread should be recorded in the newly introduced WorkerScheduler::RecordTaskMetrics. A virtual method may be needed to distinguish WorkerScheduler and CompositorWorkerScheduler.
P.S. For this new metrics, a separated task_duration_reporter per thread will be needed.
Comment 1 by l...@chromium.org
, Nov 27 2017