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

Side by Side Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 1411133003: A better idle time estimator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2526
Patch Set: Created 5 years, 1 month 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 "components/scheduler/renderer/renderer_scheduler_impl.h" 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
11 #include "cc/output/begin_frame_args.h" 11 #include "cc/output/begin_frame_args.h"
12 #include "components/scheduler/base/task_queue_impl.h" 12 #include "components/scheduler/base/task_queue_impl.h"
13 #include "components/scheduler/base/task_queue_selector.h" 13 #include "components/scheduler/base/task_queue_selector.h"
14 #include "components/scheduler/child/scheduler_task_runner_delegate.h" 14 #include "components/scheduler/child/scheduler_task_runner_delegate.h"
15 15
16 namespace scheduler { 16 namespace scheduler {
17 namespace { 17 namespace {
18 const int kLoadingTaskEstimationSampleCount = 200; 18 const int kLoadingTaskEstimationSampleCount = 200;
19 const double kLoadingTaskEstimationPercentile = 90; 19 const double kLoadingTaskEstimationPercentile = 90;
20 const int kTimerTaskEstimationSampleCount = 200; 20 const int kTimerTaskEstimationSampleCount = 200;
21 const double kTimerTaskEstimationPercentile = 90; 21 const double kTimerTaskEstimationPercentile = 90;
22 const int kShortIdlePeriodDurationSampleCount = 10; 22 const int kShortIdlePeriodDurationSampleCount = 10;
23 const double kShortIdlePeriodDurationPercentile = 20; 23 const double kShortIdlePeriodDurationPercentile = 50;
24 } 24 }
25 25
26 RendererSchedulerImpl::RendererSchedulerImpl( 26 RendererSchedulerImpl::RendererSchedulerImpl(
27 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner) 27 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner)
28 : helper_(main_task_runner, 28 : helper_(main_task_runner,
29 "renderer.scheduler", 29 "renderer.scheduler",
30 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 30 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
31 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), 31 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")),
32 idle_helper_(&helper_, 32 idle_helper_(&helper_,
33 this, 33 this,
34 "renderer.scheduler", 34 "renderer.scheduler",
35 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 35 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
36 "RendererSchedulerIdlePeriod", 36 "RendererSchedulerIdlePeriod",
37 base::TimeDelta()), 37 base::TimeDelta()),
38 control_task_runner_(helper_.ControlTaskRunner()), 38 control_task_runner_(helper_.ControlTaskRunner()),
39 compositor_task_runner_( 39 compositor_task_runner_(
40 helper_.NewTaskQueue(TaskQueue::Spec("compositor_tq") 40 helper_.NewTaskQueue(TaskQueue::Spec("compositor_tq")
41 .SetShouldMonitorQuiescence(true))), 41 .SetShouldMonitorQuiescence(true))),
42 delayed_update_policy_runner_( 42 delayed_update_policy_runner_(
43 base::Bind(&RendererSchedulerImpl::UpdatePolicy, 43 base::Bind(&RendererSchedulerImpl::UpdatePolicy,
44 base::Unretained(this)), 44 base::Unretained(this)),
45 helper_.ControlTaskRunner()), 45 helper_.ControlTaskRunner()),
46 main_thread_only_(compositor_task_runner_),
46 policy_may_need_update_(&any_thread_lock_), 47 policy_may_need_update_(&any_thread_lock_),
47 weak_factory_(this) { 48 weak_factory_(this) {
48 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, 49 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy,
49 weak_factory_.GetWeakPtr()); 50 weak_factory_.GetWeakPtr());
50 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( 51 end_renderer_hidden_idle_period_closure_.Reset(base::Bind(
51 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); 52 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr()));
52 53
53 suspend_timers_when_backgrounded_closure_.Reset( 54 suspend_timers_when_backgrounded_closure_.Reset(
54 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, 55 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded,
55 weak_factory_.GetWeakPtr())); 56 weak_factory_.GetWeakPtr()));
56 57
57 default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq"); 58 default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq");
58 default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq"); 59 default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq");
59 60
60 TRACE_EVENT_OBJECT_CREATED_WITH_ID( 61 TRACE_EVENT_OBJECT_CREATED_WITH_ID(
61 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", 62 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler",
62 this); 63 this);
63 64
64 // Make sure that we don't initially assume there is no idle time.
65 MainThreadOnly().short_idle_period_duration.InsertSample(
66 cc::BeginFrameArgs::DefaultInterval());
67
68 helper_.SetObserver(this); 65 helper_.SetObserver(this);
69 } 66 }
70 67
71 RendererSchedulerImpl::~RendererSchedulerImpl() { 68 RendererSchedulerImpl::~RendererSchedulerImpl() {
72 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 69 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
73 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", 70 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler",
74 this); 71 this);
75 72
76 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { 73 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) {
77 loading_queue->RemoveTaskObserver( 74 loading_queue->RemoveTaskObserver(
78 &MainThreadOnly().loading_task_cost_estimator); 75 &MainThreadOnly().loading_task_cost_estimator);
79 } 76 }
80 for (const scoped_refptr<TaskQueue>& timer_queue : timer_task_runners_) { 77 for (const scoped_refptr<TaskQueue>& timer_queue : timer_task_runners_) {
81 timer_queue->RemoveTaskObserver( 78 timer_queue->RemoveTaskObserver(
82 &MainThreadOnly().timer_task_cost_estimator); 79 &MainThreadOnly().timer_task_cost_estimator);
83 } 80 }
84 81
85 // Ensure the renderer scheduler was shut down explicitly, because otherwise 82 // Ensure the renderer scheduler was shut down explicitly, because otherwise
86 // we could end up having stale pointers to the Blink heap which has been 83 // we could end up having stale pointers to the Blink heap which has been
87 // terminated by this point. 84 // terminated by this point.
88 DCHECK(MainThreadOnly().was_shutdown); 85 DCHECK(MainThreadOnly().was_shutdown);
89 } 86 }
90 87
91 RendererSchedulerImpl::Policy::Policy() 88 RendererSchedulerImpl::Policy::Policy()
92 : compositor_queue_priority(TaskQueue::NORMAL_PRIORITY), 89 : compositor_queue_priority(TaskQueue::NORMAL_PRIORITY),
93 loading_queue_priority(TaskQueue::NORMAL_PRIORITY), 90 loading_queue_priority(TaskQueue::NORMAL_PRIORITY),
94 timer_queue_priority(TaskQueue::NORMAL_PRIORITY), 91 timer_queue_priority(TaskQueue::NORMAL_PRIORITY),
95 default_queue_priority(TaskQueue::NORMAL_PRIORITY) {} 92 default_queue_priority(TaskQueue::NORMAL_PRIORITY) {}
96 93
97 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly() 94 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly(
95 const scoped_refptr<TaskQueue>& compositor_task_runner)
98 : loading_task_cost_estimator(kLoadingTaskEstimationSampleCount, 96 : loading_task_cost_estimator(kLoadingTaskEstimationSampleCount,
99 kLoadingTaskEstimationPercentile), 97 kLoadingTaskEstimationPercentile),
100 timer_task_cost_estimator(kTimerTaskEstimationSampleCount, 98 timer_task_cost_estimator(kTimerTaskEstimationSampleCount,
101 kTimerTaskEstimationPercentile), 99 kTimerTaskEstimationPercentile),
102 short_idle_period_duration(kShortIdlePeriodDurationSampleCount), 100 idle_time_estimator(compositor_task_runner,
101 kShortIdlePeriodDurationSampleCount,
102 kShortIdlePeriodDurationPercentile),
103 current_use_case(UseCase::NONE), 103 current_use_case(UseCase::NONE),
104 timer_queue_suspend_count(0), 104 timer_queue_suspend_count(0),
105 navigation_task_expected_count(0), 105 navigation_task_expected_count(0),
106 renderer_hidden(false), 106 renderer_hidden(false),
107 renderer_backgrounded(false), 107 renderer_backgrounded(false),
108 timer_queue_suspension_when_backgrounded_enabled(false), 108 timer_queue_suspension_when_backgrounded_enabled(false),
109 timer_queue_suspended_when_backgrounded(false), 109 timer_queue_suspended_when_backgrounded(false),
110 was_shutdown(false), 110 was_shutdown(false),
111 loading_tasks_seem_expensive(false), 111 loading_tasks_seem_expensive(false),
112 timer_tasks_seem_expensive(false), 112 timer_tasks_seem_expensive(false),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void RendererSchedulerImpl::WillBeginFrame(const cc::BeginFrameArgs& args) { 213 void RendererSchedulerImpl::WillBeginFrame(const cc::BeginFrameArgs& args) {
214 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 214 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
215 "RendererSchedulerImpl::WillBeginFrame", "args", args.AsValue()); 215 "RendererSchedulerImpl::WillBeginFrame", "args", args.AsValue());
216 helper_.CheckOnValidThread(); 216 helper_.CheckOnValidThread();
217 if (helper_.IsShutdown()) 217 if (helper_.IsShutdown())
218 return; 218 return;
219 219
220 EndIdlePeriod(); 220 EndIdlePeriod();
221 MainThreadOnly().estimated_next_frame_begin = args.frame_time + args.interval; 221 MainThreadOnly().estimated_next_frame_begin = args.frame_time + args.interval;
222 MainThreadOnly().have_seen_a_begin_main_frame = true; 222 MainThreadOnly().have_seen_a_begin_main_frame = true;
223 MainThreadOnly().compositor_frame_interval = args.interval;
223 { 224 {
224 base::AutoLock lock(any_thread_lock_); 225 base::AutoLock lock(any_thread_lock_);
225 AnyThread().begin_main_frame_on_critical_path = args.on_critical_path; 226 AnyThread().begin_main_frame_on_critical_path = args.on_critical_path;
226 } 227 }
227 } 228 }
228 229
229 void RendererSchedulerImpl::DidCommitFrameToCompositor() { 230 void RendererSchedulerImpl::DidCommitFrameToCompositor() {
230 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 231 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
231 "RendererSchedulerImpl::DidCommitFrameToCompositor"); 232 "RendererSchedulerImpl::DidCommitFrameToCompositor");
232 helper_.CheckOnValidThread(); 233 helper_.CheckOnValidThread();
233 if (helper_.IsShutdown()) 234 if (helper_.IsShutdown())
234 return; 235 return;
235 236
236 base::TimeTicks now(helper_.Now()); 237 base::TimeTicks now(helper_.Now());
237 if (now < MainThreadOnly().estimated_next_frame_begin) { 238 if (now < MainThreadOnly().estimated_next_frame_begin) {
238 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of 239 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of
239 // the next pending delayed tasks (as currently done in for long idle times) 240 // the next pending delayed tasks (as currently done in for long idle times)
240 idle_helper_.StartIdlePeriod( 241 idle_helper_.StartIdlePeriod(
241 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, 242 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now,
242 MainThreadOnly().estimated_next_frame_begin); 243 MainThreadOnly().estimated_next_frame_begin);
243 MainThreadOnly().short_idle_period_duration.InsertSample(
244 MainThreadOnly().estimated_next_frame_begin - now);
245 } else {
246 // There was no idle time :(
247 MainThreadOnly().short_idle_period_duration.InsertSample(base::TimeDelta());
248 } 244 }
249 245
250 MainThreadOnly().expected_short_idle_period_duration = 246 MainThreadOnly().idle_time_estimator.DidCommitFrameToCompositor();
251 MainThreadOnly().short_idle_period_duration.Percentile(
252 kShortIdlePeriodDurationPercentile);
253 } 247 }
254 248
255 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { 249 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() {
256 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 250 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
257 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); 251 "RendererSchedulerImpl::BeginFrameNotExpectedSoon");
258 helper_.CheckOnValidThread(); 252 helper_.CheckOnValidThread();
259 if (helper_.IsShutdown()) 253 if (helper_.IsShutdown())
260 return; 254 return;
261 255
262 idle_helper_.EnableLongIdlePeriod(); 256 idle_helper_.EnableLongIdlePeriod();
257 {
258 base::AutoLock lock(any_thread_lock_);
259 AnyThread().begin_main_frame_on_critical_path = false;
260 }
263 } 261 }
264 262
265 void RendererSchedulerImpl::OnRendererHidden() { 263 void RendererSchedulerImpl::OnRendererHidden() {
266 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 264 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
267 "RendererSchedulerImpl::OnRendererHidden"); 265 "RendererSchedulerImpl::OnRendererHidden");
268 helper_.CheckOnValidThread(); 266 helper_.CheckOnValidThread();
269 if (helper_.IsShutdown() || MainThreadOnly().renderer_hidden) 267 if (helper_.IsShutdown() || MainThreadOnly().renderer_hidden)
270 return; 268 return;
271 269
272 idle_helper_.EnableLongIdlePeriod(); 270 idle_helper_.EnableLongIdlePeriod();
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 550
553 // TODO(alexclarke): We should wire up a signal from blink to let us know if 551 // TODO(alexclarke): We should wire up a signal from blink to let us know if
554 // there are any touch handlers registerd or not, and only call 552 // there are any touch handlers registerd or not, and only call
555 // TouchStartExpectedSoon if there is at least one. NOTE a TouchStart will 553 // TouchStartExpectedSoon if there is at least one. NOTE a TouchStart will
556 // only actually get sent if there is a touch handler. 554 // only actually get sent if there is a touch handler.
557 base::TimeDelta touchstart_expected_flag_valid_for_duration; 555 base::TimeDelta touchstart_expected_flag_valid_for_duration;
558 bool touchstart_expected_soon = AnyThread().user_model.IsGestureExpectedSoon( 556 bool touchstart_expected_soon = AnyThread().user_model.IsGestureExpectedSoon(
559 use_case, now, &touchstart_expected_flag_valid_for_duration); 557 use_case, now, &touchstart_expected_flag_valid_for_duration);
560 MainThreadOnly().touchstart_expected_soon = touchstart_expected_soon; 558 MainThreadOnly().touchstart_expected_soon = touchstart_expected_soon;
561 559
560 base::TimeDelta expected_idle_duration =
561 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration(
562 MainThreadOnly().compositor_frame_interval);
563 MainThreadOnly().expected_idle_duration = expected_idle_duration;
564
562 bool loading_tasks_seem_expensive = 565 bool loading_tasks_seem_expensive =
563 MainThreadOnly().loading_task_cost_estimator.expected_task_duration() > 566 MainThreadOnly().loading_task_cost_estimator.expected_task_duration() >
564 MainThreadOnly().expected_short_idle_period_duration; 567 expected_idle_duration;
565 MainThreadOnly().loading_tasks_seem_expensive = loading_tasks_seem_expensive; 568 MainThreadOnly().loading_tasks_seem_expensive = loading_tasks_seem_expensive;
566 569
567 bool timer_tasks_seem_expensive = 570 bool timer_tasks_seem_expensive =
568 MainThreadOnly().timer_task_cost_estimator.expected_task_duration() > 571 MainThreadOnly().timer_task_cost_estimator.expected_task_duration() >
569 MainThreadOnly().expected_short_idle_period_duration; 572 expected_idle_duration;
570 MainThreadOnly().timer_tasks_seem_expensive = timer_tasks_seem_expensive; 573 MainThreadOnly().timer_tasks_seem_expensive = timer_tasks_seem_expensive;
571 574
572 // The |new_policy_duration| is the minimum of |expected_use_case_duration| 575 // The |new_policy_duration| is the minimum of |expected_use_case_duration|
573 // and |touchstart_expected_flag_valid_for_duration| unless one is zero in 576 // and |touchstart_expected_flag_valid_for_duration| unless one is zero in
574 // which case we choose the other. 577 // which case we choose the other.
575 base::TimeDelta new_policy_duration = expected_use_case_duration; 578 base::TimeDelta new_policy_duration = expected_use_case_duration;
576 if (new_policy_duration == base::TimeDelta() || 579 if (new_policy_duration == base::TimeDelta() ||
577 (touchstart_expected_flag_valid_for_duration > base::TimeDelta() && 580 (touchstart_expected_flag_valid_for_duration > base::TimeDelta() &&
578 new_policy_duration > touchstart_expected_flag_valid_for_duration)) { 581 new_policy_duration > touchstart_expected_flag_valid_for_duration)) {
579 new_policy_duration = touchstart_expected_flag_valid_for_duration; 582 new_policy_duration = touchstart_expected_flag_valid_for_duration;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 if (!MainThreadOnly().have_seen_a_begin_main_frame) 635 if (!MainThreadOnly().have_seen_a_begin_main_frame)
633 block_expensive_tasks = false; 636 block_expensive_tasks = false;
634 637
635 // Don't block expensive tasks if we are expecting a navigation. 638 // Don't block expensive tasks if we are expecting a navigation.
636 if (MainThreadOnly().navigation_task_expected_count > 0) 639 if (MainThreadOnly().navigation_task_expected_count > 0)
637 block_expensive_tasks = false; 640 block_expensive_tasks = false;
638 641
639 if (block_expensive_tasks && loading_tasks_seem_expensive) 642 if (block_expensive_tasks && loading_tasks_seem_expensive)
640 new_policy.loading_queue_priority = TaskQueue::DISABLED_PRIORITY; 643 new_policy.loading_queue_priority = TaskQueue::DISABLED_PRIORITY;
641 644
642 if (MainThreadOnly().timer_queue_suspend_count != 0 || 645 if ((block_expensive_tasks && timer_tasks_seem_expensive) ||
646 MainThreadOnly().timer_queue_suspend_count != 0 ||
643 MainThreadOnly().timer_queue_suspended_when_backgrounded) { 647 MainThreadOnly().timer_queue_suspended_when_backgrounded) {
644 new_policy.timer_queue_priority = TaskQueue::DISABLED_PRIORITY; 648 new_policy.timer_queue_priority = TaskQueue::DISABLED_PRIORITY;
645 } 649 }
646 650
647 // Tracing is done before the early out check, because it's quite possible we 651 // Tracing is done before the early out check, because it's quite possible we
648 // will otherwise miss this information in traces. 652 // will otherwise miss this information in traces.
649 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 653 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
650 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", 654 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler",
651 this, AsValueLocked(now)); 655 this, AsValueLocked(now));
652 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", 656 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case",
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 TaskCostEstimator* 755 TaskCostEstimator*
752 RendererSchedulerImpl::GetLoadingTaskCostEstimatorForTesting() { 756 RendererSchedulerImpl::GetLoadingTaskCostEstimatorForTesting() {
753 return &MainThreadOnly().loading_task_cost_estimator; 757 return &MainThreadOnly().loading_task_cost_estimator;
754 } 758 }
755 759
756 TaskCostEstimator* 760 TaskCostEstimator*
757 RendererSchedulerImpl::GetTimerTaskCostEstimatorForTesting() { 761 RendererSchedulerImpl::GetTimerTaskCostEstimatorForTesting() {
758 return &MainThreadOnly().timer_task_cost_estimator; 762 return &MainThreadOnly().timer_task_cost_estimator;
759 } 763 }
760 764
765 IdleTimeEstimator* RendererSchedulerImpl::GetIdleTimeEstimatorForTesting() {
766 return &MainThreadOnly().idle_time_estimator;
767 }
768
761 void RendererSchedulerImpl::SuspendTimerQueue() { 769 void RendererSchedulerImpl::SuspendTimerQueue() {
762 MainThreadOnly().timer_queue_suspend_count++; 770 MainThreadOnly().timer_queue_suspend_count++;
763 ForceUpdatePolicy(); 771 ForceUpdatePolicy();
764 #ifndef NDEBUG 772 #ifndef NDEBUG
765 DCHECK(!default_timer_task_runner_->IsQueueEnabled()); 773 DCHECK(!default_timer_task_runner_->IsQueueEnabled());
766 for (const auto& runner : timer_task_runners_) { 774 for (const auto& runner : timer_task_runners_) {
767 DCHECK(!runner->IsQueueEnabled()); 775 DCHECK(!runner->IsQueueEnabled());
768 } 776 }
769 #endif 777 #endif
770 } 778 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 AnyThread().begin_main_frame_on_critical_path); 839 AnyThread().begin_main_frame_on_critical_path);
832 state->SetDouble("expected_loading_task_duration", 840 state->SetDouble("expected_loading_task_duration",
833 MainThreadOnly() 841 MainThreadOnly()
834 .loading_task_cost_estimator.expected_task_duration() 842 .loading_task_cost_estimator.expected_task_duration()
835 .InMillisecondsF()); 843 .InMillisecondsF());
836 state->SetDouble("expected_timer_task_duration", 844 state->SetDouble("expected_timer_task_duration",
837 MainThreadOnly() 845 MainThreadOnly()
838 .timer_task_cost_estimator.expected_task_duration() 846 .timer_task_cost_estimator.expected_task_duration()
839 .InMillisecondsF()); 847 .InMillisecondsF());
840 // TODO(skyostil): Can we somehow trace how accurate these estimates were? 848 // TODO(skyostil): Can we somehow trace how accurate these estimates were?
849 state->SetDouble("expected_idle_duration",
850 MainThreadOnly().expected_idle_duration.InMillisecondsF());
841 state->SetDouble( 851 state->SetDouble(
842 "expected_short_idle_period_duration", 852 "compositor_frame_interval",
843 MainThreadOnly().expected_short_idle_period_duration.InMillisecondsF()); 853 MainThreadOnly().compositor_frame_interval.InMillisecondsF());
844 state->SetDouble( 854 state->SetDouble(
845 "estimated_next_frame_begin", 855 "estimated_next_frame_begin",
846 (MainThreadOnly().estimated_next_frame_begin - base::TimeTicks()) 856 (MainThreadOnly().estimated_next_frame_begin - base::TimeTicks())
847 .InMillisecondsF()); 857 .InMillisecondsF());
848 state->SetBoolean("in_idle_period", AnyThread().in_idle_period); 858 state->SetBoolean("in_idle_period", AnyThread().in_idle_period);
849 AnyThread().user_model.AsValueInto(state.get()); 859 AnyThread().user_model.AsValueInto(state.get());
850 860
851 return state; 861 return state;
852 } 862 }
853 863
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 920
911 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; 921 MainThreadOnly().timer_queue_suspended_when_backgrounded = false;
912 ForceUpdatePolicy(); 922 ForceUpdatePolicy();
913 } 923 }
914 924
915 void RendererSchedulerImpl::ResetForNavigationLocked() { 925 void RendererSchedulerImpl::ResetForNavigationLocked() {
916 helper_.CheckOnValidThread(); 926 helper_.CheckOnValidThread();
917 any_thread_lock_.AssertAcquired(); 927 any_thread_lock_.AssertAcquired();
918 MainThreadOnly().loading_task_cost_estimator.Clear(); 928 MainThreadOnly().loading_task_cost_estimator.Clear();
919 MainThreadOnly().timer_task_cost_estimator.Clear(); 929 MainThreadOnly().timer_task_cost_estimator.Clear();
920 MainThreadOnly().short_idle_period_duration.Clear(); 930 MainThreadOnly().idle_time_estimator.Clear();
921 // Make sure that we don't initially assume there is no idle time.
922 MainThreadOnly().short_idle_period_duration.InsertSample(
923 cc::BeginFrameArgs::DefaultInterval());
924 AnyThread().user_model.Reset(); 931 AnyThread().user_model.Reset();
925 MainThreadOnly().have_seen_a_begin_main_frame = false; 932 MainThreadOnly().have_seen_a_begin_main_frame = false;
926 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); 933 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED);
927 } 934 }
928 935
929 } // namespace scheduler 936 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698