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

Side by Side Diff: cc/scheduler/compositor_timing_history.cc

Issue 2754943002: Reimplement vsync latency UMA to be based on BeginImplFrame rather than BeginMainFrame (Closed)
Patch Set: Addressed CR feedback Created 3 years, 9 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
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 "cc/scheduler/compositor_timing_history.h" 5 #include "cc/scheduler/compositor_timing_history.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "cc/debug/rendering_stats_instrumentation.h" 13 #include "cc/debug/rendering_stats_instrumentation.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 class CompositorTimingHistory::UMAReporter { 17 class CompositorTimingHistory::UMAReporter {
18 public: 18 public:
19 virtual ~UMAReporter() {} 19 virtual ~UMAReporter() {}
20 20
21 // Throughput measurements 21 // Throughput measurements
22 virtual void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) = 0; 22 virtual void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) = 0;
23 virtual void AddBeginMainFrameIntervalNotCritical( 23 virtual void AddBeginMainFrameIntervalNotCritical(
24 base::TimeDelta interval) = 0; 24 base::TimeDelta interval) = 0;
25 virtual void AddCommitInterval(base::TimeDelta interval) = 0; 25 virtual void AddCommitInterval(base::TimeDelta interval) = 0;
26 virtual void AddDrawInterval(base::TimeDelta interval) = 0; 26 virtual void AddDrawInterval(base::TimeDelta interval) = 0;
27 27
28 // Latency measurements 28 // Latency measurements
29 virtual void AddBeginMainFrameLatency(base::TimeDelta delta) = 0; 29 virtual void AddBeginImplFrameLatency(base::TimeDelta delta) = 0;
30 virtual void AddBeginMainFrameQueueDurationCriticalDuration( 30 virtual void AddBeginMainFrameQueueDurationCriticalDuration(
31 base::TimeDelta duration) = 0; 31 base::TimeDelta duration) = 0;
32 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( 32 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration(
33 base::TimeDelta duration) = 0; 33 base::TimeDelta duration) = 0;
34 virtual void AddBeginMainFrameStartToCommitDuration( 34 virtual void AddBeginMainFrameStartToCommitDuration(
35 base::TimeDelta duration) = 0; 35 base::TimeDelta duration) = 0;
36 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0; 36 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0;
37 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0; 37 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0;
38 virtual void AddActivateDuration(base::TimeDelta duration) = 0; 38 virtual void AddActivateDuration(base::TimeDelta duration) = 0;
39 virtual void AddDrawDuration(base::TimeDelta duration) = 0; 39 virtual void AddDrawDuration(base::TimeDelta duration) = 0;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void AddCommitInterval(base::TimeDelta interval) override { 140 void AddCommitInterval(base::TimeDelta interval) override {
141 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 141 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
142 "Scheduling.Renderer.CommitInterval", interval); 142 "Scheduling.Renderer.CommitInterval", interval);
143 } 143 }
144 144
145 void AddDrawInterval(base::TimeDelta interval) override { 145 void AddDrawInterval(base::TimeDelta interval) override {
146 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED("Scheduling.Renderer.DrawInterval", 146 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED("Scheduling.Renderer.DrawInterval",
147 interval); 147 interval);
148 } 148 }
149 149
150 void AddBeginImplFrameLatency(base::TimeDelta delta) override {
151 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
152 "Scheduling.Renderer.VsyncToBeginImplFrameLatency", delta);
brianderson 2017/03/16 20:53:16 Using the "Vsync" is true on Windows, but is not q
stanisc 2017/03/16 21:01:12 ajuma@ suggested adding VSync in the previous revi
Ilya Sherman 2017/03/16 21:28:04 Either name is ok with me. Thanks.
stanisc 2017/03/16 23:17:41 Done.
153 }
154
150 void AddBeginMainFrameQueueDurationCriticalDuration( 155 void AddBeginMainFrameQueueDurationCriticalDuration(
151 base::TimeDelta duration) override { 156 base::TimeDelta duration) override {
152 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( 157 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
153 "Scheduling.Renderer.BeginMainFrameQueueDurationCritical", duration); 158 "Scheduling.Renderer.BeginMainFrameQueueDurationCritical", duration);
154 } 159 }
155 160
156 void AddBeginMainFrameQueueDurationNotCriticalDuration( 161 void AddBeginMainFrameQueueDurationNotCriticalDuration(
157 base::TimeDelta duration) override { 162 base::TimeDelta duration) override {
158 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( 163 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
159 "Scheduling.Renderer.BeginMainFrameQueueDurationNotCritical", duration); 164 "Scheduling.Renderer.BeginMainFrameQueueDurationNotCritical", duration);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 196 }
192 197
193 void AddSubmitAckWasFast(bool was_fast) override { 198 void AddSubmitAckWasFast(bool was_fast) override {
194 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast); 199 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast);
195 } 200 }
196 201
197 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { 202 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {
198 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 203 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
199 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta); 204 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta);
200 } 205 }
201
202 void AddBeginMainFrameLatency(base::TimeDelta delta) override {
203 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
204 "Scheduling.Renderer.VsyncToBeginMainFrameLatency", delta);
205 }
206 }; 206 };
207 207
208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { 208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter {
209 public: 209 public:
210 ~BrowserUMAReporter() override {} 210 ~BrowserUMAReporter() override {}
211 211
212 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { 212 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {
213 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 213 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
214 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); 214 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval);
215 } 215 }
216 216
217 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { 217 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override {
218 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 218 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
219 "Scheduling.Browser.BeginMainFrameIntervalNotCritical", interval); 219 "Scheduling.Browser.BeginMainFrameIntervalNotCritical", interval);
220 } 220 }
221 221
222 void AddCommitInterval(base::TimeDelta interval) override { 222 void AddCommitInterval(base::TimeDelta interval) override {
223 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 223 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
224 "Scheduling.Browser.CommitInterval", interval); 224 "Scheduling.Browser.CommitInterval", interval);
225 } 225 }
226 226
227 void AddDrawInterval(base::TimeDelta interval) override { 227 void AddDrawInterval(base::TimeDelta interval) override {
228 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED("Scheduling.Browser.DrawInterval", 228 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED("Scheduling.Browser.DrawInterval",
229 interval); 229 interval);
230 } 230 }
231 231
232 void AddBeginImplFrameLatency(base::TimeDelta delta) override {
233 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
234 "Scheduling.Browser.VsyncToBeginImplFrameLatency", delta);
235 }
236
232 void AddBeginMainFrameQueueDurationCriticalDuration( 237 void AddBeginMainFrameQueueDurationCriticalDuration(
233 base::TimeDelta duration) override { 238 base::TimeDelta duration) override {
234 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( 239 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
235 "Scheduling.Browser.BeginMainFrameQueueDurationCritical", duration); 240 "Scheduling.Browser.BeginMainFrameQueueDurationCritical", duration);
236 } 241 }
237 242
238 void AddBeginMainFrameQueueDurationNotCriticalDuration( 243 void AddBeginMainFrameQueueDurationNotCriticalDuration(
239 base::TimeDelta duration) override { 244 base::TimeDelta duration) override {
240 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( 245 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
241 "Scheduling.Browser.BeginMainFrameQueueDurationNotCritical", duration); 246 "Scheduling.Browser.BeginMainFrameQueueDurationNotCritical", duration);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 278 }
274 279
275 void AddSubmitAckWasFast(bool was_fast) override { 280 void AddSubmitAckWasFast(bool was_fast) override {
276 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast); 281 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast);
277 } 282 }
278 283
279 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { 284 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {
280 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 285 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
281 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta); 286 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta);
282 } 287 }
283
284 void AddBeginMainFrameLatency(base::TimeDelta delta) override {
285 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
286 "Scheduling.Browser.VsyncToBeginMainFrameLatency", delta);
287 }
288 }; 288 };
289 289
290 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { 290 class NullUMAReporter : public CompositorTimingHistory::UMAReporter {
291 public: 291 public:
292 ~NullUMAReporter() override {} 292 ~NullUMAReporter() override {}
293 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} 293 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {}
294 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { 294 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override {
295 } 295 }
296 void AddCommitInterval(base::TimeDelta interval) override {} 296 void AddCommitInterval(base::TimeDelta interval) override {}
297 void AddDrawInterval(base::TimeDelta interval) override {} 297 void AddDrawInterval(base::TimeDelta interval) override {}
298 void AddBeginImplFrameLatency(base::TimeDelta delta) override {}
298 void AddBeginMainFrameQueueDurationCriticalDuration( 299 void AddBeginMainFrameQueueDurationCriticalDuration(
299 base::TimeDelta duration) override {} 300 base::TimeDelta duration) override {}
300 void AddBeginMainFrameQueueDurationNotCriticalDuration( 301 void AddBeginMainFrameQueueDurationNotCriticalDuration(
301 base::TimeDelta duration) override {} 302 base::TimeDelta duration) override {}
302 void AddBeginMainFrameStartToCommitDuration( 303 void AddBeginMainFrameStartToCommitDuration(
303 base::TimeDelta duration) override {} 304 base::TimeDelta duration) override {}
304 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {} 305 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {}
305 void AddPrepareTilesDuration(base::TimeDelta duration) override {} 306 void AddPrepareTilesDuration(base::TimeDelta duration) override {}
306 void AddActivateDuration(base::TimeDelta duration) override {} 307 void AddActivateDuration(base::TimeDelta duration) override {}
307 void AddDrawDuration(base::TimeDelta duration) override {} 308 void AddDrawDuration(base::TimeDelta duration) override {}
308 void AddSubmitToAckLatency(base::TimeDelta duration) override {} 309 void AddSubmitToAckLatency(base::TimeDelta duration) override {}
309 void AddSubmitAckWasFast(bool was_fast) override {} 310 void AddSubmitAckWasFast(bool was_fast) override {}
310 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {} 311 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {}
311 void AddBeginMainFrameLatency(base::TimeDelta delta) override {}
312 }; 312 };
313 313
314 } // namespace 314 } // namespace
315 315
316 CompositorTimingHistory::CompositorTimingHistory( 316 CompositorTimingHistory::CompositorTimingHistory(
317 bool using_synchronous_renderer_compositor, 317 bool using_synchronous_renderer_compositor,
318 UMACategory uma_category, 318 UMACategory uma_category,
319 RenderingStatsInstrumentation* rendering_stats_instrumentation) 319 RenderingStatsInstrumentation* rendering_stats_instrumentation)
320 : using_synchronous_renderer_compositor_( 320 : using_synchronous_renderer_compositor_(
321 using_synchronous_renderer_compositor), 321 using_synchronous_renderer_compositor),
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 460 }
461 461
462 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() { 462 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() {
463 // After we get a new output surface, we won't get a spurious 463 // After we get a new output surface, we won't get a spurious
464 // CompositorFrameAck from the old output surface. 464 // CompositorFrameAck from the old output surface.
465 submit_start_time_ = base::TimeTicks(); 465 submit_start_time_ = base::TimeTicks();
466 submit_ack_watchdog_enabled_ = false; 466 submit_ack_watchdog_enabled_ = false;
467 } 467 }
468 468
469 void CompositorTimingHistory::WillBeginImplFrame( 469 void CompositorTimingHistory::WillBeginImplFrame(
470 bool new_active_tree_is_likely) { 470 bool new_active_tree_is_likely,
471 base::TimeTicks frame_time,
472 BeginFrameArgs::BeginFrameArgsType frame_type,
473 base::TimeTicks now) {
471 // The check for whether a BeginMainFrame was sent anytime between two 474 // The check for whether a BeginMainFrame was sent anytime between two
472 // BeginImplFrames protects us from not detecting a fast main thread that 475 // BeginImplFrames protects us from not detecting a fast main thread that
473 // does all it's work and goes idle in between BeginImplFrames. 476 // does all it's work and goes idle in between BeginImplFrames.
474 // For example, this may happen if an animation is being driven with 477 // For example, this may happen if an animation is being driven with
475 // setInterval(17) or if input events just happen to arrive in the 478 // setInterval(17) or if input events just happen to arrive in the
476 // middle of every frame. 479 // middle of every frame.
477 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { 480 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) {
478 SetBeginMainFrameNeededContinuously(false); 481 SetBeginMainFrameNeededContinuously(false);
479 SetBeginMainFrameCommittingContinuously(false); 482 SetBeginMainFrameCommittingContinuously(false);
480 } 483 }
481 484
482 if (submit_ack_watchdog_enabled_) { 485 if (submit_ack_watchdog_enabled_) {
483 base::TimeDelta submit_not_acked_time_ = Now() - submit_start_time_; 486 base::TimeDelta submit_not_acked_time_ = now - submit_start_time_;
484 if (submit_not_acked_time_ >= kSubmitAckWatchdogTimeout) { 487 if (submit_not_acked_time_ >= kSubmitAckWatchdogTimeout) {
485 uma_reporter_->AddSubmitAckWasFast(false); 488 uma_reporter_->AddSubmitAckWasFast(false);
486 // Only record this UMA once per submitted CompositorFrame. 489 // Only record this UMA once per submitted CompositorFrame.
487 submit_ack_watchdog_enabled_ = false; 490 submit_ack_watchdog_enabled_ = false;
488 } 491 }
489 } 492 }
490 493
494 if (frame_type == BeginFrameArgs::NORMAL)
495 uma_reporter_->AddBeginImplFrameLatency(now - frame_time);
496
491 did_send_begin_main_frame_ = false; 497 did_send_begin_main_frame_ = false;
492 } 498 }
493 499
494 void CompositorTimingHistory::WillFinishImplFrame(bool needs_redraw) { 500 void CompositorTimingHistory::WillFinishImplFrame(bool needs_redraw) {
495 if (!needs_redraw) 501 if (!needs_redraw)
496 SetCompositorDrawingContinuously(false); 502 SetCompositorDrawingContinuously(false);
497 } 503 }
498 504
499 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() { 505 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() {
500 SetBeginMainFrameNeededContinuously(false); 506 SetBeginMainFrameNeededContinuously(false);
501 SetBeginMainFrameCommittingContinuously(false); 507 SetBeginMainFrameCommittingContinuously(false);
502 SetCompositorDrawingContinuously(false); 508 SetCompositorDrawingContinuously(false);
503 } 509 }
504 510
505 void CompositorTimingHistory::WillBeginMainFrame( 511 void CompositorTimingHistory::WillBeginMainFrame(
506 bool on_critical_path, 512 bool on_critical_path,
507 base::TimeTicks main_frame_time, 513 base::TimeTicks main_frame_time) {
508 BeginFrameArgs::BeginFrameArgsType frame_type) {
509 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); 514 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_);
510 DCHECK_EQ(base::TimeTicks(), begin_main_frame_frame_time_); 515 DCHECK_EQ(base::TimeTicks(), begin_main_frame_frame_time_);
511 516
512 begin_main_frame_on_critical_path_ = on_critical_path; 517 begin_main_frame_on_critical_path_ = on_critical_path;
513 begin_main_frame_sent_time_ = Now(); 518 begin_main_frame_sent_time_ = Now();
514 begin_main_frame_frame_time_ = main_frame_time; 519 begin_main_frame_frame_time_ = main_frame_time;
515 520
516 if (frame_type == BeginFrameArgs::NORMAL) {
517 uma_reporter_->AddBeginMainFrameLatency(begin_main_frame_sent_time_ -
518 begin_main_frame_frame_time_);
519 }
520
521 did_send_begin_main_frame_ = true; 521 did_send_begin_main_frame_ = true;
522 SetBeginMainFrameNeededContinuously(true); 522 SetBeginMainFrameNeededContinuously(true);
523 } 523 }
524 524
525 void CompositorTimingHistory::BeginMainFrameStarted( 525 void CompositorTimingHistory::BeginMainFrameStarted(
526 base::TimeTicks main_thread_start_time) { 526 base::TimeTicks main_thread_start_time) {
527 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); 527 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_);
528 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); 528 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_);
529 begin_main_frame_start_time_ = main_thread_start_time; 529 begin_main_frame_start_time_ = main_thread_start_time;
530 } 530 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration); 742 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration);
743 if (submit_ack_watchdog_enabled_) { 743 if (submit_ack_watchdog_enabled_) {
744 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout; 744 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout;
745 uma_reporter_->AddSubmitAckWasFast(was_fast); 745 uma_reporter_->AddSubmitAckWasFast(was_fast);
746 submit_ack_watchdog_enabled_ = false; 746 submit_ack_watchdog_enabled_ = false;
747 } 747 }
748 submit_start_time_ = base::TimeTicks(); 748 submit_start_time_ = base::TimeTicks();
749 } 749 }
750 750
751 } // namespace cc 751 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/compositor_timing_history.h ('k') | cc/scheduler/compositor_timing_history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698