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

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: 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 + ".ToFirstScrollUpdateSwapBegin",
259 original_component, gpu_swap_begin_component);
260 } else if (!latency.FindLatency(
261 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
262 latency_component_id, &original_component)) {
263 return;
264 }
265
266 // This UMA metric tracks the time from when the original touch event is
267 // created to when the scroll gesture results in final frame swap.
268 if (event_type_name == "Touch") {
269 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
270 "Event.Latency." + event_type_name + ".ToScrollUpdateSwapBegin",
tdresser 2016/09/23 14:28:38 We want to exclude the first GSU from this metric.
sahel 2016/09/23 20:48:23 Done.
271 original_component, gpu_swap_begin_component);
272 }
273 LatencyInfo::LatencyComponent rendering_scheduled_component;
274 bool rendering_scheduled_on_main = latency.FindLatency(
275 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
276 &rendering_scheduled_component);
277 if (!rendering_scheduled_on_main) {
278 if (!latency.FindLatency(
279 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0,
280 &rendering_scheduled_component))
281 return;
282 }
283
284 if (rendering_scheduled_on_main) {
285 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
286 "Event.Latency.ScrollUpdate." + event_type_name + ".ToHandled_Main",
287 original_component, rendering_scheduled_component);
288 } else {
289 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
290 "Event.Latency.ScrollUpdate." + event_type_name + ".ToHandled_Impl",
291 original_component, rendering_scheduled_component);
292 }
293
294 LatencyInfo::LatencyComponent renderer_swap_component;
295 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0,
296 &renderer_swap_component))
297 return;
298
299 if (rendering_scheduled_on_main) {
300 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
301 "Event.Latency.ScrollUpdate." + event_type_name +
302 ".HandledToRendererSwap_Main",
303 rendering_scheduled_component, renderer_swap_component);
304 } else {
305 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
306 "Event.Latency.ScrollUpdate." + event_type_name +
307 ".HandledToRendererSwap_Impl",
308 rendering_scheduled_component, renderer_swap_component);
309 }
310
311 LatencyInfo::LatencyComponent browser_received_swap_component;
312 if (!latency.FindLatency(
313 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0,
314 &browser_received_swap_component))
315 return;
316
317 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
318 "Event.Latency.ScrollUpdate." + event_type_name +
319 ".RendererSwapToBrowserNotified",
320 renderer_swap_component, browser_received_swap_component);
321
322 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
323 "Event.Latency.ScrollUpdate." + event_type_name +
324 ".BrowserNotifiedToBeforeGpuSwap",
325 browser_received_swap_component, gpu_swap_begin_component);
326
327 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
328 "Event.Latency.ScrollUpdate." + event_type_name + ".GpuSwap",
329 gpu_swap_begin_component, gpu_swap_end_component);
330 }
331
213 // LatencyComponents generated in the renderer must have component IDs 332 // LatencyComponents generated in the renderer must have component IDs
214 // provided to them by the browser process. This function adds the correct 333 // provided to them by the browser process. This function adds the correct
215 // component ID where necessary. 334 // component ID where necessary.
216 void AddLatencyInfoComponentIds(LatencyInfo* latency, 335 void AddLatencyInfoComponentIds(LatencyInfo* latency,
217 int64_t latency_component_id) { 336 int64_t latency_component_id) {
218 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; 337 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key;
219 std::vector<LatencyInfo::LatencyComponent> new_components_value; 338 std::vector<LatencyInfo::LatencyComponent> new_components_value;
220 for (const auto& lc : latency->latency_components()) { 339 for (const auto& lc : latency->latency_components()) {
221 ui::LatencyComponentType component_type = lc.first.first; 340 ui::LatencyComponentType component_type = lc.first.first;
222 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { 341 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) { 667 for (LatencyInfo& latency : *latencies) {
549 AddLatencyInfoComponentIds(&latency, latency_component_id_); 668 AddLatencyInfoComponentIds(&latency, latency_component_id_);
550 latency.AddLatencyNumber( 669 latency.AddLatencyNumber(
551 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); 670 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0);
552 } 671 }
553 } 672 }
554 673
555 void RenderWidgetHostLatencyTracker::OnFrameSwapped( 674 void RenderWidgetHostLatencyTracker::OnFrameSwapped(
556 const LatencyInfo& latency, 675 const LatencyInfo& latency,
557 bool is_running_navigation_hint_task) { 676 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 677
568 LatencyInfo::LatencyComponent gpu_swap_end_component; 678 LatencyInfo::LatencyComponent gpu_swap_end_component;
569 if (!latency.FindLatency( 679 if (!latency.FindLatency(
570 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 680 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0,
571 &gpu_swap_end_component)) { 681 &gpu_swap_end_component)) {
572 return; 682 return;
573 } 683 }
574 684
575 LatencyInfo::LatencyComponent gpu_swap_begin_component; 685 LatencyInfo::LatencyComponent gpu_swap_begin_component;
576 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 686 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
577 &gpu_swap_begin_component)) { 687 &gpu_swap_begin_component)) {
578 return; 688 return;
579 } 689 }
580 690
581 LatencyInfo::LatencyComponent tab_switch_component; 691 LatencyInfo::LatencyComponent tab_switch_component;
582 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, 692 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_,
583 &tab_switch_component)) { 693 &tab_switch_component)) {
584 base::TimeDelta delta = 694 base::TimeDelta delta =
585 gpu_swap_end_component.event_time - tab_switch_component.event_time; 695 gpu_swap_end_component.event_time - tab_switch_component.event_time;
586 for (size_t i = 0; i < tab_switch_component.event_count; i++) { 696 for (size_t i = 0; i < tab_switch_component.event_count; i++) {
587 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); 697 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta);
588 } 698 }
589 } 699 }
590 700
591 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 701 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
592 latency_component_id_, nullptr)) { 702 latency_component_id_, nullptr)) {
593 return; 703 return;
594 } 704 }
595 705
596 ComputeScrollLatencyHistograms(gpu_swap_begin_component, 706 // Don't report frame latency on wheel events. Previously they were only
597 gpu_swap_end_component, latency_component_id_, 707 // reported on touch metrics and we need to be consistent across reporting
598 latency, is_running_navigation_hint_task); 708 // metrics.
tdresser 2016/09/23 14:28:38 We should update this comment, as we are now repor
sahel 2016/09/23 20:48:23 Done.
709 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
710 if (!latency.FindLatency(
711 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
712 &mouse_wheel_scroll_update_component)) {
713 ComputeScrollLatencyHistograms(
tdresser 2016/09/23 14:28:38 Might be worth mentioning in a comment here that w
sahel 2016/09/23 20:48:23 Done.
714 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
715 latency, is_running_navigation_hint_task);
716 }
717
718 ui::SourceEventType source_event_type = latency.source_event_type();
719 if (source_event_type != ui::SourceEventType::WHEEL &&
720 source_event_type != ui::SourceEventType::TOUCH) {
721 return;
722 }
723
724 ComputeTouchAndWheelScrollLatencyHistograms(
725 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
726 latency,
727 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch");
599 } 728 }
600 729
601 } // namespace content 730 } // 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