Commit 9b4909cf authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Add a new UMA RendererScheduler.TaskDurationPerTaskType

This CL adds a new UMA RendererScheduler.TaskDurationPerTaskType to know
what kind of task type of tasks consumes how much time.

Bug: 780785
Change-Id: I2dc6f4d042945d79089eb1320e220f2b91de51ca
Reviewed-on: https://chromium-review.googlesource.com/771374Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517366}
parent 1732f2b0
......@@ -61,6 +61,9 @@ scoped_refptr<WebTaskRunner> WorkerGlobalScopeScheduler::GetTaskRunner(
// move them into other task runners. See also comments in
// Get(LocalFrame). (https://crbug.com/670534)
return WebTaskRunnerImpl::Create(task_queue_, type);
case TaskType::kCount:
NOTREACHED();
break;
}
NOTREACHED();
return nullptr;
......
......@@ -120,6 +120,7 @@ class PLATFORM_EXPORT RendererMetricsHelper {
~RendererMetricsHelper();
void RecordTaskMetrics(MainThreadTaskQueue* queue,
const TaskQueue::Task& task,
base::TimeTicks start_time,
base::TimeTicks end_time);
......@@ -143,34 +144,44 @@ class PLATFORM_EXPORT RendererMetricsHelper {
using TaskDurationPerQueueTypeMetricReporter =
TaskDurationMetricReporter<MainThreadTaskQueue::QueueType>;
TaskDurationPerQueueTypeMetricReporter task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter foreground_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
foreground_first_minute_task_duration_reporter;
foreground_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
foreground_second_minute_task_duration_reporter;
foreground_first_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
foreground_third_minute_task_duration_reporter;
foreground_second_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
foreground_after_third_minute_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter background_task_duration_reporter;
foreground_third_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_first_minute_task_duration_reporter;
foreground_after_third_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_second_minute_task_duration_reporter;
background_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_third_minute_task_duration_reporter;
background_first_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_fourth_minute_task_duration_reporter;
background_second_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_fifth_minute_task_duration_reporter;
background_third_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_after_fifth_minute_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter hidden_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter visible_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter hidden_music_task_duration_reporter;
background_fourth_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_fifth_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
background_after_fifth_minute_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
hidden_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
visible_per_queue_type_task_duration_reporter;
TaskDurationPerQueueTypeMetricReporter
hidden_music_per_queue_type_task_duration_reporter;
TaskDurationMetricReporter<FrameType> per_frame_type_duration_reporter;
using TaskDurationPerTaskTypeMetricReporter =
TaskDurationMetricReporter<TaskType>;
TaskDurationPerTaskTypeMetricReporter per_task_type_duration_reporter;
TaskDurationMetricReporter<FrameType> frame_type_duration_reporter;
MainThreadTaskLoadState main_thread_task_load_state;
DISALLOW_COPY_AND_ASSIGN(RendererMetricsHelper);
......
......@@ -54,7 +54,12 @@ class RendererMetricsHelperTest : public ::testing::Test {
clock_->SetNowTicks(start + duration);
scoped_refptr<MainThreadTaskQueueForTest> queue(
new MainThreadTaskQueueForTest(queue_type));
metrics_helper_->RecordTaskMetrics(queue.get(), start, start + duration);
// Pass an empty task for recording.
TaskQueue::PostedTask posted_task(base::Closure(), FROM_HERE);
TaskQueue::Task task(std::move(posted_task), base::TimeTicks());
metrics_helper_->RecordTaskMetrics(queue.get(), task, start,
start + duration);
}
base::TimeTicks Microseconds(int microseconds) {
......
......@@ -2167,7 +2167,7 @@ void RendererSchedulerImpl::OnTaskCompleted(MainThreadTaskQueue* queue,
task_queue_throttler()->OnTaskRunTimeReported(queue, start, end);
// TODO(altimin): Per-page metrics should also be considered.
main_thread_only().metrics_helper.RecordTaskMetrics(queue, start, end);
main_thread_only().metrics_helper.RecordTaskMetrics(queue, task, start, end);
}
void RendererSchedulerImpl::OnBeginNestedRunLoop() {
......
......@@ -258,6 +258,9 @@ scoped_refptr<blink::WebTaskRunner> WebFrameSchedulerImpl::GetTaskRunner(
return WebTaskRunnerImpl::Create(PausableTaskQueue(), type);
case TaskType::kUnthrottled:
return WebTaskRunnerImpl::Create(UnpausableTaskQueue(), type);
case TaskType::kCount:
NOTREACHED();
break;
}
NOTREACHED();
return nullptr;
......
......@@ -8,102 +8,105 @@
namespace blink {
// A list of task sources known to Blink according to the spec.
// This enum is used for a histogram and it should not be re-numbered.
enum class TaskType : unsigned {
// Speced tasks and related internal tasks should be posted to one of
// the following task runners. These task runners may be throttled.
// 0 is reserved to represent that TaskType is not specified.
// https://html.spec.whatwg.org/multipage/webappapis.html#generic-task-sources
//
// This task source is used for features that react to DOM manipulations, such
// as things that happen in a non-blocking fashion when an element is inserted
// into the document.
kDOMManipulation,
kDOMManipulation = 1,
// This task source is used for features that react to user interaction, for
// example keyboard or mouse input. Events sent in response to user input
// (e.g. click events) must be fired using tasks queued with the user
// interaction task source.
kUserInteraction,
kUserInteraction = 2,
// This task source is used for features that trigger in response to network
// activity.
kNetworking,
kNetworking = 3,
// This task source is used for control messages between kNetworking tasks.
kNetworkingControl,
kNetworkingControl = 4,
// This task source is used to queue calls to history.back() and similar APIs.
kHistoryTraversal,
kHistoryTraversal = 5,
// https://html.spec.whatwg.org/multipage/embedded-content.html#the-embed-element
// This task source is used for the embed element setup steps.
kEmbed,
kEmbed = 6,
// https://html.spec.whatwg.org/multipage/embedded-content.html#media-elements
// This task source is used for all tasks queued in the [Media elements]
// section and subsections of the spec unless explicitly specified otherwise.
kMediaElementEvent,
kMediaElementEvent = 7,
// https://html.spec.whatwg.org/multipage/scripting.html#the-canvas-element
// This task source is used to invoke the result callback of
// HTMLCanvasElement.toBlob().
kCanvasBlobSerialization,
kCanvasBlobSerialization = 8,
// https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model
// This task source is used when an algorithm requires a microtask to be
// queued.
kMicrotask,
kMicrotask = 9,
// https://html.spec.whatwg.org/multipage/webappapis.html#timers
// This task source is used to queue tasks queued by setInterval() and similar
// APIs.
kJavascriptTimer,
kJavascriptTimer = 10,
// https://html.spec.whatwg.org/multipage/comms.html#sse-processing-model
// This task source is used for any tasks that are queued by EventSource
// objects.
kRemoteEvent,
kRemoteEvent = 11,
// https://html.spec.whatwg.org/multipage/comms.html#feedback-from-the-protocol
// The task source for all tasks queued in the [WebSocket] section of the
// spec.
kWebSocket,
kWebSocket = 12,
// https://html.spec.whatwg.org/multipage/comms.html#web-messaging
// This task source is used for the tasks in cross-document messaging.
kPostedMessage,
kPostedMessage = 13,
// https://html.spec.whatwg.org/multipage/comms.html#message-ports
kUnshippedPortMessage,
kUnshippedPortMessage = 14,
// https://www.w3.org/TR/FileAPI/#blobreader-task-source
// This task source is used for all tasks queued in the FileAPI spec to read
// byte sequences associated with Blob and File objects.
kFileReading,
kFileReading = 15,
// https://www.w3.org/TR/IndexedDB/#request-api
kDatabaseAccess,
kDatabaseAccess = 16,
// https://w3c.github.io/presentation-api/#common-idioms
// This task source is used for all tasks in the Presentation API spec.
kPresentation,
kPresentation = 17,
// https://www.w3.org/TR/2016/WD-generic-sensor-20160830/#sensor-task-source
// This task source is used for all tasks in the Sensor API spec.
kSensor,
kSensor = 18,
// https://w3c.github.io/performance-timeline/#performance-timeline
kPerformanceTimeline,
kPerformanceTimeline = 19,
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
// This task source is used for all tasks in the WebGL spec.
kWebGL,
kWebGL = 20,
// https://www.w3.org/TR/requestidlecallback/#start-an-event-loop-s-idle-period
kIdleTask,
kIdleTask = 21,
// Use MiscPlatformAPI for a task that is defined in the spec but is not yet
// associated with any specific task runner in the spec. MiscPlatformAPI is
// not encouraged for stable and matured APIs. The spec should define the task
// runner explicitly.
// The task runner may be throttled.
kMiscPlatformAPI,
kMiscPlatformAPI = 22,
// Other internal tasks that cannot fit any of the above task runners
// can be posted here, but the usage is not encouraged. The task runner
......@@ -111,12 +114,14 @@ enum class TaskType : unsigned {
//
// UnspecedLoading type should be used for all tasks associated with
// loading page content, UnspecedTimer should be used for all other purposes.
kUnspecedTimer,
kUnspecedLoading,
kUnspecedTimer = 23,
kUnspecedLoading = 24,
// Tasks that must not be throttled should be posted here, but the usage
// should be very limited.
kUnthrottled,
kUnthrottled = 25,
kCount = 26,
};
} // namespace blink
......
......@@ -34627,6 +34627,35 @@ Called by update_net_error_codes.py.-->
<int value="17" label="IPC"/>
</enum>
<enum name="RendererSchedulerTaskType">
<int value="0" label="None"/>
<int value="1" label="DOMManipulation"/>
<int value="2" label="UserInteraction"/>
<int value="3" label="Networking"/>
<int value="4" label="NetworkingControl"/>
<int value="5" label="HistoryTraversal"/>
<int value="6" label="Embed"/>
<int value="7" label="MediaElementEvent"/>
<int value="8" label="CanvasBlobSerialization"/>
<int value="9" label="Microtask"/>
<int value="10" label="JavascriptTimer"/>
<int value="11" label="RemoteEvent"/>
<int value="12" label="WebSocket"/>
<int value="13" label="PostedMessage"/>
<int value="14" label="UnshippedPortMessage"/>
<int value="15" label="FileReading"/>
<int value="16" label="DatabaseAccess"/>
<int value="17" label="Presentation"/>
<int value="18" label="Sensor"/>
<int value="19" label="PerformanceTimeline"/>
<int value="20" label="WebGL"/>
<int value="21" label="IdleTask"/>
<int value="22" label="MiscPlatformAPI"/>
<int value="23" label="UnspecedTimer"/>
<int value="24" label="UnspecedLoading"/>
<int value="25" label="Unthrottled"/>
</enum>
<enum name="RendererType">
<int value="1" label="Normal renderer"/>
<int value="2" label="Extension renderer"/>
......@@ -68879,6 +68879,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="RendererScheduler.TaskDurationPerTaskType"
enum="RendererSchedulerTaskType" units="ms">
<owner>altimin@chromium.org</owner>
<owner>hajimehoshi@chromium.org</owner>
<summary>
Total duration of renderer per-frame tasks split per task type. Used to
monitor usage of each task type. Reported each time when task is completed
and current accumulated duration is longer than 1ms.
This metric is susceptible to problematic outliers and should be analyzed
with custom scripts accounting for that rather than from a dashboard.
</summary>
</histogram>
<histogram name="RendererScheduler.TaskQueueManager.DelayedTaskLateness"
units="ms">
<obsolete>
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