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 "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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 virtual void AddBeginMainFrameQueueDurationCriticalDuration( | 29 virtual void AddBeginMainFrameQueueDurationCriticalDuration( |
30 base::TimeDelta duration) = 0; | 30 base::TimeDelta duration) = 0; |
31 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( | 31 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( |
32 base::TimeDelta duration) = 0; | 32 base::TimeDelta duration) = 0; |
33 virtual void AddBeginMainFrameStartToCommitDuration( | 33 virtual void AddBeginMainFrameStartToCommitDuration( |
34 base::TimeDelta duration) = 0; | 34 base::TimeDelta duration) = 0; |
35 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0; | 35 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0; |
36 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0; | 36 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0; |
37 virtual void AddActivateDuration(base::TimeDelta duration) = 0; | 37 virtual void AddActivateDuration(base::TimeDelta duration) = 0; |
38 virtual void AddDrawDuration(base::TimeDelta duration) = 0; | 38 virtual void AddDrawDuration(base::TimeDelta duration) = 0; |
39 virtual void AddSwapToAckLatency(base::TimeDelta duration) = 0; | 39 virtual void AddSubmitToAckLatency(base::TimeDelta duration) = 0; |
40 virtual void AddSwapAckWasFast(bool was_fast) = 0; | 40 virtual void AddSubmitAckWasFast(bool was_fast) = 0; |
41 | 41 |
42 // Synchronization measurements | 42 // Synchronization measurements |
43 virtual void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) = 0; | 43 virtual void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) = 0; |
44 }; | 44 }; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Using the 90th percentile will disable latency recovery | 48 // Using the 90th percentile will disable latency recovery |
49 // if we are missing the deadline approximately ~6 times per | 49 // if we are missing the deadline approximately ~6 times per |
50 // second. | 50 // second. |
51 // TODO(brianderson): Fine tune the percentiles below. | 51 // TODO(brianderson): Fine tune the percentiles below. |
52 const size_t kDurationHistorySize = 60; | 52 const size_t kDurationHistorySize = 60; |
53 const double kBeginMainFrameQueueDurationEstimationPercentile = 90.0; | 53 const double kBeginMainFrameQueueDurationEstimationPercentile = 90.0; |
54 const double kBeginMainFrameQueueDurationCriticalEstimationPercentile = 90.0; | 54 const double kBeginMainFrameQueueDurationCriticalEstimationPercentile = 90.0; |
55 const double kBeginMainFrameQueueDurationNotCriticalEstimationPercentile = 90.0; | 55 const double kBeginMainFrameQueueDurationNotCriticalEstimationPercentile = 90.0; |
56 const double kBeginMainFrameStartToCommitEstimationPercentile = 90.0; | 56 const double kBeginMainFrameStartToCommitEstimationPercentile = 90.0; |
57 const double kCommitToReadyToActivateEstimationPercentile = 90.0; | 57 const double kCommitToReadyToActivateEstimationPercentile = 90.0; |
58 const double kPrepareTilesEstimationPercentile = 90.0; | 58 const double kPrepareTilesEstimationPercentile = 90.0; |
59 const double kActivateEstimationPercentile = 90.0; | 59 const double kActivateEstimationPercentile = 90.0; |
60 const double kDrawEstimationPercentile = 90.0; | 60 const double kDrawEstimationPercentile = 90.0; |
61 | 61 |
62 constexpr base::TimeDelta kSwapAckWatchdogTimeout = | 62 constexpr base::TimeDelta kSubmitAckWatchdogTimeout = |
63 base::TimeDelta::FromSeconds(8); | 63 base::TimeDelta::FromSeconds(8); |
64 | 64 |
65 const int kUmaDurationMinMicros = 1; | 65 const int kUmaDurationMinMicros = 1; |
66 const int64_t kUmaDurationMaxMicros = base::Time::kMicrosecondsPerSecond / 5; | 66 const int64_t kUmaDurationMaxMicros = base::Time::kMicrosecondsPerSecond / 5; |
67 const int kUmaDurationBucketCount = 100; | 67 const int kUmaDurationBucketCount = 100; |
68 | 68 |
69 // This macro is deprecated since its bucket count uses too much bandwidth. | 69 // This macro is deprecated since its bucket count uses too much bandwidth. |
70 // It also has sub-optimal range and bucket distribution. | 70 // It also has sub-optimal range and bucket distribution. |
71 // TODO(brianderson): Delete this macro and associated UMAs once there is | 71 // TODO(brianderson): Delete this macro and associated UMAs once there is |
72 // sufficient overlap with the re-bucketed UMAs. | 72 // sufficient overlap with the re-bucketed UMAs. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void AddActivateDuration(base::TimeDelta duration) override { | 183 void AddActivateDuration(base::TimeDelta duration) override { |
184 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Renderer.ActivateDuration", | 184 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Renderer.ActivateDuration", |
185 duration); | 185 duration); |
186 } | 186 } |
187 | 187 |
188 void AddDrawDuration(base::TimeDelta duration) override { | 188 void AddDrawDuration(base::TimeDelta duration) override { |
189 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Renderer.DrawDuration", | 189 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Renderer.DrawDuration", |
190 duration); | 190 duration); |
191 } | 191 } |
192 | 192 |
193 void AddSwapToAckLatency(base::TimeDelta duration) override { | 193 void AddSubmitToAckLatency(base::TimeDelta duration) override { |
194 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Renderer.SwapToAckLatency", | 194 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Renderer.SwapToAckLatency", |
195 duration); | 195 duration); |
196 } | 196 } |
197 | 197 |
198 void AddSwapAckWasFast(bool was_fast) override { | 198 void AddSubmitAckWasFast(bool was_fast) override { |
199 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast); | 199 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast); |
200 } | 200 } |
201 | 201 |
202 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { | 202 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { |
203 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( | 203 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( |
204 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta); | 204 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta); |
205 } | 205 } |
206 }; | 206 }; |
207 | 207 |
208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { | 208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 void AddActivateDuration(base::TimeDelta duration) override { | 260 void AddActivateDuration(base::TimeDelta duration) override { |
261 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Browser.ActivateDuration", | 261 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Browser.ActivateDuration", |
262 duration); | 262 duration); |
263 } | 263 } |
264 | 264 |
265 void AddDrawDuration(base::TimeDelta duration) override { | 265 void AddDrawDuration(base::TimeDelta duration) override { |
266 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Browser.DrawDuration", | 266 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Browser.DrawDuration", |
267 duration); | 267 duration); |
268 } | 268 } |
269 | 269 |
270 void AddSwapToAckLatency(base::TimeDelta duration) override { | 270 void AddSubmitToAckLatency(base::TimeDelta duration) override { |
271 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Browser.SwapToAckLatency", | 271 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION("Scheduling.Browser.SwapToAckLatency", |
272 duration); | 272 duration); |
273 } | 273 } |
274 | 274 |
275 void AddSwapAckWasFast(bool was_fast) override { | 275 void AddSubmitAckWasFast(bool was_fast) override { |
276 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast); | 276 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast); |
277 } | 277 } |
278 | 278 |
279 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { | 279 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { |
280 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( | 280 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( |
281 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta); | 281 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta); |
282 } | 282 } |
283 }; | 283 }; |
284 | 284 |
285 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { | 285 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { |
286 public: | 286 public: |
287 ~NullUMAReporter() override {} | 287 ~NullUMAReporter() override {} |
288 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} | 288 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} |
289 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { | 289 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { |
290 } | 290 } |
291 void AddCommitInterval(base::TimeDelta interval) override {} | 291 void AddCommitInterval(base::TimeDelta interval) override {} |
292 void AddDrawInterval(base::TimeDelta interval) override {} | 292 void AddDrawInterval(base::TimeDelta interval) override {} |
293 void AddBeginMainFrameQueueDurationCriticalDuration( | 293 void AddBeginMainFrameQueueDurationCriticalDuration( |
294 base::TimeDelta duration) override {} | 294 base::TimeDelta duration) override {} |
295 void AddBeginMainFrameQueueDurationNotCriticalDuration( | 295 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
296 base::TimeDelta duration) override {} | 296 base::TimeDelta duration) override {} |
297 void AddBeginMainFrameStartToCommitDuration( | 297 void AddBeginMainFrameStartToCommitDuration( |
298 base::TimeDelta duration) override {} | 298 base::TimeDelta duration) override {} |
299 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {} | 299 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {} |
300 void AddPrepareTilesDuration(base::TimeDelta duration) override {} | 300 void AddPrepareTilesDuration(base::TimeDelta duration) override {} |
301 void AddActivateDuration(base::TimeDelta duration) override {} | 301 void AddActivateDuration(base::TimeDelta duration) override {} |
302 void AddDrawDuration(base::TimeDelta duration) override {} | 302 void AddDrawDuration(base::TimeDelta duration) override {} |
303 void AddSwapToAckLatency(base::TimeDelta duration) override {} | 303 void AddSubmitToAckLatency(base::TimeDelta duration) override {} |
304 void AddSwapAckWasFast(bool was_fast) override {} | 304 void AddSubmitAckWasFast(bool was_fast) override {} |
305 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {} | 305 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {} |
306 }; | 306 }; |
307 | 307 |
308 } // namespace | 308 } // namespace |
309 | 309 |
310 CompositorTimingHistory::CompositorTimingHistory( | 310 CompositorTimingHistory::CompositorTimingHistory( |
311 bool using_synchronous_renderer_compositor, | 311 bool using_synchronous_renderer_compositor, |
312 UMACategory uma_category, | 312 UMACategory uma_category, |
313 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 313 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
314 : using_synchronous_renderer_compositor_( | 314 : using_synchronous_renderer_compositor_( |
315 using_synchronous_renderer_compositor), | 315 using_synchronous_renderer_compositor), |
316 enabled_(false), | 316 enabled_(false), |
317 did_send_begin_main_frame_(false), | 317 did_send_begin_main_frame_(false), |
318 begin_main_frame_needed_continuously_(false), | 318 begin_main_frame_needed_continuously_(false), |
319 begin_main_frame_committing_continuously_(false), | 319 begin_main_frame_committing_continuously_(false), |
320 compositor_drawing_continuously_(false), | 320 compositor_drawing_continuously_(false), |
321 begin_main_frame_queue_duration_history_(kDurationHistorySize), | 321 begin_main_frame_queue_duration_history_(kDurationHistorySize), |
322 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), | 322 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), |
323 begin_main_frame_queue_duration_not_critical_history_( | 323 begin_main_frame_queue_duration_not_critical_history_( |
324 kDurationHistorySize), | 324 kDurationHistorySize), |
325 begin_main_frame_start_to_commit_duration_history_(kDurationHistorySize), | 325 begin_main_frame_start_to_commit_duration_history_(kDurationHistorySize), |
326 commit_to_ready_to_activate_duration_history_(kDurationHistorySize), | 326 commit_to_ready_to_activate_duration_history_(kDurationHistorySize), |
327 prepare_tiles_duration_history_(kDurationHistorySize), | 327 prepare_tiles_duration_history_(kDurationHistorySize), |
328 activate_duration_history_(kDurationHistorySize), | 328 activate_duration_history_(kDurationHistorySize), |
329 draw_duration_history_(kDurationHistorySize), | 329 draw_duration_history_(kDurationHistorySize), |
330 begin_main_frame_on_critical_path_(false), | 330 begin_main_frame_on_critical_path_(false), |
331 swap_ack_watchdog_enabled_(false), | 331 submit_ack_watchdog_enabled_(false), |
332 uma_reporter_(CreateUMAReporter(uma_category)), | 332 uma_reporter_(CreateUMAReporter(uma_category)), |
333 rendering_stats_instrumentation_(rendering_stats_instrumentation) {} | 333 rendering_stats_instrumentation_(rendering_stats_instrumentation) {} |
334 | 334 |
335 CompositorTimingHistory::~CompositorTimingHistory() { | 335 CompositorTimingHistory::~CompositorTimingHistory() { |
336 } | 336 } |
337 | 337 |
338 std::unique_ptr<CompositorTimingHistory::UMAReporter> | 338 std::unique_ptr<CompositorTimingHistory::UMAReporter> |
339 CompositorTimingHistory::CreateUMAReporter(UMACategory category) { | 339 CompositorTimingHistory::CreateUMAReporter(UMACategory category) { |
340 switch (category) { | 340 switch (category) { |
341 case RENDERER_UMA: | 341 case RENDERER_UMA: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 base::TimeDelta CompositorTimingHistory::ActivateDurationEstimate() const { | 448 base::TimeDelta CompositorTimingHistory::ActivateDurationEstimate() const { |
449 return activate_duration_history_.Percentile(kActivateEstimationPercentile); | 449 return activate_duration_history_.Percentile(kActivateEstimationPercentile); |
450 } | 450 } |
451 | 451 |
452 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const { | 452 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const { |
453 return draw_duration_history_.Percentile(kDrawEstimationPercentile); | 453 return draw_duration_history_.Percentile(kDrawEstimationPercentile); |
454 } | 454 } |
455 | 455 |
456 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() { | 456 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() { |
457 // After we get a new output surface, we won't get a spurious | 457 // After we get a new output surface, we won't get a spurious |
458 // swap ack from the old output surface. | 458 // CompositorFrameAck from the old output surface. |
459 swap_start_time_ = base::TimeTicks(); | 459 submit_start_time_ = base::TimeTicks(); |
460 swap_ack_watchdog_enabled_ = false; | 460 submit_ack_watchdog_enabled_ = false; |
461 } | 461 } |
462 | 462 |
463 void CompositorTimingHistory::WillBeginImplFrame( | 463 void CompositorTimingHistory::WillBeginImplFrame( |
464 bool new_active_tree_is_likely) { | 464 bool new_active_tree_is_likely) { |
465 // The check for whether a BeginMainFrame was sent anytime between two | 465 // The check for whether a BeginMainFrame was sent anytime between two |
466 // BeginImplFrames protects us from not detecting a fast main thread that | 466 // BeginImplFrames protects us from not detecting a fast main thread that |
467 // does all it's work and goes idle in between BeginImplFrames. | 467 // does all it's work and goes idle in between BeginImplFrames. |
468 // For example, this may happen if an animation is being driven with | 468 // For example, this may happen if an animation is being driven with |
469 // setInterval(17) or if input events just happen to arrive in the | 469 // setInterval(17) or if input events just happen to arrive in the |
470 // middle of every frame. | 470 // middle of every frame. |
471 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { | 471 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { |
472 SetBeginMainFrameNeededContinuously(false); | 472 SetBeginMainFrameNeededContinuously(false); |
473 SetBeginMainFrameCommittingContinuously(false); | 473 SetBeginMainFrameCommittingContinuously(false); |
474 } | 474 } |
475 | 475 |
476 if (swap_ack_watchdog_enabled_) { | 476 if (submit_ack_watchdog_enabled_) { |
477 base::TimeDelta swap_not_acked_time_ = Now() - swap_start_time_; | 477 base::TimeDelta submit_not_acked_time_ = Now() - submit_start_time_; |
478 if (swap_not_acked_time_ >= kSwapAckWatchdogTimeout) { | 478 if (submit_not_acked_time_ >= kSubmitAckWatchdogTimeout) { |
479 uma_reporter_->AddSwapAckWasFast(false); | 479 uma_reporter_->AddSubmitAckWasFast(false); |
480 // Only record this UMA once per swap. | 480 // Only record this UMA once per submitted CompositorFrame. |
481 swap_ack_watchdog_enabled_ = false; | 481 submit_ack_watchdog_enabled_ = false; |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 did_send_begin_main_frame_ = false; | 485 did_send_begin_main_frame_ = false; |
486 } | 486 } |
487 | 487 |
488 void CompositorTimingHistory::WillFinishImplFrame(bool needs_redraw) { | 488 void CompositorTimingHistory::WillFinishImplFrame(bool needs_redraw) { |
489 if (!needs_redraw) | 489 if (!needs_redraw) |
490 SetCompositorDrawingContinuously(false); | 490 SetCompositorDrawingContinuously(false); |
491 } | 491 } |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 draw_end_time - new_active_tree_draw_end_time_prev_; | 711 draw_end_time - new_active_tree_draw_end_time_prev_; |
712 uma_reporter_->AddCommitInterval(draw_interval); | 712 uma_reporter_->AddCommitInterval(draw_interval); |
713 } | 713 } |
714 new_active_tree_draw_end_time_prev_ = draw_end_time; | 714 new_active_tree_draw_end_time_prev_ = draw_end_time; |
715 } | 715 } |
716 } | 716 } |
717 | 717 |
718 draw_start_time_ = base::TimeTicks(); | 718 draw_start_time_ = base::TimeTicks(); |
719 } | 719 } |
720 | 720 |
721 void CompositorTimingHistory::DidSwapBuffers() { | 721 void CompositorTimingHistory::DidSubmitCompositorFrame() { |
722 DCHECK_EQ(base::TimeTicks(), swap_start_time_); | 722 DCHECK_EQ(base::TimeTicks(), submit_start_time_); |
723 swap_start_time_ = Now(); | 723 submit_start_time_ = Now(); |
724 swap_ack_watchdog_enabled_ = true; | 724 submit_ack_watchdog_enabled_ = true; |
725 } | 725 } |
726 | 726 |
727 void CompositorTimingHistory::DidSwapBuffersComplete() { | 727 void CompositorTimingHistory::DidReceiveCompositorFrameAck() { |
728 DCHECK_NE(base::TimeTicks(), swap_start_time_); | 728 DCHECK_NE(base::TimeTicks(), submit_start_time_); |
729 base::TimeDelta swap_to_ack_duration = Now() - swap_start_time_; | 729 base::TimeDelta submit_to_ack_duration = Now() - submit_start_time_; |
730 uma_reporter_->AddSwapToAckLatency(swap_to_ack_duration); | 730 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration); |
731 if (swap_ack_watchdog_enabled_) { | 731 if (submit_ack_watchdog_enabled_) { |
732 bool was_fast = swap_to_ack_duration < kSwapAckWatchdogTimeout; | 732 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout; |
733 uma_reporter_->AddSwapAckWasFast(was_fast); | 733 uma_reporter_->AddSubmitAckWasFast(was_fast); |
734 swap_ack_watchdog_enabled_ = false; | 734 submit_ack_watchdog_enabled_ = false; |
735 } | 735 } |
736 swap_start_time_ = base::TimeTicks(); | 736 submit_start_time_ = base::TimeTicks(); |
737 } | 737 } |
738 | 738 |
739 } // namespace cc | 739 } // namespace cc |
OLD | NEW |