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/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 rendering_scheduled_on_main = latency.FindLatency( | |
| 191 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, | |
| 192 0, &rendering_scheduled_component); | |
| 193 | |
| 194 if (!rendering_scheduled_on_main) { | |
| 195 if (!latency.FindLatency( | |
| 196 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, | |
| 197 0, &rendering_scheduled_component)) | |
| 198 return; | |
| 199 } | |
| 200 | |
| 201 if (rendering_scheduled_on_main) { | |
| 202 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 203 "Event.Latency.ScrollUpdate.TouchToHandled_Main", | |
| 204 original_component, rendering_scheduled_component); | |
| 205 } else { | |
| 206 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 207 "Event.Latency.ScrollUpdate.TouchToHandled_Impl", | |
| 208 original_component, rendering_scheduled_component); | |
| 209 } | |
| 210 | |
| 211 LatencyInfo::LatencyComponent renderer_swap_component; | |
| 212 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | |
| 213 0, &renderer_swap_component)) | |
| 214 return; | |
| 215 | |
| 216 if (rendering_scheduled_on_main) { | |
| 217 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
|
jdduke (slow)
2015/02/17 20:40:37
Will using separate buckets for impl vs main make
Alexei Svitkine (slow)
2015/02/17 20:53:02
I have this concern as well - if you're planning t
Yufeng Shen (Slow to review)
2015/02/17 20:55:39
Done.
| |
| 218 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", | |
| 219 rendering_scheduled_component, renderer_swap_component); | |
| 220 } else { | |
| 221 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | |
| 222 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", | |
| 223 rendering_scheduled_component, renderer_swap_component); | |
| 224 } | |
| 225 | |
| 226 LatencyInfo::LatencyComponent browser_received_swap_component; | |
| 227 if (!latency.FindLatency( | |
| 228 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, | |
| 229 0, &browser_received_swap_component)) | |
| 230 return; | |
| 231 | |
| 232 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( | |
| 233 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", | |
| 234 renderer_swap_component, browser_received_swap_component); | |
| 235 | |
| 236 LatencyInfo::LatencyComponent gpu_swap_component; | |
| 237 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, | |
| 238 0, &gpu_swap_component)) | |
| 239 return; | |
| 240 | |
| 241 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( | |
| 242 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", | |
| 243 browser_received_swap_component, gpu_swap_component); | |
| 244 | |
| 245 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", | |
| 246 gpu_swap_component, swap_component); | |
| 174 } | 247 } |
| 175 | 248 |
| 176 // LatencyComponents generated in the renderer must have component IDs | 249 // LatencyComponents generated in the renderer must have component IDs |
| 177 // provided to them by the browser process. This function adds the correct | 250 // provided to them by the browser process. This function adds the correct |
| 178 // component ID where necessary. | 251 // component ID where necessary. |
| 179 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 252 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
| 180 int64 latency_component_id) { | 253 int64 latency_component_id) { |
| 181 LatencyInfo::LatencyMap new_components; | 254 LatencyInfo::LatencyMap new_components; |
| 182 auto lc = latency->latency_components.begin(); | 255 auto lc = latency->latency_components.begin(); |
| 183 while (lc != latency->latency_components.end()) { | 256 while (lc != latency->latency_components.end()) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 } | 330 } |
| 258 } | 331 } |
| 259 | 332 |
| 260 void RenderWidgetHostLatencyTracker::OnInputEventAck( | 333 void RenderWidgetHostLatencyTracker::OnInputEventAck( |
| 261 const blink::WebInputEvent& event, | 334 const blink::WebInputEvent& event, |
| 262 LatencyInfo* latency) { | 335 LatencyInfo* latency) { |
| 263 DCHECK(latency); | 336 DCHECK(latency); |
| 264 | 337 |
| 265 // Latency ends when it is acked but does not cause render scheduling. | 338 // Latency ends when it is acked but does not cause render scheduling. |
| 266 bool rendering_scheduled = latency->FindLatency( | 339 bool rendering_scheduled = latency->FindLatency( |
| 267 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL); | 340 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr); |
| 341 rendering_scheduled |= latency->FindLatency( | |
| 342 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr); | |
| 268 | 343 |
| 269 if (WebInputEvent::isGestureEventType(event.type)) { | 344 if (WebInputEvent::isGestureEventType(event.type)) { |
| 270 if (!rendering_scheduled) { | 345 if (!rendering_scheduled) { |
| 271 latency->AddLatencyNumber( | 346 latency->AddLatencyNumber( |
| 272 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); | 347 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); |
| 273 // TODO(jdduke): Consider exposing histograms for gesture event types. | 348 // TODO(jdduke): Consider exposing histograms for gesture event types. |
| 274 } | 349 } |
| 275 return; | 350 return; |
| 276 } | 351 } |
| 277 | 352 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 // cause regressions. | 436 // cause regressions. |
| 362 return std::max( | 437 return std::max( |
| 363 browser_composite_latency_history_.Percentile( | 438 browser_composite_latency_history_.Percentile( |
| 364 kBrowserCompositeLatencyEstimationPercentile) * | 439 kBrowserCompositeLatencyEstimationPercentile) * |
| 365 kBrowserCompositeLatencyEstimationSlack, | 440 kBrowserCompositeLatencyEstimationSlack, |
| 366 base::TimeDelta::FromMicroseconds( | 441 base::TimeDelta::FromMicroseconds( |
| 367 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); | 442 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
| 368 } | 443 } |
| 369 | 444 |
| 370 } // namespace content | 445 } // namespace content |
| OLD | NEW |