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 // Touch to scroll latency that is mostly under 1 second. | |
139 #define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(name, start, end) \ | |
140 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | |
141 name, (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, \ | |
142 100) | |
143 | |
138 // Long scroll latency component that is mostly under 200ms. | 144 // Long scroll latency component that is mostly under 200ms. |
139 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ | 145 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ |
140 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 146 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
141 name, \ | 147 name, \ |
142 (end.event_time - start.event_time).InMicroseconds(), \ | 148 (end.event_time - start.event_time).InMicroseconds(), \ |
143 1000, 200000, 50) | 149 1000, 200000, 50) |
144 | 150 |
145 // Short scroll latency component that is mostly under 50ms. | 151 // Short scroll latency component that is mostly under 50ms. |
146 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ | 152 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ |
147 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 153 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
148 name, \ | 154 name, \ |
149 (end.event_time - start.event_time).InMicroseconds(), \ | 155 (end.event_time - start.event_time).InMicroseconds(), \ |
150 1, 50000, 50) | 156 1, 50000, 50) |
151 | 157 |
152 void ComputeScrollLatencyHistograms( | 158 void ComputeScrollLatencyHistograms( |
153 const LatencyInfo::LatencyComponent& gpu_swap_component, | 159 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
160 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | |
154 int64 latency_component_id, | 161 int64 latency_component_id, |
155 const LatencyInfo& latency) { | 162 const LatencyInfo& latency) { |
156 DCHECK(!gpu_swap_component.event_time.is_null()); | 163 DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
164 DCHECK(!gpu_swap_end_component.event_time.is_null()); | |
157 LatencyInfo::LatencyComponent first_original_component, original_component; | 165 LatencyInfo::LatencyComponent first_original_component, original_component; |
158 if (latency.FindLatency( | 166 if (latency.FindLatency( |
159 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 167 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
160 latency_component_id, &first_original_component)) { | 168 latency_component_id, &first_original_component)) { |
161 // This UMA metric tracks the time between the final frame swap for the | 169 // This UMA metric tracks the time between the final frame swap for the |
162 // first scroll event in a sequence and the original timestamp of that | 170 // first scroll event in a sequence and the original timestamp of that |
163 // scroll event's underlying touch event. | 171 // scroll event's underlying touch event. |
164 for (size_t i = 0; i < first_original_component.event_count; i++) { | 172 for (size_t i = 0; i < first_original_component.event_count; i++) { |
165 UMA_HISTOGRAM_CUSTOM_COUNTS( | 173 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
166 "Event.Latency.TouchToFirstScrollUpdateSwap", | 174 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", |
167 (gpu_swap_component.event_time - first_original_component.event_time) | 175 gpu_swap_begin_component, first_original_component); |
Yufeng Shen (Slow to review)
2015/04/17 22:28:42
the start/end order is reversed and ditto to all t
brianderson
2015/04/17 22:52:50
Done.
| |
168 .InMicroseconds(), | 176 // TODO(brianderson): Remove this version once we have enough overlapping |
169 1, 1000000, 100); | 177 // data with the metric above. |
178 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
179 "Event.Latency.TouchToFirstScrollUpdateSwap", gpu_swap_end_component, | |
180 first_original_component); | |
170 } | 181 } |
171 original_component = first_original_component; | 182 original_component = first_original_component; |
172 } else if (!latency.FindLatency( | 183 } else if (!latency.FindLatency( |
173 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 184 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
174 latency_component_id, &original_component)) { | 185 latency_component_id, &original_component)) { |
175 return; | 186 return; |
176 } | 187 } |
177 | 188 |
178 // This UMA metric tracks the time from when the original touch event is | 189 // This UMA metric tracks the time from when the original touch event is |
179 // created (averaged if there are multiple) to when the scroll gesture | 190 // created (averaged if there are multiple) to when the scroll gesture |
180 // results in final frame swap. | 191 // results in final frame swap. |
181 for (size_t i = 0; i < original_component.event_count; i++) { | 192 for (size_t i = 0; i < original_component.event_count; i++) { |
182 UMA_HISTOGRAM_CUSTOM_COUNTS( | 193 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
183 "Event.Latency.TouchToScrollUpdateSwap", | 194 "Event.Latency.TouchToScrollUpdateSwapBegin", gpu_swap_begin_component, |
184 (gpu_swap_component.event_time - original_component.event_time) | 195 original_component); |
185 .InMicroseconds(), | 196 // TODO(brianderson): Remove this version once we have enough overlapping |
186 1, 1000000, 100); | 197 // data with the metric above. |
198 UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( | |
199 "Event.Latency.TouchToScrollUpdateSwap", gpu_swap_end_component, | |
200 original_component); | |
187 } | 201 } |
188 | 202 |
189 // TODO(miletus): Add validation for making sure the following components | 203 // TODO(miletus): Add validation for making sure the following components |
190 // are present and their event times are legit. | 204 // are present and their event times are legit. |
191 LatencyInfo::LatencyComponent rendering_scheduled_component; | 205 LatencyInfo::LatencyComponent rendering_scheduled_component; |
192 bool rendering_scheduled_on_main = latency.FindLatency( | 206 bool rendering_scheduled_on_main = latency.FindLatency( |
193 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | 207 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
194 0, &rendering_scheduled_component); | 208 0, &rendering_scheduled_component); |
195 | 209 |
196 if (!rendering_scheduled_on_main) { | 210 if (!rendering_scheduled_on_main) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, | 244 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, |
231 0, &browser_received_swap_component)) | 245 0, &browser_received_swap_component)) |
232 return; | 246 return; |
233 | 247 |
234 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | 248 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
235 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", | 249 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", |
236 renderer_swap_component, browser_received_swap_component); | 250 renderer_swap_component, browser_received_swap_component); |
237 | 251 |
238 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 252 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
239 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | 253 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
240 browser_received_swap_component, gpu_swap_component); | 254 browser_received_swap_component, gpu_swap_begin_component); |
241 | |
242 LatencyInfo::LatencyComponent gpu_swap_ack_component; | |
243 if (!latency.FindLatency( | |
244 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, | |
245 &gpu_swap_ack_component)) | |
246 return; | |
247 | 255 |
248 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | 256 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
249 gpu_swap_component, | 257 gpu_swap_begin_component, |
250 gpu_swap_ack_component); | 258 gpu_swap_end_component); |
251 } | 259 } |
252 | 260 |
253 // LatencyComponents generated in the renderer must have component IDs | 261 // LatencyComponents generated in the renderer must have component IDs |
254 // 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 |
255 // component ID where necessary. | 263 // component ID where necessary. |
256 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 264 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
257 int64 latency_component_id) { | 265 int64 latency_component_id) { |
258 LatencyInfo::LatencyMap new_components; | 266 LatencyInfo::LatencyMap new_components; |
259 auto lc = latency->latency_components.begin(); | 267 auto lc = latency->latency_components.begin(); |
260 while (lc != latency->latency_components.end()) { | 268 while (lc != latency->latency_components.end()) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 DCHECK(latencies); | 404 DCHECK(latencies); |
397 for (LatencyInfo& latency : *latencies) { | 405 for (LatencyInfo& latency : *latencies) { |
398 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 406 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
399 latency.AddLatencyNumber( | 407 latency.AddLatencyNumber( |
400 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); | 408 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); |
401 } | 409 } |
402 } | 410 } |
403 | 411 |
404 void RenderWidgetHostLatencyTracker::OnFrameSwapped( | 412 void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
405 const LatencyInfo& latency) { | 413 const LatencyInfo& latency) { |
406 LatencyInfo::LatencyComponent gpu_swap_component; | 414 LatencyInfo::LatencyComponent gpu_swap_end_component; |
407 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | 415 if (!latency.FindLatency( |
408 &gpu_swap_component)) { | 416 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
417 &gpu_swap_end_component)) { | |
409 return; | 418 return; |
410 } | 419 } |
411 | 420 |
421 LatencyInfo::LatencyComponent gpu_swap_begin_component; | |
422 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | |
423 &gpu_swap_begin_component)) { | |
424 return; | |
425 } | |
426 | |
412 LatencyInfo::LatencyComponent tab_switch_component; | 427 LatencyInfo::LatencyComponent tab_switch_component; |
413 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, | 428 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, |
414 &tab_switch_component)) { | 429 &tab_switch_component)) { |
415 base::TimeDelta delta = | 430 base::TimeDelta delta = |
416 gpu_swap_component.event_time - tab_switch_component.event_time; | 431 gpu_swap_end_component.event_time - tab_switch_component.event_time; |
417 for (size_t i = 0; i < tab_switch_component.event_count; i++) { | 432 for (size_t i = 0; i < tab_switch_component.event_count; i++) { |
418 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); | 433 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); |
419 } | 434 } |
420 } | 435 } |
421 | 436 |
422 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 437 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
423 latency_component_id_, nullptr)) { | 438 latency_component_id_, nullptr)) { |
424 return; | 439 return; |
425 } | 440 } |
426 | 441 |
427 ComputeScrollLatencyHistograms(gpu_swap_component, latency_component_id_, | 442 ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
443 gpu_swap_end_component, latency_component_id_, | |
428 latency); | 444 latency); |
429 | 445 |
430 LatencyInfo::LatencyComponent browser_swap_component; | 446 LatencyInfo::LatencyComponent browser_swap_component; |
431 if (latency.FindLatency( | 447 if (latency.FindLatency( |
432 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, | 448 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
433 &browser_swap_component)) { | 449 &browser_swap_component)) { |
434 base::TimeDelta delta = | 450 base::TimeDelta delta = |
435 gpu_swap_component.event_time - browser_swap_component.event_time; | 451 gpu_swap_begin_component.event_time - browser_swap_component.event_time; |
436 browser_composite_latency_history_.InsertSample(delta); | 452 browser_composite_latency_history_.InsertSample(delta); |
437 } | 453 } |
438 } | 454 } |
439 | 455 |
440 base::TimeDelta | 456 base::TimeDelta |
441 RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const { | 457 RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const { |
442 // TODO(brianderson): Remove lower bound on estimate once we're sure it won't | 458 // TODO(brianderson): Remove lower bound on estimate once we're sure it won't |
443 // cause regressions. | 459 // cause regressions. |
444 return std::max( | 460 return std::max( |
445 browser_composite_latency_history_.Percentile( | 461 browser_composite_latency_history_.Percentile( |
446 kBrowserCompositeLatencyEstimationPercentile) * | 462 kBrowserCompositeLatencyEstimationPercentile) * |
447 kBrowserCompositeLatencyEstimationSlack, | 463 kBrowserCompositeLatencyEstimationSlack, |
448 base::TimeDelta::FromMicroseconds( | 464 base::TimeDelta::FromMicroseconds( |
449 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); | 465 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
450 } | 466 } |
451 | 467 |
452 } // namespace content | 468 } // namespace content |
OLD | NEW |