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

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: use of getFactory to recompute the histogram names. Created 4 years, 2 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 base::Histogram::FactoryGet(name, 1, 1000000, 100, \
105 base::HistogramBase::kUmaTargetedHistogramFlag) \
106 ->Add((end.last_event_time - start.first_event_time).InMicroseconds());
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 base::Histogram::FactoryGet(name, 1000, 200000, 50, \
112 base::HistogramBase::kUmaTargetedHistogramFlag) \
113 ->Add((end.last_event_time - start.first_event_time).InMicroseconds());
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 base::Histogram::FactoryGet(name, 1, 50000, 50, \
119 base::HistogramBase::kUmaTargetedHistogramFlag) \
120 ->Add((end.last_event_time - start.first_event_time).InMicroseconds());
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.
266 // First scroll events are excluded from this metric.
267 if (event_type_name == "Touch") {
268 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
269 "Event.Latency." + event_type_name + ".TimeToScrollUpdateSwapBegin2",
270 original_component, gpu_swap_begin_component);
271 }
272 } else {
273 // No original component found.
274 return;
275 }
276
277 LatencyInfo::LatencyComponent rendering_scheduled_component;
278 bool rendering_scheduled_on_main = latency.FindLatency(
279 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
280 &rendering_scheduled_component);
281 if (!rendering_scheduled_on_main) {
282 if (!latency.FindLatency(
283 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0,
284 &rendering_scheduled_component))
285 return;
286 }
287
288 if (rendering_scheduled_on_main) {
289 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
290 "Event.Latency.ScrollUpdate." + event_type_name +
291 ".TimeToHandled2_Main",
Steven Holte 2016/10/04 22:43:40 Optional: since you are computing these names anyw
292 original_component, rendering_scheduled_component);
293 } else {
294 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
295 "Event.Latency.ScrollUpdate." + event_type_name +
296 ".TimeToHandled2_Impl",
297 original_component, rendering_scheduled_component);
298 }
299
300 LatencyInfo::LatencyComponent renderer_swap_component;
301 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0,
302 &renderer_swap_component))
303 return;
304
305 if (rendering_scheduled_on_main) {
306 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
307 "Event.Latency.ScrollUpdate." + event_type_name +
308 ".HandledToRendererSwap2_Main",
309 rendering_scheduled_component, renderer_swap_component);
310 } else {
311 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
312 "Event.Latency.ScrollUpdate." + event_type_name +
313 ".HandledToRendererSwap2_Impl",
314 rendering_scheduled_component, renderer_swap_component);
315 }
316
317 LatencyInfo::LatencyComponent browser_received_swap_component;
318 if (!latency.FindLatency(
319 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0,
320 &browser_received_swap_component))
321 return;
322
323 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
324 "Event.Latency.ScrollUpdate." + event_type_name +
325 ".RendererSwapToBrowserNotified2",
326 renderer_swap_component, browser_received_swap_component);
327
328 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
329 "Event.Latency.ScrollUpdate." + event_type_name +
330 ".BrowserNotifiedToBeforeGpuSwap2",
331 browser_received_swap_component, gpu_swap_begin_component);
332
333 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
334 "Event.Latency.ScrollUpdate." + event_type_name + ".GpuSwap2",
335 gpu_swap_begin_component, gpu_swap_end_component);
336 }
213 // LatencyComponents generated in the renderer must have component IDs 337 // LatencyComponents generated in the renderer must have component IDs
214 // provided to them by the browser process. This function adds the correct 338 // provided to them by the browser process. This function adds the correct
215 // component ID where necessary. 339 // component ID where necessary.
216 void AddLatencyInfoComponentIds(LatencyInfo* latency, 340 void AddLatencyInfoComponentIds(LatencyInfo* latency,
217 int64_t latency_component_id) { 341 int64_t latency_component_id) {
218 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; 342 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key;
219 std::vector<LatencyInfo::LatencyComponent> new_components_value; 343 std::vector<LatencyInfo::LatencyComponent> new_components_value;
220 for (const auto& lc : latency->latency_components()) { 344 for (const auto& lc : latency->latency_components()) {
221 ui::LatencyComponentType component_type = lc.first.first; 345 ui::LatencyComponentType component_type = lc.first.first;
222 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { 346 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) { 672 for (LatencyInfo& latency : *latencies) {
549 AddLatencyInfoComponentIds(&latency, latency_component_id_); 673 AddLatencyInfoComponentIds(&latency, latency_component_id_);
550 latency.AddLatencyNumber( 674 latency.AddLatencyNumber(
551 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); 675 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0);
552 } 676 }
553 } 677 }
554 678
555 void RenderWidgetHostLatencyTracker::OnFrameSwapped( 679 void RenderWidgetHostLatencyTracker::OnFrameSwapped(
556 const LatencyInfo& latency, 680 const LatencyInfo& latency,
557 bool is_running_navigation_hint_task) { 681 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 682
568 LatencyInfo::LatencyComponent gpu_swap_end_component; 683 LatencyInfo::LatencyComponent gpu_swap_end_component;
569 if (!latency.FindLatency( 684 if (!latency.FindLatency(
570 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 685 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0,
571 &gpu_swap_end_component)) { 686 &gpu_swap_end_component)) {
572 return; 687 return;
573 } 688 }
574 689
575 LatencyInfo::LatencyComponent gpu_swap_begin_component; 690 LatencyInfo::LatencyComponent gpu_swap_begin_component;
576 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 691 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
577 &gpu_swap_begin_component)) { 692 &gpu_swap_begin_component)) {
578 return; 693 return;
579 } 694 }
580 695
581 LatencyInfo::LatencyComponent tab_switch_component; 696 LatencyInfo::LatencyComponent tab_switch_component;
582 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, 697 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_,
583 &tab_switch_component)) { 698 &tab_switch_component)) {
584 base::TimeDelta delta = 699 base::TimeDelta delta =
585 gpu_swap_end_component.event_time - tab_switch_component.event_time; 700 gpu_swap_end_component.event_time - tab_switch_component.event_time;
586 for (size_t i = 0; i < tab_switch_component.event_count; i++) { 701 for (size_t i = 0; i < tab_switch_component.event_count; i++) {
587 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); 702 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta);
588 } 703 }
589 } 704 }
590 705
591 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 706 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
592 latency_component_id_, nullptr)) { 707 latency_component_id_, nullptr)) {
593 return; 708 return;
594 } 709 }
595 710
596 ComputeScrollLatencyHistograms(gpu_swap_begin_component, 711 ui::SourceEventType source_event_type = latency.source_event_type();
597 gpu_swap_end_component, latency_component_id_, 712 if (source_event_type == ui::SourceEventType::WHEEL ||
598 latency, is_running_navigation_hint_task); 713 source_event_type == ui::SourceEventType::TOUCH) {
714 ComputeTouchAndWheelScrollLatencyHistograms(
715 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
716 latency,
717 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch");
718 }
719
720 // Compute the old scroll update latency metrics. They are exclusively
721 // calculated for touch scrolls, and will be deprecated on M56.
722 // (https://crbug.com/649754)
723 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
724 if (!latency.FindLatency(
725 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
726 &mouse_wheel_scroll_update_component)) {
727 ComputeScrollLatencyHistograms(
728 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
729 latency, is_running_navigation_hint_task);
730 }
599 } 731 }
600 732
601 } // namespace content 733 } // 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