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

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

Issue 1192663005: cc: Measure compositor timing with finer granularity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@modeTimingHistory3
Patch Set: don't reset timing history Created 5 years, 5 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/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 estimated_parent_draw_time_ = draw_time; 124 estimated_parent_draw_time_ = draw_time;
125 } 125 }
126 126
127 void Scheduler::SetCanStart() { 127 void Scheduler::SetCanStart() {
128 state_machine_.SetCanStart(); 128 state_machine_.SetCanStart();
129 ProcessScheduledActions(); 129 ProcessScheduledActions();
130 } 130 }
131 131
132 void Scheduler::SetVisible(bool visible) { 132 void Scheduler::SetVisible(bool visible) {
133 state_machine_.SetVisible(visible); 133 state_machine_.SetVisible(visible);
134 UpdateCompositorTimingHistoryRecordingEnabled();
134 ProcessScheduledActions(); 135 ProcessScheduledActions();
135 } 136 }
136 137
137 void Scheduler::SetCanDraw(bool can_draw) { 138 void Scheduler::SetCanDraw(bool can_draw) {
138 state_machine_.SetCanDraw(can_draw); 139 state_machine_.SetCanDraw(can_draw);
139 ProcessScheduledActions(); 140 ProcessScheduledActions();
140 } 141 }
141 142
142 void Scheduler::NotifyReadyToActivate() { 143 void Scheduler::NotifyReadyToActivate() {
144 compositor_timing_history_->ReadyToActivate();
143 state_machine_.NotifyReadyToActivate(); 145 state_machine_.NotifyReadyToActivate();
144 ProcessScheduledActions(); 146 ProcessScheduledActions();
145 } 147 }
146 148
147 void Scheduler::NotifyReadyToDraw() { 149 void Scheduler::NotifyReadyToDraw() {
148 // Future work might still needed for crbug.com/352894. 150 // Future work might still needed for crbug.com/352894.
149 state_machine_.NotifyReadyToDraw(); 151 state_machine_.NotifyReadyToDraw();
150 ProcessScheduledActions(); 152 ProcessScheduledActions();
151 } 153 }
152 154
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 state_machine_.SetImplLatencyTakesPriority(impl_latency_takes_priority); 212 state_machine_.SetImplLatencyTakesPriority(impl_latency_takes_priority);
211 ProcessScheduledActions(); 213 ProcessScheduledActions();
212 } 214 }
213 215
214 void Scheduler::NotifyReadyToCommit() { 216 void Scheduler::NotifyReadyToCommit() {
215 TRACE_EVENT0("cc", "Scheduler::NotifyReadyToCommit"); 217 TRACE_EVENT0("cc", "Scheduler::NotifyReadyToCommit");
216 state_machine_.NotifyReadyToCommit(); 218 state_machine_.NotifyReadyToCommit();
217 ProcessScheduledActions(); 219 ProcessScheduledActions();
218 } 220 }
219 221
222 void Scheduler::DidCommit() {
223 compositor_timing_history_->DidCommit();
224 }
225
220 void Scheduler::BeginMainFrameAborted(CommitEarlyOutReason reason) { 226 void Scheduler::BeginMainFrameAborted(CommitEarlyOutReason reason) {
221 TRACE_EVENT1("cc", "Scheduler::BeginMainFrameAborted", "reason", 227 TRACE_EVENT1("cc", "Scheduler::BeginMainFrameAborted", "reason",
222 CommitEarlyOutReasonToString(reason)); 228 CommitEarlyOutReasonToString(reason));
229 compositor_timing_history_->BeginMainFrameAborted();
223 state_machine_.BeginMainFrameAborted(reason); 230 state_machine_.BeginMainFrameAborted(reason);
224 ProcessScheduledActions(); 231 ProcessScheduledActions();
225 } 232 }
226 233
234 void Scheduler::WillPrepareTiles() {
235 compositor_timing_history_->WillPrepareTiles();
236 }
237
227 void Scheduler::DidPrepareTiles() { 238 void Scheduler::DidPrepareTiles() {
239 compositor_timing_history_->DidPrepareTiles();
228 state_machine_.DidPrepareTiles(); 240 state_machine_.DidPrepareTiles();
229 } 241 }
230 242
231 void Scheduler::DidLoseOutputSurface() { 243 void Scheduler::DidLoseOutputSurface() {
232 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); 244 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface");
233 begin_retro_frame_args_.clear(); 245 begin_retro_frame_args_.clear();
234 begin_retro_frame_task_.Cancel(); 246 begin_retro_frame_task_.Cancel();
235 state_machine_.DidLoseOutputSurface(); 247 state_machine_.DidLoseOutputSurface();
248 UpdateCompositorTimingHistoryRecordingEnabled();
236 ProcessScheduledActions(); 249 ProcessScheduledActions();
237 } 250 }
238 251
239 void Scheduler::DidCreateAndInitializeOutputSurface() { 252 void Scheduler::DidCreateAndInitializeOutputSurface() {
240 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); 253 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
241 DCHECK(!frame_source_->NeedsBeginFrames()); 254 DCHECK(!frame_source_->NeedsBeginFrames());
242 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); 255 DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
243 state_machine_.DidCreateAndInitializeOutputSurface(); 256 state_machine_.DidCreateAndInitializeOutputSurface();
257 UpdateCompositorTimingHistoryRecordingEnabled();
244 ProcessScheduledActions(); 258 ProcessScheduledActions();
245 } 259 }
246 260
247 void Scheduler::NotifyBeginMainFrameStarted() { 261 void Scheduler::NotifyBeginMainFrameStarted() {
248 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); 262 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
249 state_machine_.NotifyBeginMainFrameStarted(); 263 state_machine_.NotifyBeginMainFrameStarted();
250 } 264 }
251 265
252 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 266 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
253 return begin_impl_frame_tracker_.Current().frame_time; 267 return begin_impl_frame_tracker_.Current().frame_time;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 586 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
573 tracked_objects::ScopedTracker tracking_profile1( 587 tracked_objects::ScopedTracker tracking_profile1(
574 FROM_HERE_WITH_EXPLICIT_FUNCTION( 588 FROM_HERE_WITH_EXPLICIT_FUNCTION(
575 "461509 Scheduler::OnBeginImplFrameDeadline1")); 589 "461509 Scheduler::OnBeginImplFrameDeadline1"));
576 state_machine_.OnBeginImplFrameDeadline(); 590 state_machine_.OnBeginImplFrameDeadline();
577 ProcessScheduledActions(); 591 ProcessScheduledActions();
578 FinishImplFrame(); 592 FinishImplFrame();
579 } 593 }
580 594
581 void Scheduler::DrawAndSwapIfPossible() { 595 void Scheduler::DrawAndSwapIfPossible() {
582 compositor_timing_history_->DidStartDrawing(); 596 compositor_timing_history_->WillDraw();
583 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); 597 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible();
584 state_machine_.DidDrawIfPossibleCompleted(result); 598 state_machine_.DidDrawIfPossibleCompleted(result);
585 compositor_timing_history_->DidFinishDrawing(); 599 compositor_timing_history_->DidDraw();
586 } 600 }
587 601
588 void Scheduler::DrawAndSwapForced() { 602 void Scheduler::DrawAndSwapForced() {
589 compositor_timing_history_->DidStartDrawing(); 603 compositor_timing_history_->WillDraw();
590 client_->ScheduledActionDrawAndSwapForced(); 604 client_->ScheduledActionDrawAndSwapForced();
591 compositor_timing_history_->DidFinishDrawing(); 605 compositor_timing_history_->DidDraw();
592 } 606 }
593 607
594 void Scheduler::SetDeferCommits(bool defer_commits) { 608 void Scheduler::SetDeferCommits(bool defer_commits) {
595 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits", 609 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits",
596 "defer_commits", 610 "defer_commits",
597 defer_commits); 611 defer_commits);
598 state_machine_.SetDeferCommits(defer_commits); 612 state_machine_.SetDeferCommits(defer_commits);
599 ProcessScheduledActions(); 613 ProcessScheduledActions();
600 } 614 }
601 615
(...skipping 25 matching lines...) Expand all
627 compositor_timing_history_->WillBeginMainFrame(); 641 compositor_timing_history_->WillBeginMainFrame();
628 client_->ScheduledActionSendBeginMainFrame(); 642 client_->ScheduledActionSendBeginMainFrame();
629 break; 643 break;
630 case SchedulerStateMachine::ACTION_COMMIT: { 644 case SchedulerStateMachine::ACTION_COMMIT: {
631 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is 645 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is
632 // fixed. 646 // fixed.
633 tracked_objects::ScopedTracker tracking_profile4( 647 tracked_objects::ScopedTracker tracking_profile4(
634 FROM_HERE_WITH_EXPLICIT_FUNCTION( 648 FROM_HERE_WITH_EXPLICIT_FUNCTION(
635 "461509 Scheduler::ProcessScheduledActions4")); 649 "461509 Scheduler::ProcessScheduledActions4"));
636 client_->ScheduledActionCommit(); 650 client_->ScheduledActionCommit();
637 compositor_timing_history_->DidCommit();
638 break; 651 break;
639 } 652 }
640 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: 653 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE:
654 compositor_timing_history_->WillActivate();
641 client_->ScheduledActionActivateSyncTree(); 655 client_->ScheduledActionActivateSyncTree();
642 compositor_timing_history_->DidActivateSyncTree(); 656 compositor_timing_history_->DidActivate();
643 break; 657 break;
644 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { 658 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: {
645 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is 659 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is
646 // fixed. 660 // fixed.
647 tracked_objects::ScopedTracker tracking_profile6( 661 tracked_objects::ScopedTracker tracking_profile6(
648 FROM_HERE_WITH_EXPLICIT_FUNCTION( 662 FROM_HERE_WITH_EXPLICIT_FUNCTION(
649 "461509 Scheduler::ProcessScheduledActions6")); 663 "461509 Scheduler::ProcessScheduledActions6"));
650 DrawAndSwapIfPossible(); 664 DrawAndSwapIfPossible();
651 break; 665 break;
652 } 666 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 state->BeginDictionary("begin_impl_frame_args"); 728 state->BeginDictionary("begin_impl_frame_args");
715 begin_impl_frame_tracker_.AsValueInto(Now(), state); 729 begin_impl_frame_tracker_.AsValueInto(Now(), state);
716 state->EndDictionary(); 730 state->EndDictionary();
717 state->EndDictionary(); 731 state->EndDictionary();
718 732
719 state->BeginDictionary("compositor_timing_history"); 733 state->BeginDictionary("compositor_timing_history");
720 compositor_timing_history_->AsValueInto(state); 734 compositor_timing_history_->AsValueInto(state);
721 state->EndDictionary(); 735 state->EndDictionary();
722 } 736 }
723 737
738 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() {
739 compositor_timing_history_->SetRecordingEnabled(
740 state_machine_.HasInitializedOutputSurface() && state_machine_.visible());
741 }
742
724 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { 743 bool Scheduler::CanCommitAndActivateBeforeDeadline() const {
725 BeginFrameArgs args = 744 BeginFrameArgs args =
726 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast(); 745 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast();
727 746
728 // Check if the main thread computation and commit can be finished before the 747 // Check if the main thread computation and commit can be finished before the
729 // impl thread's deadline. 748 // impl thread's deadline.
730 base::TimeTicks estimated_draw_time = 749 base::TimeTicks estimated_draw_time =
731 args.frame_time + 750 args.frame_time +
732 compositor_timing_history_->BeginMainFrameToCommitDurationEstimate() + 751 compositor_timing_history_->BeginMainFrameToCommitDurationEstimate() +
733 compositor_timing_history_->CommitToActivateDurationEstimate(); 752 compositor_timing_history_->CommitToReadyToActivateDurationEstimate() +
753 compositor_timing_history_->ActivateDurationEstimate();
734 754
735 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 755 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
736 "CanCommitAndActivateBeforeDeadline", 756 "CanCommitAndActivateBeforeDeadline",
737 "time_left_after_drawing_ms", 757 "time_left_after_drawing_ms",
738 (args.deadline - estimated_draw_time).InMillisecondsF(), "state", 758 (args.deadline - estimated_draw_time).InMillisecondsF(), "state",
739 AsValue()); 759 AsValue());
740 760
741 return estimated_draw_time < args.deadline; 761 return estimated_draw_time < args.deadline;
742 } 762 }
743 763
744 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 764 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
745 return (state_machine_.commit_state() == 765 return (state_machine_.commit_state() ==
746 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 766 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
747 state_machine_.commit_state() == 767 state_machine_.commit_state() ==
748 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 768 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
749 } 769 }
750 770
751 } // namespace cc 771 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698