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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 1000, 200000, 50) | 143 1000, 200000, 50) |
144 | 144 |
145 // Short scroll latency component that is mostly under 50ms. | 145 // Short scroll latency component that is mostly under 50ms. |
146 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ | 146 #define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ |
147 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 147 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
148 name, \ | 148 name, \ |
149 (end.event_time - start.event_time).InMicroseconds(), \ | 149 (end.event_time - start.event_time).InMicroseconds(), \ |
150 1, 50000, 50) | 150 1, 50000, 50) |
151 | 151 |
152 void ComputeScrollLatencyHistograms( | 152 void ComputeScrollLatencyHistograms( |
153 const LatencyInfo::LatencyComponent& gpu_swap_component, | 153 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
154 const LatencyInfo::LatencyComponent& gpu_swap_end_component, | |
154 int64 latency_component_id, | 155 int64 latency_component_id, |
155 const LatencyInfo& latency) { | 156 const LatencyInfo& latency) { |
156 DCHECK(!gpu_swap_component.event_time.is_null()); | 157 DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
158 DCHECK(!gpu_swap_end_component.event_time.is_null()); | |
157 LatencyInfo::LatencyComponent first_original_component, original_component; | 159 LatencyInfo::LatencyComponent first_original_component, original_component; |
158 if (latency.FindLatency( | 160 if (latency.FindLatency( |
159 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 161 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
160 latency_component_id, &first_original_component)) { | 162 latency_component_id, &first_original_component)) { |
161 // This UMA metric tracks the time between the final frame swap for the | 163 // 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 | 164 // first scroll event in a sequence and the original timestamp of that |
163 // scroll event's underlying touch event. | 165 // scroll event's underlying touch event. |
164 for (size_t i = 0; i < first_original_component.event_count; i++) { | 166 for (size_t i = 0; i < first_original_component.event_count; i++) { |
165 UMA_HISTOGRAM_CUSTOM_COUNTS( | 167 UMA_HISTOGRAM_CUSTOM_COUNTS( |
168 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", | |
169 (gpu_swap_begin_component.event_time - | |
170 first_original_component.event_time).InMicroseconds(), | |
171 1, 1000000, 100); | |
Yufeng Shen (Slow to review)
2015/04/17 21:49:58
a UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY macro for
brianderson
2015/04/17 22:01:41
Done.
| |
172 } | |
173 // TODO(brianderson): Remove this version once we have enough overlapping | |
174 // data with the metric above. | |
175 for (size_t i = 0; i < first_original_component.event_count; i++) { | |
176 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
Yufeng Shen (Slow to review)
2015/04/17 21:49:58
you can do this in the same loop above.
brianderson
2015/04/17 22:01:41
Done.
| |
166 "Event.Latency.TouchToFirstScrollUpdateSwap", | 177 "Event.Latency.TouchToFirstScrollUpdateSwap", |
167 (gpu_swap_component.event_time - first_original_component.event_time) | 178 (gpu_swap_end_component.event_time - |
168 .InMicroseconds(), | 179 first_original_component.event_time).InMicroseconds(), |
169 1, 1000000, 100); | 180 1, 1000000, 100); |
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_CUSTOM_COUNTS( |
194 "Event.Latency.TouchToScrollUpdateSwapBegin", | |
195 (gpu_swap_begin_component.event_time - original_component.event_time) | |
196 .InMicroseconds(), | |
197 1, 1000000, 100); | |
198 // TODO(brianderson): Remove this version once we have enough overlapping | |
199 // data with the metric above. | |
200 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
183 "Event.Latency.TouchToScrollUpdateSwap", | 201 "Event.Latency.TouchToScrollUpdateSwap", |
184 (gpu_swap_component.event_time - original_component.event_time) | 202 (gpu_swap_end_component.event_time - original_component.event_time) |
185 .InMicroseconds(), | 203 .InMicroseconds(), |
186 1, 1000000, 100); | 204 1, 1000000, 100); |
187 } | 205 } |
188 | 206 |
189 // TODO(miletus): Add validation for making sure the following components | 207 // TODO(miletus): Add validation for making sure the following components |
190 // are present and their event times are legit. | 208 // are present and their event times are legit. |
191 LatencyInfo::LatencyComponent rendering_scheduled_component; | 209 LatencyInfo::LatencyComponent rendering_scheduled_component; |
192 bool rendering_scheduled_on_main = latency.FindLatency( | 210 bool rendering_scheduled_on_main = latency.FindLatency( |
193 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | 211 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
194 0, &rendering_scheduled_component); | 212 0, &rendering_scheduled_component); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, | 248 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, |
231 0, &browser_received_swap_component)) | 249 0, &browser_received_swap_component)) |
232 return; | 250 return; |
233 | 251 |
234 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | 252 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
235 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", | 253 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", |
236 renderer_swap_component, browser_received_swap_component); | 254 renderer_swap_component, browser_received_swap_component); |
237 | 255 |
238 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | 256 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
239 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | 257 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
240 browser_received_swap_component, gpu_swap_component); | 258 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 | 259 |
248 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | 260 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
249 gpu_swap_component, | 261 gpu_swap_begin_component, |
250 gpu_swap_ack_component); | 262 gpu_swap_end_component); |
251 } | 263 } |
252 | 264 |
253 // LatencyComponents generated in the renderer must have component IDs | 265 // LatencyComponents generated in the renderer must have component IDs |
254 // provided to them by the browser process. This function adds the correct | 266 // provided to them by the browser process. This function adds the correct |
255 // component ID where necessary. | 267 // component ID where necessary. |
256 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 268 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
257 int64 latency_component_id) { | 269 int64 latency_component_id) { |
258 LatencyInfo::LatencyMap new_components; | 270 LatencyInfo::LatencyMap new_components; |
259 auto lc = latency->latency_components.begin(); | 271 auto lc = latency->latency_components.begin(); |
260 while (lc != latency->latency_components.end()) { | 272 while (lc != latency->latency_components.end()) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 DCHECK(latencies); | 408 DCHECK(latencies); |
397 for (LatencyInfo& latency : *latencies) { | 409 for (LatencyInfo& latency : *latencies) { |
398 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 410 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
399 latency.AddLatencyNumber( | 411 latency.AddLatencyNumber( |
400 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); | 412 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); |
401 } | 413 } |
402 } | 414 } |
403 | 415 |
404 void RenderWidgetHostLatencyTracker::OnFrameSwapped( | 416 void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
405 const LatencyInfo& latency) { | 417 const LatencyInfo& latency) { |
406 LatencyInfo::LatencyComponent gpu_swap_component; | 418 LatencyInfo::LatencyComponent gpu_swap_end_component; |
407 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | 419 if (!latency.FindLatency( |
408 &gpu_swap_component)) { | 420 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
421 &gpu_swap_end_component)) { | |
409 return; | 422 return; |
410 } | 423 } |
411 | 424 |
425 LatencyInfo::LatencyComponent gpu_swap_begin_component; | |
426 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | |
427 &gpu_swap_begin_component)) { | |
428 return; | |
429 } | |
430 | |
412 LatencyInfo::LatencyComponent tab_switch_component; | 431 LatencyInfo::LatencyComponent tab_switch_component; |
413 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, | 432 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, |
414 &tab_switch_component)) { | 433 &tab_switch_component)) { |
415 base::TimeDelta delta = | 434 base::TimeDelta delta = |
416 gpu_swap_component.event_time - tab_switch_component.event_time; | 435 gpu_swap_end_component.event_time - tab_switch_component.event_time; |
brianderson
2015/04/17 21:21:52
jbauman: Heads up that this will change MPArch.RWH
| |
417 for (size_t i = 0; i < tab_switch_component.event_count; i++) { | 436 for (size_t i = 0; i < tab_switch_component.event_count; i++) { |
418 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); | 437 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); |
419 } | 438 } |
420 } | 439 } |
421 | 440 |
422 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 441 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
423 latency_component_id_, nullptr)) { | 442 latency_component_id_, nullptr)) { |
424 return; | 443 return; |
425 } | 444 } |
426 | 445 |
427 ComputeScrollLatencyHistograms(gpu_swap_component, latency_component_id_, | 446 ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
447 gpu_swap_end_component, latency_component_id_, | |
428 latency); | 448 latency); |
429 | 449 |
430 LatencyInfo::LatencyComponent browser_swap_component; | 450 LatencyInfo::LatencyComponent browser_swap_component; |
431 if (latency.FindLatency( | 451 if (latency.FindLatency( |
432 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, | 452 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
433 &browser_swap_component)) { | 453 &browser_swap_component)) { |
434 base::TimeDelta delta = | 454 base::TimeDelta delta = |
435 gpu_swap_component.event_time - browser_swap_component.event_time; | 455 gpu_swap_begin_component.event_time - browser_swap_component.event_time; |
jdduke (slow)
2015/04/17 21:26:40
Hmm, I'm wondering if it makes sense to use the "e
brianderson
2015/04/17 21:51:29
For this one I'd prefer to keep the begin componen
jdduke (slow)
2015/04/17 22:03:22
I see. By "renderer" do you mean Blink? Or the ren
| |
436 browser_composite_latency_history_.InsertSample(delta); | 456 browser_composite_latency_history_.InsertSample(delta); |
437 } | 457 } |
438 } | 458 } |
439 | 459 |
440 base::TimeDelta | 460 base::TimeDelta |
441 RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const { | 461 RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const { |
442 // TODO(brianderson): Remove lower bound on estimate once we're sure it won't | 462 // TODO(brianderson): Remove lower bound on estimate once we're sure it won't |
443 // cause regressions. | 463 // cause regressions. |
444 return std::max( | 464 return std::max( |
445 browser_composite_latency_history_.Percentile( | 465 browser_composite_latency_history_.Percentile( |
446 kBrowserCompositeLatencyEstimationPercentile) * | 466 kBrowserCompositeLatencyEstimationPercentile) * |
447 kBrowserCompositeLatencyEstimationSlack, | 467 kBrowserCompositeLatencyEstimationSlack, |
448 base::TimeDelta::FromMicroseconds( | 468 base::TimeDelta::FromMicroseconds( |
449 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); | 469 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
450 } | 470 } |
451 | 471 |
452 } // namespace content | 472 } // namespace content |
OLD | NEW |