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/render_widget_host_latency_tracker.h" | 5 #include "content/browser/renderer_host/render_widget_host_latency_tracker.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 "Event.Latency.Browser.TouchAcked", | 128 "Event.Latency.Browser.TouchAcked", |
129 acked_delta.InMicroseconds(), 1, 1000000, 100); | 129 acked_delta.InMicroseconds(), 1, 1000000, 100); |
130 break; | 130 break; |
131 default: | 131 default: |
132 NOTREACHED(); | 132 NOTREACHED(); |
133 break; | 133 break; |
134 } | 134 } |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
| 138 // Long scroll latency component that is mostly under 200ms. |
| 139 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ |
| 140 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 141 name, \ |
| 142 (end.event_time - start.event_time).InMicroseconds(), \ |
| 143 1000, 200000, 50) |
| 144 |
| 145 // Short scroll latency component that is mostly under 50ms. |
| 146 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ |
| 147 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 148 name, \ |
| 149 (end.event_time - start.event_time).InMicroseconds(), \ |
| 150 1, 50000, 50) |
| 151 |
138 void ComputeScrollLatencyHistograms( | 152 void ComputeScrollLatencyHistograms( |
139 const LatencyInfo::LatencyComponent& swap_component, | 153 const LatencyInfo::LatencyComponent& swap_component, |
140 int64 latency_component_id, | 154 int64 latency_component_id, |
141 const ui::LatencyInfo& latency) { | 155 const ui::LatencyInfo& latency) { |
142 DCHECK(!swap_component.event_time.is_null()); | 156 DCHECK(!swap_component.event_time.is_null()); |
143 LatencyInfo::LatencyComponent first_original_component, original_component; | 157 LatencyInfo::LatencyComponent first_original_component, original_component; |
144 if (latency.FindLatency( | 158 if (latency.FindLatency( |
145 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 159 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
146 latency_component_id, &first_original_component)) { | 160 latency_component_id, &first_original_component)) { |
147 // This UMA metric tracks the time between the final frame swap for the | 161 // This UMA metric tracks the time between the final frame swap for the |
(...skipping 16 matching lines...) Expand all Loading... |
164 // This UMA metric tracks the time from when the original touch event is | 178 // This UMA metric tracks the time from when the original touch event is |
165 // created (averaged if there are multiple) to when the scroll gesture | 179 // created (averaged if there are multiple) to when the scroll gesture |
166 // results in final frame swap. | 180 // results in final frame swap. |
167 for (size_t i = 0; i < original_component.event_count; i++) { | 181 for (size_t i = 0; i < original_component.event_count; i++) { |
168 UMA_HISTOGRAM_CUSTOM_COUNTS( | 182 UMA_HISTOGRAM_CUSTOM_COUNTS( |
169 "Event.Latency.TouchToScrollUpdateSwap", | 183 "Event.Latency.TouchToScrollUpdateSwap", |
170 (swap_component.event_time - original_component.event_time) | 184 (swap_component.event_time - original_component.event_time) |
171 .InMicroseconds(), | 185 .InMicroseconds(), |
172 1, 1000000, 100); | 186 1, 1000000, 100); |
173 } | 187 } |
| 188 |
| 189 // TODO(miletus): Add validation for making sure the following components |
| 190 // are present and their event times are legit. |
| 191 LatencyInfo::LatencyComponent rendering_scheduled_component; |
| 192 bool rendering_scheduled_on_main = latency.FindLatency( |
| 193 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
| 194 0, &rendering_scheduled_component); |
| 195 |
| 196 if (!rendering_scheduled_on_main) { |
| 197 if (!latency.FindLatency( |
| 198 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, |
| 199 0, &rendering_scheduled_component)) |
| 200 return; |
| 201 } |
| 202 |
| 203 if (rendering_scheduled_on_main) { |
| 204 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 205 "Event.Latency.ScrollUpdate.TouchToHandled_Main", |
| 206 original_component, rendering_scheduled_component); |
| 207 } else { |
| 208 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 209 "Event.Latency.ScrollUpdate.TouchToHandled_Impl", |
| 210 original_component, rendering_scheduled_component); |
| 211 } |
| 212 |
| 213 LatencyInfo::LatencyComponent renderer_swap_component; |
| 214 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
| 215 0, &renderer_swap_component)) |
| 216 return; |
| 217 |
| 218 if (rendering_scheduled_on_main) { |
| 219 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 220 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", |
| 221 rendering_scheduled_component, renderer_swap_component); |
| 222 } else { |
| 223 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 224 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", |
| 225 rendering_scheduled_component, renderer_swap_component); |
| 226 } |
| 227 |
| 228 LatencyInfo::LatencyComponent browser_received_swap_component; |
| 229 if (!latency.FindLatency( |
| 230 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, |
| 231 0, &browser_received_swap_component)) |
| 232 return; |
| 233 |
| 234 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
| 235 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", |
| 236 renderer_swap_component, browser_received_swap_component); |
| 237 |
| 238 LatencyInfo::LatencyComponent gpu_swap_component; |
| 239 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, |
| 240 0, &gpu_swap_component)) |
| 241 return; |
| 242 |
| 243 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| 244 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
| 245 browser_received_swap_component, gpu_swap_component); |
| 246 |
| 247 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
| 248 gpu_swap_component, swap_component); |
174 } | 249 } |
175 | 250 |
176 // LatencyComponents generated in the renderer must have component IDs | 251 // LatencyComponents generated in the renderer must have component IDs |
177 // provided to them by the browser process. This function adds the correct | 252 // provided to them by the browser process. This function adds the correct |
178 // component ID where necessary. | 253 // component ID where necessary. |
179 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 254 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
180 int64 latency_component_id) { | 255 int64 latency_component_id) { |
181 LatencyInfo::LatencyMap new_components; | 256 LatencyInfo::LatencyMap new_components; |
182 auto lc = latency->latency_components.begin(); | 257 auto lc = latency->latency_components.begin(); |
183 while (lc != latency->latency_components.end()) { | 258 while (lc != latency->latency_components.end()) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 332 } |
258 } | 333 } |
259 | 334 |
260 void RenderWidgetHostLatencyTracker::OnInputEventAck( | 335 void RenderWidgetHostLatencyTracker::OnInputEventAck( |
261 const blink::WebInputEvent& event, | 336 const blink::WebInputEvent& event, |
262 LatencyInfo* latency) { | 337 LatencyInfo* latency) { |
263 DCHECK(latency); | 338 DCHECK(latency); |
264 | 339 |
265 // Latency ends when it is acked but does not cause render scheduling. | 340 // Latency ends when it is acked but does not cause render scheduling. |
266 bool rendering_scheduled = latency->FindLatency( | 341 bool rendering_scheduled = latency->FindLatency( |
267 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL); | 342 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr); |
| 343 rendering_scheduled |= latency->FindLatency( |
| 344 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr); |
268 | 345 |
269 if (WebInputEvent::isGestureEventType(event.type)) { | 346 if (WebInputEvent::isGestureEventType(event.type)) { |
270 if (!rendering_scheduled) { | 347 if (!rendering_scheduled) { |
271 latency->AddLatencyNumber( | 348 latency->AddLatencyNumber( |
272 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); | 349 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); |
273 // TODO(jdduke): Consider exposing histograms for gesture event types. | 350 // TODO(jdduke): Consider exposing histograms for gesture event types. |
274 } | 351 } |
275 return; | 352 return; |
276 } | 353 } |
277 | 354 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // cause regressions. | 438 // cause regressions. |
362 return std::max( | 439 return std::max( |
363 browser_composite_latency_history_.Percentile( | 440 browser_composite_latency_history_.Percentile( |
364 kBrowserCompositeLatencyEstimationPercentile) * | 441 kBrowserCompositeLatencyEstimationPercentile) * |
365 kBrowserCompositeLatencyEstimationSlack, | 442 kBrowserCompositeLatencyEstimationSlack, |
366 base::TimeDelta::FromMicroseconds( | 443 base::TimeDelta::FromMicroseconds( |
367 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); | 444 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
368 } | 445 } |
369 | 446 |
370 } // namespace content | 447 } // namespace content |
OLD | NEW |