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 LatencyInfo::LatencyComponent rendering_scheduled_component; | |
190 bool ret = false; | |
191 bool rendering_scheduled_on_main = latency.FindLatency( | |
192 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | |
193 0, &rendering_scheduled_component); | |
194 | |
195 if (!rendering_scheduled_on_main) { | |
196 ret = latency.FindLatency( | |
197 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, | |
198 0, &rendering_scheduled_component); | |
199 DCHECK(ret); | |
200 if (!ret) return; | |
201 } | |
202 | |
203 DCHECK(rendering_scheduled_component.event_time >= | |
204 original_component.event_time); | |
205 | |
206 if (rendering_scheduled_on_main) { | |
207 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
208 "Event.Latency.ScrollUpdate.TouchToHandled_Main", | |
209 original_component, rendering_scheduled_component); | |
210 } else { | |
211 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
212 "Event.Latency.ScrollUpdate.TouchToHandled_Impl", | |
213 original_component, rendering_scheduled_component); | |
214 } | |
215 | |
216 LatencyInfo::LatencyComponent renderer_swap_component; | |
217 ret = latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | |
218 0, &renderer_swap_component); | |
219 DCHECK(ret && renderer_swap_component.event_time >= | |
220 rendering_scheduled_component.event_time); | |
221 if (!ret) return; | |
222 | |
223 if (rendering_scheduled_on_main) { | |
224 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
225 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", | |
226 rendering_scheduled_component, renderer_swap_component); | |
227 } else { | |
228 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
229 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", | |
230 rendering_scheduled_component, renderer_swap_component); | |
231 } | |
232 | |
233 LatencyInfo::LatencyComponent browser_received_swap_component; | |
234 ret = latency.FindLatency( | |
235 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, | |
236 0, &browser_received_swap_component); | |
237 DCHECK(ret && browser_received_swap_component.event_time >= | |
238 renderer_swap_component.event_time); | |
239 if (!ret) return; | |
240 | |
241 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | |
242 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", | |
243 renderer_swap_component, browser_received_swap_component); | |
244 | |
245 LatencyInfo::LatencyComponent gpu_swap_component; | |
246 ret = latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, | |
247 0, &gpu_swap_component); | |
248 DCHECK(ret && gpu_swap_component.event_time >= | |
jdduke (slow)
2015/02/18 00:00:16
Hmm, these combined DCHECK conditions will be diff
| |
249 browser_received_swap_component.event_time && | |
250 swap_component.event_time >= gpu_swap_component.event_time); | |
251 if (!ret) return; | |
252 | |
253 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
254 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | |
255 browser_received_swap_component, gpu_swap_component); | |
256 | |
257 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | |
258 gpu_swap_component, swap_component); | |
174 } | 259 } |
175 | 260 |
176 // LatencyComponents generated in the renderer must have component IDs | 261 // LatencyComponents generated in the renderer must have component IDs |
177 // provided to them by the browser process. This function adds the correct | 262 // provided to them by the browser process. This function adds the correct |
178 // component ID where necessary. | 263 // component ID where necessary. |
179 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 264 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
180 int64 latency_component_id) { | 265 int64 latency_component_id) { |
181 LatencyInfo::LatencyMap new_components; | 266 LatencyInfo::LatencyMap new_components; |
182 auto lc = latency->latency_components.begin(); | 267 auto lc = latency->latency_components.begin(); |
183 while (lc != latency->latency_components.end()) { | 268 while (lc != latency->latency_components.end()) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 } | 342 } |
258 } | 343 } |
259 | 344 |
260 void RenderWidgetHostLatencyTracker::OnInputEventAck( | 345 void RenderWidgetHostLatencyTracker::OnInputEventAck( |
261 const blink::WebInputEvent& event, | 346 const blink::WebInputEvent& event, |
262 LatencyInfo* latency) { | 347 LatencyInfo* latency) { |
263 DCHECK(latency); | 348 DCHECK(latency); |
264 | 349 |
265 // Latency ends when it is acked but does not cause render scheduling. | 350 // Latency ends when it is acked but does not cause render scheduling. |
266 bool rendering_scheduled = latency->FindLatency( | 351 bool rendering_scheduled = latency->FindLatency( |
267 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL); | 352 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr); |
353 rendering_scheduled |= latency->FindLatency( | |
354 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr); | |
268 | 355 |
269 if (WebInputEvent::isGestureEventType(event.type)) { | 356 if (WebInputEvent::isGestureEventType(event.type)) { |
270 if (!rendering_scheduled) { | 357 if (!rendering_scheduled) { |
271 latency->AddLatencyNumber( | 358 latency->AddLatencyNumber( |
272 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); | 359 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); |
273 // TODO(jdduke): Consider exposing histograms for gesture event types. | 360 // TODO(jdduke): Consider exposing histograms for gesture event types. |
274 } | 361 } |
275 return; | 362 return; |
276 } | 363 } |
277 | 364 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 // cause regressions. | 448 // cause regressions. |
362 return std::max( | 449 return std::max( |
363 browser_composite_latency_history_.Percentile( | 450 browser_composite_latency_history_.Percentile( |
364 kBrowserCompositeLatencyEstimationPercentile) * | 451 kBrowserCompositeLatencyEstimationPercentile) * |
365 kBrowserCompositeLatencyEstimationSlack, | 452 kBrowserCompositeLatencyEstimationSlack, |
366 base::TimeDelta::FromMicroseconds( | 453 base::TimeDelta::FromMicroseconds( |
367 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); | 454 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
368 } | 455 } |
369 | 456 |
370 } // namespace content | 457 } // namespace content |
OLD | NEW |