Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: content/browser/renderer_host/render_widget_host_latency_tracker.cc

Issue 921473003: Break down end-to-end scroll update latency UMA metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Scroll latency is mostly under 1000ms.
Alexei Svitkine (slow) 2015/02/13 16:16:33 I'm not convinced that these macro params are the
Yufeng Shen (Slow to review) 2015/02/17 20:37:21 Thanks Alexei for the suggestions. Here is what's
139 #define UMA_HISTOGRAM_SCROLL_LATENCY(name, start, end) \
140 UMA_HISTOGRAM_CUSTOM_COUNTS( \
141 name, \
142 (end.event_time - start.event_time).InMicroseconds(), \
143 1, 1000000, 100)
144
138 void ComputeScrollLatencyHistograms( 145 void ComputeScrollLatencyHistograms(
139 const LatencyInfo::LatencyComponent& swap_component, 146 const LatencyInfo::LatencyComponent& swap_component,
140 int64 latency_component_id, 147 int64 latency_component_id,
141 const ui::LatencyInfo& latency) { 148 const ui::LatencyInfo& latency) {
142 DCHECK(!swap_component.event_time.is_null()); 149 DCHECK(!swap_component.event_time.is_null());
143 LatencyInfo::LatencyComponent first_original_component, original_component; 150 LatencyInfo::LatencyComponent first_original_component, original_component;
144 if (latency.FindLatency( 151 if (latency.FindLatency(
145 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 152 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
146 latency_component_id, &first_original_component)) { 153 latency_component_id, &first_original_component)) {
147 // This UMA metric tracks the time between the final frame swap for the 154 // This UMA metric tracks the time between the final frame swap for the
148 // first scroll event in a sequence and the original timestamp of that 155 // first scroll event in a sequence and the original timestamp of that
149 // scroll event's underlying touch event. 156 // scroll event's underlying touch event.
150 for (size_t i = 0; i < first_original_component.event_count; i++) { 157 for (size_t i = 0; i < first_original_component.event_count; i++) {
151 UMA_HISTOGRAM_CUSTOM_COUNTS( 158 UMA_HISTOGRAM_SCROLL_LATENCY(
152 "Event.Latency.TouchToFirstScrollUpdateSwap", 159 "Event.Latency.TouchToFirstScrollUpdateSwap",
153 (swap_component.event_time - first_original_component.event_time) 160 first_original_component, swap_component);
154 .InMicroseconds(),
155 1, 1000000, 100);
156 } 161 }
157 original_component = first_original_component; 162 original_component = first_original_component;
158 } else if (!latency.FindLatency( 163 } else if (!latency.FindLatency(
159 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 164 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
160 latency_component_id, &original_component)) { 165 latency_component_id, &original_component)) {
161 return; 166 return;
162 } 167 }
163 168
164 // This UMA metric tracks the time from when the original touch event is 169 // 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 170 // created (averaged if there are multiple) to when the scroll gesture
166 // results in final frame swap. 171 // results in final frame swap.
167 for (size_t i = 0; i < original_component.event_count; i++) { 172 for (size_t i = 0; i < original_component.event_count; i++) {
168 UMA_HISTOGRAM_CUSTOM_COUNTS( 173 UMA_HISTOGRAM_SCROLL_LATENCY(
169 "Event.Latency.TouchToScrollUpdateSwap", 174 "Event.Latency.TouchToScrollUpdateSwap",
170 (swap_component.event_time - original_component.event_time) 175 original_component, swap_component);
171 .InMicroseconds(),
172 1, 1000000, 100);
173 } 176 }
177
178 LatencyInfo::LatencyComponent rendering_scheduled_component;
179 bool rendering_scheduled_on_main = latency.FindLatency(
180 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT,
181 0, &rendering_scheduled_component);
182
183 if (!rendering_scheduled_on_main) {
184 if (!latency.FindLatency(
185 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT,
186 0, &rendering_scheduled_component))
187 return;
188 }
189
190 if (rendering_scheduled_on_main) {
191 UMA_HISTOGRAM_SCROLL_LATENCY(
192 "Event.Latency.ScrollUpdate.TouchToHandled_Main",
193 original_component, rendering_scheduled_component);
194 } else {
195 UMA_HISTOGRAM_SCROLL_LATENCY(
196 "Event.Latency.ScrollUpdate.TouchToHandled_Impl",
197 original_component, rendering_scheduled_component);
198 }
199
200 LatencyInfo::LatencyComponent renderer_swap_component;
201 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT,
202 0, &renderer_swap_component))
203 return;
204
205 if (rendering_scheduled_on_main) {
206 UMA_HISTOGRAM_SCROLL_LATENCY(
207 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main",
208 rendering_scheduled_component, renderer_swap_component);
209 } else {
210 UMA_HISTOGRAM_SCROLL_LATENCY(
211 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl",
212 rendering_scheduled_component, renderer_swap_component);
213 }
214
215 LatencyInfo::LatencyComponent browser_received_swap_component;
216 if (!latency.FindLatency(
217 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT,
218 0, &browser_received_swap_component))
219 return;
220
221 UMA_HISTOGRAM_SCROLL_LATENCY(
222 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified",
223 renderer_swap_component, browser_received_swap_component);
224
225 LatencyInfo::LatencyComponent gpu_swap_component;
226 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT,
227 0, &gpu_swap_component))
228 return;
229
230 UMA_HISTOGRAM_SCROLL_LATENCY(
231 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap",
232 browser_received_swap_component, gpu_swap_component);
233
234 UMA_HISTOGRAM_SCROLL_LATENCY("Event.Latency.ScrollUpdate.GpuSwap",
235 gpu_swap_component, swap_component);
174 } 236 }
175 237
176 // LatencyComponents generated in the renderer must have component IDs 238 // LatencyComponents generated in the renderer must have component IDs
177 // provided to them by the browser process. This function adds the correct 239 // provided to them by the browser process. This function adds the correct
178 // component ID where necessary. 240 // component ID where necessary.
179 void AddLatencyInfoComponentIds(LatencyInfo* latency, 241 void AddLatencyInfoComponentIds(LatencyInfo* latency,
180 int64 latency_component_id) { 242 int64 latency_component_id) {
181 LatencyInfo::LatencyMap new_components; 243 LatencyInfo::LatencyMap new_components;
182 auto lc = latency->latency_components.begin(); 244 auto lc = latency->latency_components.begin();
183 while (lc != latency->latency_components.end()) { 245 while (lc != latency->latency_components.end()) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 319 }
258 } 320 }
259 321
260 void RenderWidgetHostLatencyTracker::OnInputEventAck( 322 void RenderWidgetHostLatencyTracker::OnInputEventAck(
261 const blink::WebInputEvent& event, 323 const blink::WebInputEvent& event,
262 LatencyInfo* latency) { 324 LatencyInfo* latency) {
263 DCHECK(latency); 325 DCHECK(latency);
264 326
265 // Latency ends when it is acked but does not cause render scheduling. 327 // Latency ends when it is acked but does not cause render scheduling.
266 bool rendering_scheduled = latency->FindLatency( 328 bool rendering_scheduled = latency->FindLatency(
267 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL); 329 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, nullptr);
330 rendering_scheduled |= latency->FindLatency(
331 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, nullptr);
268 332
269 if (WebInputEvent::isGestureEventType(event.type)) { 333 if (WebInputEvent::isGestureEventType(event.type)) {
270 if (!rendering_scheduled) { 334 if (!rendering_scheduled) {
271 latency->AddLatencyNumber( 335 latency->AddLatencyNumber(
272 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0); 336 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, 0);
273 // TODO(jdduke): Consider exposing histograms for gesture event types. 337 // TODO(jdduke): Consider exposing histograms for gesture event types.
274 } 338 }
275 return; 339 return;
276 } 340 }
277 341
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // cause regressions. 425 // cause regressions.
362 return std::max( 426 return std::max(
363 browser_composite_latency_history_.Percentile( 427 browser_composite_latency_history_.Percentile(
364 kBrowserCompositeLatencyEstimationPercentile) * 428 kBrowserCompositeLatencyEstimationPercentile) *
365 kBrowserCompositeLatencyEstimationSlack, 429 kBrowserCompositeLatencyEstimationSlack,
366 base::TimeDelta::FromMicroseconds( 430 base::TimeDelta::FromMicroseconds(
367 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); 431 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60)));
368 } 432 }
369 433
370 } // namespace content 434 } // namespace content
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698