Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 void ComputeFirstScrollLatencyHistograms( | |
| 96 const LatencyInfo::LatencyComponent& original_component, | |
| 97 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, | |
| 98 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | |
| 99 const LatencyInfo& latency, | |
| 100 bool is_running_navigation_hint_task) { | |
| 101 // This UMA metric tracks the time between the final frame swap for the | |
| 102 // first scroll event in a sequence and the original timestamp of that | |
| 103 // scroll event's underlying touch event. | |
| 104 for (size_t i = 0; i < original_component.event_count; i++) { | |
| 105 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
| 106 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", original_component, | |
| 107 gpu_swap_begin_component); | |
| 108 } | |
| 109 // TODO(horo): IsRunningNavigationHintTask UMAs are only for | |
| 110 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when | |
| 111 // the experimentation finished (crbug.com/638827). | |
| 112 if (is_running_navigation_hint_task) { | |
| 113 for (size_t i = 0; i < original_component.event_count; i++) { | |
| 114 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
| 115 "Event.Latency.TouchToFirstScrollUpdateSwapBegin_" | |
| 116 "IsRunningNavigationHintTask", | |
| 117 original_component, gpu_swap_begin_component); | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 LatencyInfo::LatencyComponent rendering_scheduled_component; | |
| 122 bool rendering_scheduled_on_main = latency.FindLatency( | |
| 123 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, | |
| 124 &rendering_scheduled_component); | |
| 125 | |
| 126 if (!rendering_scheduled_on_main) { | |
| 127 if (!latency.FindLatency( | |
| 128 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, | |
| 129 &rendering_scheduled_component)) { | |
| 130 return; | |
| 131 } | |
| 132 } | |
| 133 | |
| 134 if (rendering_scheduled_on_main) { | |
| 135 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 136 "Event.Latency.FirstScrollUpdate.FirstTouchToHandled_Main", | |
| 137 original_component, rendering_scheduled_component); | |
| 138 } else { | |
| 139 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 140 "Event.Latency.FirstScrollUpdate.FirstTouchToHandled_Impl", | |
| 141 original_component, rendering_scheduled_component); | |
| 142 } | |
| 143 | |
| 144 LatencyInfo::LatencyComponent renderer_swap_component; | |
| 145 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, | |
| 146 &renderer_swap_component)) { | |
| 147 return; | |
| 148 } | |
| 149 | |
| 150 if (rendering_scheduled_on_main) { | |
| 151 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 152 "Event.Latency.FirstScrollUpdate.HandledToRendererSwap_Main", | |
| 153 rendering_scheduled_component, renderer_swap_component); | |
| 154 } else { | |
| 155 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 156 "Event.Latency.FirstScrollUpdate.HandledToRendererSwap_Impl", | |
| 157 rendering_scheduled_component, renderer_swap_component); | |
| 158 } | |
| 159 | |
| 160 LatencyInfo::LatencyComponent browser_received_swap_component; | |
| 161 if (!latency.FindLatency( | |
| 162 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, | |
| 163 &browser_received_swap_component)) { | |
| 164 return; | |
| 165 } | |
| 166 | |
| 167 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | |
| 168 "Event.Latency.FirstScrollUpdate.RendererSwapToBrowserNotified", | |
| 169 renderer_swap_component, browser_received_swap_component); | |
| 170 | |
| 171 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 172 "Event.Latency.FirstScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | |
| 173 browser_received_swap_component, gpu_swap_begin_component); | |
| 174 | |
| 175 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.FirstScrollUpdate.GpuSwap", | |
| 176 gpu_swap_begin_component, | |
| 177 gpu_swap_end_component); | |
| 178 } | |
| 179 | |
| 95 void ComputeScrollLatencyHistograms( | 180 void ComputeScrollLatencyHistograms( |
| 96 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, | 181 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| 97 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | 182 const LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| 98 int64_t latency_component_id, | 183 int64_t latency_component_id, |
| 99 const LatencyInfo& latency, | 184 const LatencyInfo& latency, |
| 100 bool is_running_navigation_hint_task) { | 185 bool is_running_navigation_hint_task) { |
| 101 DCHECK(!latency.coalesced()); | 186 DCHECK(!latency.coalesced()); |
| 102 if (latency.coalesced()) | 187 if (latency.coalesced()) |
| 103 return; | 188 return; |
| 104 | 189 |
| 105 DCHECK(!gpu_swap_begin_component.event_time.is_null()); | 190 DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
| 106 DCHECK(!gpu_swap_end_component.event_time.is_null()); | 191 DCHECK(!gpu_swap_end_component.event_time.is_null()); |
| 107 LatencyInfo::LatencyComponent original_component; | 192 LatencyInfo::LatencyComponent original_component; |
| 108 if (latency.FindLatency( | 193 if (latency.FindLatency( |
| 109 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 194 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 110 latency_component_id, &original_component)) { | 195 latency_component_id, &original_component)) { |
| 111 // This UMA metric tracks the time between the final frame swap for the | 196 ComputeFirstScrollLatencyHistograms( |
|
tdresser
2016/08/24 12:48:57
Could we start by checking if this is the first sc
tdresser
2016/08/24 12:51:39
We'll end up having to look up some components mor
lanwei
2016/08/25 04:17:11
I tried several ways, but none of them works, bec
tdresser
2016/08/25 13:31:05
Hmmm, we want something like:
https://cs.chromium
| |
| 112 // first scroll event in a sequence and the original timestamp of that | 197 original_component, gpu_swap_begin_component, gpu_swap_end_component, |
| 113 // scroll event's underlying touch event. | 198 latency, is_running_navigation_hint_task); |
| 114 for (size_t i = 0; i < original_component.event_count; i++) { | |
| 115 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
| 116 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", | |
| 117 original_component, gpu_swap_begin_component); | |
| 118 } | |
| 119 // TODO(horo): IsRunningNavigationHintTask UMAs are only for | |
| 120 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when | |
| 121 // the experimentation finished (crbug.com/638827). | |
| 122 if (is_running_navigation_hint_task) { | |
| 123 for (size_t i = 0; i < original_component.event_count; i++) { | |
| 124 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
| 125 "Event.Latency.TouchToFirstScrollUpdateSwapBegin_" | |
| 126 "IsRunningNavigationHintTask", | |
| 127 original_component, gpu_swap_begin_component); | |
| 128 } | |
| 129 } | |
| 130 } else if (!latency.FindLatency( | 199 } else if (!latency.FindLatency( |
| 131 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 200 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 132 latency_component_id, &original_component)) { | 201 latency_component_id, &original_component)) { |
| 133 return; | 202 return; |
| 134 } | 203 } |
| 135 | 204 |
| 136 // This UMA metric tracks the time from when the original touch event is | 205 // This UMA metric tracks the time from when the original touch event is |
| 137 // created to when the scroll gesture results in final frame swap. | 206 // created to when the scroll gesture results in final frame swap. |
| 138 for (size_t i = 0; i < original_component.event_count; i++) { | 207 for (size_t i = 0; i < original_component.event_count; i++) { |
| 139 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 208 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| 140 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, | 209 "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, |
| 141 gpu_swap_begin_component); | 210 gpu_swap_begin_component); |
| 142 } | 211 } |
| 143 // TODO(horo): IsRunningNavigationHintTask UMAs are only for | 212 // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| 144 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when | 213 // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| 145 // the experimentation finished (crbug.com/638827). | 214 // the experimentation finished (crbug.com/638827). |
| 146 if (is_running_navigation_hint_task) { | 215 if (is_running_navigation_hint_task) { |
| 147 for (size_t i = 0; i < original_component.event_count; i++) { | 216 for (size_t i = 0; i < original_component.event_count; i++) { |
| 148 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | 217 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| 149 "Event.Latency.TouchToScrollUpdateSwapBegin_" | 218 "Event.Latency.TouchToScrollUpdateSwapBegin_" |
| 150 "IsRunningNavigationHintTask", | 219 "IsRunningNavigationHintTask", |
| 151 original_component, gpu_swap_begin_component); | 220 original_component, gpu_swap_begin_component); |
| 152 } | 221 } |
| 153 } | 222 } |
| 154 | 223 |
| 155 // TODO(miletus): Add validation for making sure the following components | |
| 156 // are present and their event times are legit. | |
| 157 LatencyInfo::LatencyComponent rendering_scheduled_component; | 224 LatencyInfo::LatencyComponent rendering_scheduled_component; |
| 158 bool rendering_scheduled_on_main = latency.FindLatency( | 225 bool rendering_scheduled_on_main = latency.FindLatency( |
| 159 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | 226 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
| 160 0, &rendering_scheduled_component); | 227 0, &rendering_scheduled_component); |
| 161 | |
| 162 if (!rendering_scheduled_on_main) { | 228 if (!rendering_scheduled_on_main) { |
| 163 if (!latency.FindLatency( | 229 if (!latency.FindLatency( |
| 164 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, | 230 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, |
| 165 0, &rendering_scheduled_component)) | 231 &rendering_scheduled_component)) { |
|
tdresser
2016/08/24 12:48:57
Are these changes needed?
lanwei
2016/08/25 04:17:11
I remembered you told me that if the statement has
tdresser
2016/08/25 13:31:05
Er, nope, I prefer this, sorry.
| |
| 166 return; | 232 return; |
| 233 } | |
| 167 } | 234 } |
| 168 | 235 |
| 169 if (rendering_scheduled_on_main) { | 236 if (rendering_scheduled_on_main) { |
| 170 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 237 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 171 "Event.Latency.ScrollUpdate.TouchToHandled_Main", | 238 "Event.Latency.ScrollUpdate.TouchToHandled_Main", |
| 172 original_component, rendering_scheduled_component); | 239 original_component, rendering_scheduled_component); |
| 173 } else { | 240 } else { |
| 174 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 241 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 175 "Event.Latency.ScrollUpdate.TouchToHandled_Impl", | 242 "Event.Latency.ScrollUpdate.TouchToHandled_Impl", |
| 176 original_component, rendering_scheduled_component); | 243 original_component, rendering_scheduled_component); |
| 177 } | 244 } |
| 178 | 245 |
| 179 LatencyInfo::LatencyComponent renderer_swap_component; | 246 LatencyInfo::LatencyComponent renderer_swap_component; |
| 180 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | 247 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, |
| 181 0, &renderer_swap_component)) | 248 &renderer_swap_component)) { |
| 182 return; | 249 return; |
| 250 } | |
| 183 | 251 |
| 184 if (rendering_scheduled_on_main) { | 252 if (rendering_scheduled_on_main) { |
| 185 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 253 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 186 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", | 254 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", |
| 187 rendering_scheduled_component, renderer_swap_component); | 255 rendering_scheduled_component, renderer_swap_component); |
| 188 } else { | 256 } else { |
| 189 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 257 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 190 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", | 258 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", |
| 191 rendering_scheduled_component, renderer_swap_component); | 259 rendering_scheduled_component, renderer_swap_component); |
| 192 } | 260 } |
| 193 | 261 |
| 194 LatencyInfo::LatencyComponent browser_received_swap_component; | 262 LatencyInfo::LatencyComponent browser_received_swap_component; |
| 195 if (!latency.FindLatency( | 263 if (!latency.FindLatency( |
| 196 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, | 264 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
| 197 0, &browser_received_swap_component)) | 265 &browser_received_swap_component)) { |
| 198 return; | 266 return; |
| 267 } | |
| 199 | 268 |
| 200 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | 269 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
| 201 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", | 270 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", |
| 202 renderer_swap_component, browser_received_swap_component); | 271 renderer_swap_component, browser_received_swap_component); |
| 203 | 272 |
| 204 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 273 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 205 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | 274 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
| 206 browser_received_swap_component, gpu_swap_begin_component); | 275 browser_received_swap_component, gpu_swap_begin_component); |
| 207 | 276 |
| 208 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | 277 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 latency_component_id_, nullptr)) { | 662 latency_component_id_, nullptr)) { |
| 594 return; | 663 return; |
| 595 } | 664 } |
| 596 | 665 |
| 597 ComputeScrollLatencyHistograms(gpu_swap_begin_component, | 666 ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
| 598 gpu_swap_end_component, latency_component_id_, | 667 gpu_swap_end_component, latency_component_id_, |
| 599 latency, is_running_navigation_hint_task); | 668 latency, is_running_navigation_hint_task); |
| 600 } | 669 } |
| 601 | 670 |
| 602 } // namespace content | 671 } // namespace content |
| OLD | NEW |