Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc

Issue 2341413002: New scroll latency metrics added for touch and wheel. (Closed)
Patch Set: Added comments for deprecation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 (end.event_time - start.event_time).InMicroseconds(), \ 85 (end.event_time - start.event_time).InMicroseconds(), \
86 1000, 200000, 50) 86 1000, 200000, 50)
87 87
88 // Short scroll latency component that is mostly under 50ms. 88 // Short scroll latency component that is mostly under 50ms.
89 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ 89 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \
90 UMA_HISTOGRAM_CUSTOM_COUNTS( \ 90 UMA_HISTOGRAM_CUSTOM_COUNTS( \
91 name, \ 91 name, \
92 (end.event_time - start.event_time).InMicroseconds(), \ 92 (end.event_time - start.event_time).InMicroseconds(), \
93 1, 50000, 50) 93 1, 50000, 50)
94 94
95 // Check valid timing for start and end latency components.
96 #define CONFIRM_VALID_TIMING(start, end) \
97 DCHECK(!start.first_event_time.is_null()); \
98 DCHECK(!end.last_event_time.is_null()); \
99 DCHECK_GE(end.last_event_time, start.first_event_time);
100
101 // Touch/wheel to scroll latency that is mostly under 1 second.
102 #define UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(name, start, end) \
103 CONFIRM_VALID_TIMING(start, end) \
104 UMA_HISTOGRAM_CUSTOM_COUNTS( \
105 name, (end.last_event_time - start.first_event_time).InMicroseconds(), \
106 1, 1000000, 100)
107
108 // Long touch/wheel scroll latency component that is mostly under 200ms.
109 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(name, start, end) \
110 CONFIRM_VALID_TIMING(start, end) \
111 UMA_HISTOGRAM_CUSTOM_COUNTS( \
112 name, (end.last_event_time - start.first_event_time).InMicroseconds(), \
113 1000, 200000, 50)
114
115 // Short touch/wheel scroll latency component that is mostly under 50ms.
116 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(name, start, end) \
117 CONFIRM_VALID_TIMING(start, end) \
118 UMA_HISTOGRAM_CUSTOM_COUNTS( \
119 name, (end.last_event_time - start.first_event_time).InMicroseconds(), \
120 1, 50000, 50)
121
95 void ComputeScrollLatencyHistograms( 122 void ComputeScrollLatencyHistograms(
96 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, 123 const LatencyInfo::LatencyComponent& gpu_swap_begin_component,
97 const LatencyInfo::LatencyComponent& gpu_swap_end_component, 124 const LatencyInfo::LatencyComponent& gpu_swap_end_component,
98 int64_t latency_component_id, 125 int64_t latency_component_id,
99 const LatencyInfo& latency, 126 const LatencyInfo& latency,
100 bool is_running_navigation_hint_task) { 127 bool is_running_navigation_hint_task) {
101 DCHECK(!latency.coalesced()); 128 DCHECK(!latency.coalesced());
102 if (latency.coalesced()) 129 if (latency.coalesced())
103 return; 130 return;
104 131
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 230
204 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( 231 UMA_HISTOGRAM_SCROLL_LATENCY_LONG(
205 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 232 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap",
206 browser_received_swap_component, gpu_swap_begin_component); 233 browser_received_swap_component, gpu_swap_begin_component);
207 234
208 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", 235 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap",
209 gpu_swap_begin_component, 236 gpu_swap_begin_component,
210 gpu_swap_end_component); 237 gpu_swap_end_component);
211 } 238 }
212 239
240 void ComputeTouchAndWheelScrollLatencyHistograms(
241 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component,
242 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component,
243 int64_t latency_component_id,
244 const ui::LatencyInfo& latency,
245 const std::string event_type_name) {
246 DCHECK(!latency.coalesced());
247 if (latency.coalesced())
248 return;
249
250 LatencyInfo::LatencyComponent original_component;
251 if (latency.FindLatency(
252 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
253 latency_component_id, &original_component)) {
254 // This UMA metric tracks the time between the final frame swap for the
255 // first scroll event in a sequence and the original timestamp of that
256 // scroll event's underlying touch/wheel event.
257 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
258 "Event.Latency." + event_type_name +
259 ".TimeToFirstScrollUpdateSwapBegin2",
260 original_component, gpu_swap_begin_component);
261 } else if (latency.FindLatency(
262 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
263 latency_component_id, &original_component)) {
264 // This UMA metric tracks the time from when the original touch event is
265 // created to when the scroll gesture results in final frame swap.
tdresser 2016/09/30 17:16:38 Clarify that this excludes the first scroll.
sahel 2016/10/04 14:22:25 Done.
266 if (event_type_name == "Touch") {
267 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
268 "Event.Latency." + event_type_name + ".TimeToScrollUpdateSwapBegin2",
269 original_component, gpu_swap_begin_component);
270 }
271 } else {
272 // No original component found.
273 return;
274 }
275
276 LatencyInfo::LatencyComponent rendering_scheduled_component;
277 bool rendering_scheduled_on_main = latency.FindLatency(
278 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
279 &rendering_scheduled_component);
280 if (!rendering_scheduled_on_main) {
281 if (!latency.FindLatency(
282 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0,
283 &rendering_scheduled_component))
284 return;
285 }
286
287 if (rendering_scheduled_on_main) {
288 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
289 "Event.Latency.ScrollUpdate." + event_type_name +
290 ".TimeToHandled2_Main",
291 original_component, rendering_scheduled_component);
292 } else {
293 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
294 "Event.Latency.ScrollUpdate." + event_type_name +
295 ".TimeToHandled2_Impl",
296 original_component, rendering_scheduled_component);
297 }
298
299 LatencyInfo::LatencyComponent renderer_swap_component;
300 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0,
301 &renderer_swap_component))
302 return;
303
304 if (rendering_scheduled_on_main) {
305 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
306 "Event.Latency.ScrollUpdate." + event_type_name +
Steven Holte 2016/09/30 22:10:05 Computing names like this doesn't work when using
sahel 2016/10/04 14:22:26 Done.
307 ".HandledToRendererSwap2_Main",
308 rendering_scheduled_component, renderer_swap_component);
309 } else {
310 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
311 "Event.Latency.ScrollUpdate." + event_type_name +
312 ".HandledToRendererSwap2_Impl",
313 rendering_scheduled_component, renderer_swap_component);
314 }
315
316 LatencyInfo::LatencyComponent browser_received_swap_component;
317 if (!latency.FindLatency(
318 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0,
319 &browser_received_swap_component))
320 return;
321
322 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
323 "Event.Latency.ScrollUpdate." + event_type_name +
324 ".RendererSwapToBrowserNotified2",
325 renderer_swap_component, browser_received_swap_component);
326
327 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
328 "Event.Latency.ScrollUpdate." + event_type_name +
329 ".BrowserNotifiedToBeforeGpuSwap2",
330 browser_received_swap_component, gpu_swap_begin_component);
331
332 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
333 "Event.Latency.ScrollUpdate." + event_type_name + ".GpuSwap2",
334 gpu_swap_begin_component, gpu_swap_end_component);
335 }
213 // LatencyComponents generated in the renderer must have component IDs 336 // LatencyComponents generated in the renderer must have component IDs
214 // provided to them by the browser process. This function adds the correct 337 // provided to them by the browser process. This function adds the correct
215 // component ID where necessary. 338 // component ID where necessary.
216 void AddLatencyInfoComponentIds(LatencyInfo* latency, 339 void AddLatencyInfoComponentIds(LatencyInfo* latency,
217 int64_t latency_component_id) { 340 int64_t latency_component_id) {
218 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; 341 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key;
219 std::vector<LatencyInfo::LatencyComponent> new_components_value; 342 std::vector<LatencyInfo::LatencyComponent> new_components_value;
220 for (const auto& lc : latency->latency_components()) { 343 for (const auto& lc : latency->latency_components()) {
221 ui::LatencyComponentType component_type = lc.first.first; 344 ui::LatencyComponentType component_type = lc.first.first;
222 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { 345 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 for (LatencyInfo& latency : *latencies) { 671 for (LatencyInfo& latency : *latencies) {
549 AddLatencyInfoComponentIds(&latency, latency_component_id_); 672 AddLatencyInfoComponentIds(&latency, latency_component_id_);
550 latency.AddLatencyNumber( 673 latency.AddLatencyNumber(
551 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); 674 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0);
552 } 675 }
553 } 676 }
554 677
555 void RenderWidgetHostLatencyTracker::OnFrameSwapped( 678 void RenderWidgetHostLatencyTracker::OnFrameSwapped(
556 const LatencyInfo& latency, 679 const LatencyInfo& latency,
557 bool is_running_navigation_hint_task) { 680 bool is_running_navigation_hint_task) {
558 // Don't report frame latency on wheel events. Previously they were only
559 // reported on touch metrics and we need to be consistent across reporting
560 // metrics.
561 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
562 if (latency.FindLatency(
563 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
564 &mouse_wheel_scroll_update_component)) {
565 return;
566 }
567 681
568 LatencyInfo::LatencyComponent gpu_swap_end_component; 682 LatencyInfo::LatencyComponent gpu_swap_end_component;
569 if (!latency.FindLatency( 683 if (!latency.FindLatency(
570 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 684 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0,
571 &gpu_swap_end_component)) { 685 &gpu_swap_end_component)) {
572 return; 686 return;
573 } 687 }
574 688
575 LatencyInfo::LatencyComponent gpu_swap_begin_component; 689 LatencyInfo::LatencyComponent gpu_swap_begin_component;
576 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 690 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
577 &gpu_swap_begin_component)) { 691 &gpu_swap_begin_component)) {
578 return; 692 return;
579 } 693 }
580 694
581 LatencyInfo::LatencyComponent tab_switch_component; 695 LatencyInfo::LatencyComponent tab_switch_component;
582 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, 696 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_,
583 &tab_switch_component)) { 697 &tab_switch_component)) {
584 base::TimeDelta delta = 698 base::TimeDelta delta =
585 gpu_swap_end_component.event_time - tab_switch_component.event_time; 699 gpu_swap_end_component.event_time - tab_switch_component.event_time;
586 for (size_t i = 0; i < tab_switch_component.event_count; i++) { 700 for (size_t i = 0; i < tab_switch_component.event_count; i++) {
587 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); 701 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta);
588 } 702 }
589 } 703 }
590 704
591 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 705 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
592 latency_component_id_, nullptr)) { 706 latency_component_id_, nullptr)) {
593 return; 707 return;
594 } 708 }
595 709
596 ComputeScrollLatencyHistograms(gpu_swap_begin_component, 710 // Compute the old scroll update latency metrics. They are exclusively
597 gpu_swap_end_component, latency_component_id_, 711 // calculated for touch scrolls, and will be deprecated on M56.
598 latency, is_running_navigation_hint_task); 712 // (https://crbug.com/649754)
713 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
714 if (!latency.FindLatency(
715 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
716 &mouse_wheel_scroll_update_component)) {
717 ComputeScrollLatencyHistograms(
718 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
719 latency, is_running_navigation_hint_task);
720 }
tdresser 2016/09/30 17:16:38 Let's move the deprecated metrics after the more c
sahel 2016/10/04 14:22:26 Done.
721
722 ui::SourceEventType source_event_type = latency.source_event_type();
723 if (source_event_type != ui::SourceEventType::WHEEL &&
724 source_event_type != ui::SourceEventType::TOUCH) {
725 return;
726 }
727
728 ComputeTouchAndWheelScrollLatencyHistograms(
729 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
730 latency,
731 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch");
599 } 732 }
600 733
601 } // namespace content 734 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698