Commit fbc6f8e7 authored by Hailey Wang's avatar Hailey Wang Committed by Commit Bot

Add tracing event for long first input delay

A trace is uploaded via "slow reports" when a long first input delay is detected (for opted-in clients). This trace event will make it easier to identify the location of the long delay when analyzing the trace.

Bug: 1055890
Change-Id: I479406c3c78accbc4c06ccaeab14f699bf8ccdf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078775Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Hailey Wang <haileywang@google.com>
Cr-Commit-Position: refs/heads/master@{#746526}
parent 6a4d8864
...@@ -27,6 +27,11 @@ int g_num_long_input_events = 0; ...@@ -27,6 +27,11 @@ int g_num_long_input_events = 0;
constexpr base::TimeDelta kInputDelayTraceEventThreshold = constexpr base::TimeDelta kInputDelayTraceEventThreshold =
base::TimeDelta::FromMilliseconds(250); base::TimeDelta::FromMilliseconds(250);
// The threshold to emit the "Long First Input Delay" trace event is the 99th
// percentile of the histogram on Windows Stable as of Feb 27, 2020.
constexpr base::TimeDelta kFirstInputDelayTraceEventThreshold =
base::TimeDelta::FromMilliseconds(575);
} // namespace } // namespace
// Required length of main thread and network quiet window for determining // Required length of main thread and network quiet window for determining
...@@ -237,10 +242,20 @@ void InteractiveDetector::HandleForInputDelay( ...@@ -237,10 +242,20 @@ void InteractiveDetector::HandleForInputDelay(
if (page_event_times_.first_input_delay.is_zero()) { if (page_event_times_.first_input_delay.is_zero()) {
page_event_times_.first_input_delay = delay; page_event_times_.first_input_delay = delay;
page_event_times_.first_input_timestamp = event_timestamp; page_event_times_.first_input_timestamp = event_timestamp;
}
// Emit a trace event to highlight long input delays. if (delay > kFirstInputDelayTraceEventThreshold) {
if (delay > kInputDelayTraceEventThreshold) { // Emit a trace event to highlight long first input delays.
TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(
"latency", "Long First Input Delay",
TRACE_ID_LOCAL(g_num_long_input_events), event_timestamp);
TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(
"latency", "Long First Input Delay",
TRACE_ID_LOCAL(g_num_long_input_events), event_timestamp + delay);
g_num_long_input_events++;
}
} else if (delay > kInputDelayTraceEventThreshold) {
// Emit a trace event to highlight long input delays from second input and
// onwards.
TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0( TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(
"latency", "Long Input Delay", TRACE_ID_LOCAL(g_num_long_input_events), "latency", "Long Input Delay", TRACE_ID_LOCAL(g_num_long_input_events),
event_timestamp); event_timestamp);
......
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