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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/debug/rendering_stats_instrumentation.h" | 9 #include "cc/debug/rendering_stats_instrumentation.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 bool affects_estimate) = 0; | 31 bool affects_estimate) = 0; |
32 virtual void AddPrepareTilesDuration(base::TimeDelta duration, | 32 virtual void AddPrepareTilesDuration(base::TimeDelta duration, |
33 base::TimeDelta estimate, | 33 base::TimeDelta estimate, |
34 bool affects_estimate) = 0; | 34 bool affects_estimate) = 0; |
35 virtual void AddActivateDuration(base::TimeDelta duration, | 35 virtual void AddActivateDuration(base::TimeDelta duration, |
36 base::TimeDelta estimate, | 36 base::TimeDelta estimate, |
37 bool affects_estimate) = 0; | 37 bool affects_estimate) = 0; |
38 virtual void AddDrawDuration(base::TimeDelta duration, | 38 virtual void AddDrawDuration(base::TimeDelta duration, |
39 base::TimeDelta estimate, | 39 base::TimeDelta estimate, |
40 bool affects_estimate) = 0; | 40 bool affects_estimate) = 0; |
| 41 virtual void AddSwapToAckLatency(base::TimeDelta duration) = 0; |
41 }; | 42 }; |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
45 // Using the 90th percentile will disable latency recovery | 46 // Using the 90th percentile will disable latency recovery |
46 // if we are missing the deadline approximately ~6 times per | 47 // if we are missing the deadline approximately ~6 times per |
47 // second. | 48 // second. |
48 // TODO(brianderson): Fine tune the percentiles below. | 49 // TODO(brianderson): Fine tune the percentiles below. |
49 const size_t kDurationHistorySize = 60; | 50 const size_t kDurationHistorySize = 60; |
50 const double kBeginMainFrameToCommitEstimationPercentile = 90.0; | 51 const double kBeginMainFrameToCommitEstimationPercentile = 90.0; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 bool affects_estimate) override { | 173 bool affects_estimate) override { |
173 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "Activate"); | 174 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "Activate"); |
174 } | 175 } |
175 | 176 |
176 void AddDrawDuration(base::TimeDelta duration, | 177 void AddDrawDuration(base::TimeDelta duration, |
177 base::TimeDelta estimate, | 178 base::TimeDelta estimate, |
178 bool affects_estimate) override { | 179 bool affects_estimate) override { |
179 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "Draw"); | 180 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "Draw"); |
180 DeprecatedDrawDurationUMA(duration, estimate); | 181 DeprecatedDrawDurationUMA(duration, estimate); |
181 } | 182 } |
| 183 |
| 184 void AddSwapToAckLatency(base::TimeDelta duration) override { |
| 185 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.SwapToAckLatency", |
| 186 duration); |
| 187 } |
182 }; | 188 }; |
183 | 189 |
184 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { | 190 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { |
185 public: | 191 public: |
186 ~BrowserUMAReporter() override {} | 192 ~BrowserUMAReporter() override {} |
187 | 193 |
188 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 194 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
189 base::TimeDelta estimate, | 195 base::TimeDelta estimate, |
190 bool affects_estimate) override { | 196 bool affects_estimate) override { |
191 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "BeginMainFrameToCommit"); | 197 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "BeginMainFrameToCommit"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 bool affects_estimate) override { | 234 bool affects_estimate) override { |
229 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Activate"); | 235 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Activate"); |
230 } | 236 } |
231 | 237 |
232 void AddDrawDuration(base::TimeDelta duration, | 238 void AddDrawDuration(base::TimeDelta duration, |
233 base::TimeDelta estimate, | 239 base::TimeDelta estimate, |
234 bool affects_estimate) override { | 240 bool affects_estimate) override { |
235 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Draw"); | 241 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Draw"); |
236 DeprecatedDrawDurationUMA(duration, estimate); | 242 DeprecatedDrawDurationUMA(duration, estimate); |
237 } | 243 } |
| 244 |
| 245 void AddSwapToAckLatency(base::TimeDelta duration) override { |
| 246 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.SwapToAckLatency", |
| 247 duration); |
| 248 } |
238 }; | 249 }; |
239 | 250 |
240 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { | 251 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { |
241 public: | 252 public: |
242 ~NullUMAReporter() override {} | 253 ~NullUMAReporter() override {} |
243 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 254 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
244 base::TimeDelta estimate, | 255 base::TimeDelta estimate, |
245 bool affects_estimate) override {} | 256 bool affects_estimate) override {} |
246 void AddBeginMainFrameQueueDurationCriticalDuration( | 257 void AddBeginMainFrameQueueDurationCriticalDuration( |
247 base::TimeDelta duration, | 258 base::TimeDelta duration, |
248 bool affects_estimate) override {} | 259 bool affects_estimate) override {} |
249 void AddBeginMainFrameQueueDurationNotCriticalDuration( | 260 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
250 base::TimeDelta duration, | 261 base::TimeDelta duration, |
251 bool affects_estimate) override {} | 262 bool affects_estimate) override {} |
252 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, | 263 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, |
253 bool affects_estimate) override {} | 264 bool affects_estimate) override {} |
254 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, | 265 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, |
255 base::TimeDelta estimate, | 266 base::TimeDelta estimate, |
256 bool affects_estimate) override {} | 267 bool affects_estimate) override {} |
257 void AddPrepareTilesDuration(base::TimeDelta duration, | 268 void AddPrepareTilesDuration(base::TimeDelta duration, |
258 base::TimeDelta estimate, | 269 base::TimeDelta estimate, |
259 bool affects_estimate) override {} | 270 bool affects_estimate) override {} |
260 void AddActivateDuration(base::TimeDelta duration, | 271 void AddActivateDuration(base::TimeDelta duration, |
261 base::TimeDelta estimate, | 272 base::TimeDelta estimate, |
262 bool affects_estimate) override {} | 273 bool affects_estimate) override {} |
263 void AddDrawDuration(base::TimeDelta duration, | 274 void AddDrawDuration(base::TimeDelta duration, |
264 base::TimeDelta estimate, | 275 base::TimeDelta estimate, |
265 bool affects_estimate) override {} | 276 bool affects_estimate) override {} |
| 277 void AddSwapToAckLatency(base::TimeDelta duration) override {} |
266 }; | 278 }; |
267 | 279 |
268 } // namespace | 280 } // namespace |
269 | 281 |
270 CompositorTimingHistory::CompositorTimingHistory( | 282 CompositorTimingHistory::CompositorTimingHistory( |
271 UMACategory uma_category, | 283 UMACategory uma_category, |
272 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 284 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
273 : enabled_(false), | 285 : enabled_(false), |
274 begin_main_frame_sent_to_commit_duration_history_(kDurationHistorySize), | 286 begin_main_frame_sent_to_commit_duration_history_(kDurationHistorySize), |
275 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), | 287 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 541 |
530 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); | 542 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); |
531 | 543 |
532 if (enabled_) { | 544 if (enabled_) { |
533 draw_duration_history_.InsertSample(draw_duration); | 545 draw_duration_history_.InsertSample(draw_duration); |
534 } | 546 } |
535 | 547 |
536 start_draw_time_ = base::TimeTicks(); | 548 start_draw_time_ = base::TimeTicks(); |
537 } | 549 } |
538 | 550 |
| 551 void CompositorTimingHistory::DidSwapBuffers() { |
| 552 DCHECK_EQ(base::TimeTicks(), swap_start_time_); |
| 553 swap_start_time_ = Now(); |
| 554 } |
| 555 |
| 556 void CompositorTimingHistory::DidSwapBuffersComplete() { |
| 557 DCHECK_NE(base::TimeTicks(), swap_start_time_); |
| 558 base::TimeDelta swap_to_ack_duration = Now() - swap_start_time_; |
| 559 uma_reporter_->AddSwapToAckLatency(swap_to_ack_duration); |
| 560 swap_start_time_ = base::TimeTicks(); |
| 561 } |
| 562 |
| 563 void CompositorTimingHistory::DidSwapBuffersReset() { |
| 564 swap_start_time_ = base::TimeTicks(); |
| 565 } |
| 566 |
539 } // namespace cc | 567 } // namespace cc |
OLD | NEW |