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

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 thread_name to compute _MAin, _Impl only once. 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 const std::string thread_name = rendering_scheduled_on_main ? "Main" : "Impl";
289
290 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
291 "Event.Latency.ScrollUpdate." + event_type_name +
292 ".TimeToHandled2_" + thread_name,
293 original_component, rendering_scheduled_component);
294
295 LatencyInfo::LatencyComponent renderer_swap_component;
296 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0,
297 &renderer_swap_component))
298 return;
299
300 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
301 "Event.Latency.ScrollUpdate." + event_type_name +
302 ".HandledToRendererSwap2_" + thread_name,
303 rendering_scheduled_component, renderer_swap_component);
304
305 LatencyInfo::LatencyComponent browser_received_swap_component;
306 if (!latency.FindLatency(
307 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0,
308 &browser_received_swap_component))
309 return;
310
311 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
312 "Event.Latency.ScrollUpdate." + event_type_name +
313 ".RendererSwapToBrowserNotified2",
314 renderer_swap_component, browser_received_swap_component);
315
316 UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(
317 "Event.Latency.ScrollUpdate." + event_type_name +
318 ".BrowserNotifiedToBeforeGpuSwap2",
319 browser_received_swap_component, gpu_swap_begin_component);
320
321 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
322 "Event.Latency.ScrollUpdate." + event_type_name + ".GpuSwap2",
323 gpu_swap_begin_component, gpu_swap_end_component);
324 }
213 // LatencyComponents generated in the renderer must have component IDs 325 // LatencyComponents generated in the renderer must have component IDs
214 // provided to them by the browser process. This function adds the correct 326 // provided to them by the browser process. This function adds the correct
215 // component ID where necessary. 327 // component ID where necessary.
216 void AddLatencyInfoComponentIds(LatencyInfo* latency, 328 void AddLatencyInfoComponentIds(LatencyInfo* latency,
217 int64_t latency_component_id) { 329 int64_t latency_component_id) {
218 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key; 330 std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key;
219 std::vector<LatencyInfo::LatencyComponent> new_components_value; 331 std::vector<LatencyInfo::LatencyComponent> new_components_value;
220 for (const auto& lc : latency->latency_components()) { 332 for (const auto& lc : latency->latency_components()) {
221 ui::LatencyComponentType component_type = lc.first.first; 333 ui::LatencyComponentType component_type = lc.first.first;
222 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { 334 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) { 660 for (LatencyInfo& latency : *latencies) {
549 AddLatencyInfoComponentIds(&latency, latency_component_id_); 661 AddLatencyInfoComponentIds(&latency, latency_component_id_);
550 latency.AddLatencyNumber( 662 latency.AddLatencyNumber(
551 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); 663 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0);
552 } 664 }
553 } 665 }
554 666
555 void RenderWidgetHostLatencyTracker::OnFrameSwapped( 667 void RenderWidgetHostLatencyTracker::OnFrameSwapped(
556 const LatencyInfo& latency, 668 const LatencyInfo& latency,
557 bool is_running_navigation_hint_task) { 669 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 670
568 LatencyInfo::LatencyComponent gpu_swap_end_component; 671 LatencyInfo::LatencyComponent gpu_swap_end_component;
569 if (!latency.FindLatency( 672 if (!latency.FindLatency(
570 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 673 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0,
571 &gpu_swap_end_component)) { 674 &gpu_swap_end_component)) {
572 return; 675 return;
573 } 676 }
574 677
575 LatencyInfo::LatencyComponent gpu_swap_begin_component; 678 LatencyInfo::LatencyComponent gpu_swap_begin_component;
576 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 679 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0,
577 &gpu_swap_begin_component)) { 680 &gpu_swap_begin_component)) {
578 return; 681 return;
579 } 682 }
580 683
581 LatencyInfo::LatencyComponent tab_switch_component; 684 LatencyInfo::LatencyComponent tab_switch_component;
582 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, 685 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_,
583 &tab_switch_component)) { 686 &tab_switch_component)) {
584 base::TimeDelta delta = 687 base::TimeDelta delta =
585 gpu_swap_end_component.event_time - tab_switch_component.event_time; 688 gpu_swap_end_component.event_time - tab_switch_component.event_time;
586 for (size_t i = 0; i < tab_switch_component.event_count; i++) { 689 for (size_t i = 0; i < tab_switch_component.event_count; i++) {
587 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); 690 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta);
588 } 691 }
589 } 692 }
590 693
591 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 694 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
592 latency_component_id_, nullptr)) { 695 latency_component_id_, nullptr)) {
593 return; 696 return;
594 } 697 }
595 698
596 ComputeScrollLatencyHistograms(gpu_swap_begin_component, 699 ui::SourceEventType source_event_type = latency.source_event_type();
597 gpu_swap_end_component, latency_component_id_, 700 if (source_event_type == ui::SourceEventType::WHEEL ||
598 latency, is_running_navigation_hint_task); 701 source_event_type == ui::SourceEventType::TOUCH) {
702 ComputeTouchAndWheelScrollLatencyHistograms(
703 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
704 latency,
705 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch");
706 }
707
708 // Compute the old scroll update latency metrics. They are exclusively
709 // calculated for touch scrolls, and will be deprecated on M56.
710 // (https://crbug.com/649754)
711 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
712 if (!latency.FindLatency(
713 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
714 &mouse_wheel_scroll_update_component)) {
715 ComputeScrollLatencyHistograms(
716 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
717 latency, is_running_navigation_hint_task);
718 }
599 } 719 }
600 720
601 } // namespace content 721 } // 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