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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2581243004: Pass main thread responsiveness threshold via Finch (Closed)
Patch Set: Use EXPECT_FALSE/TRUE - avoids compile error. Created 3 years, 10 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 "platform/scheduler/renderer/renderer_scheduler_impl.h" 5 #include "platform/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/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 29 matching lines...) Expand all
40 // Amount of idle time left in a frame (as a ratio of the vsync interval) above 40 // Amount of idle time left in a frame (as a ratio of the vsync interval) above
41 // which main thread compositing can be considered fast. 41 // which main thread compositing can be considered fast.
42 const double kFastCompositingIdleTimeThreshold = .2; 42 const double kFastCompositingIdleTimeThreshold = .2;
43 constexpr base::TimeDelta kThreadLoadTrackerReportingInterval = 43 constexpr base::TimeDelta kThreadLoadTrackerReportingInterval =
44 base::TimeDelta::FromMinutes(1); 44 base::TimeDelta::FromMinutes(1);
45 constexpr base::TimeDelta kThreadLoadTrackerWaitingPeriodBeforeReporting = 45 constexpr base::TimeDelta kThreadLoadTrackerWaitingPeriodBeforeReporting =
46 base::TimeDelta::FromMinutes(2); 46 base::TimeDelta::FromMinutes(2);
47 // We do not throttle anything while audio is played and shortly after that. 47 // We do not throttle anything while audio is played and shortly after that.
48 constexpr base::TimeDelta kThrottlingDelayAfterAudioIsPlayed = 48 constexpr base::TimeDelta kThrottlingDelayAfterAudioIsPlayed =
49 base::TimeDelta::FromSeconds(5); 49 base::TimeDelta::FromSeconds(5);
50 // Maximum task queueing time before the main thread is considered unresponsive.
51 constexpr base::TimeDelta kMainThreadResponsivenessThreshold =
52 base::TimeDelta::FromMilliseconds(200);
53 50
54 void ReportForegroundRendererTaskLoad(base::TimeTicks time, double load) { 51 void ReportForegroundRendererTaskLoad(base::TimeTicks time, double load) {
55 int load_percentage = static_cast<int>(load * 100); 52 int load_percentage = static_cast<int>(load * 100);
56 UMA_HISTOGRAM_PERCENTAGE("RendererScheduler.ForegroundRendererMainThreadLoad", 53 UMA_HISTOGRAM_PERCENTAGE("RendererScheduler.ForegroundRendererMainThreadLoad",
57 load_percentage); 54 load_percentage);
58 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 55 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
59 "RendererScheduler.ForegroundRendererLoad", load_percentage); 56 "RendererScheduler.ForegroundRendererLoad", load_percentage);
60 } 57 }
61 58
62 void ReportBackgroundRendererTaskLoad(base::TimeTicks time, double load) { 59 void ReportBackgroundRendererTaskLoad(base::TimeTicks time, double load) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 base::Bind(&RendererSchedulerImpl::UpdatePolicy, 104 base::Bind(&RendererSchedulerImpl::UpdatePolicy,
108 base::Unretained(this)), 105 base::Unretained(this)),
109 helper_.ControlTaskRunner()), 106 helper_.ControlTaskRunner()),
110 seqlock_queueing_time_estimator_( 107 seqlock_queueing_time_estimator_(
111 QueueingTimeEstimator(this, base::TimeDelta::FromSeconds(1))), 108 QueueingTimeEstimator(this, base::TimeDelta::FromSeconds(1))),
112 main_thread_only_(this, 109 main_thread_only_(this,
113 compositor_task_runner_, 110 compositor_task_runner_,
114 helper_.scheduler_tqm_delegate().get(), 111 helper_.scheduler_tqm_delegate().get(),
115 helper_.scheduler_tqm_delegate()->NowTicks()), 112 helper_.scheduler_tqm_delegate()->NowTicks()),
116 policy_may_need_update_(&any_thread_lock_), 113 policy_may_need_update_(&any_thread_lock_),
117 main_thread_responsiveness_threshold_(kMainThreadResponsivenessThreshold),
118 weak_factory_(this) { 114 weak_factory_(this) {
119 task_queue_throttler_.reset( 115 task_queue_throttler_.reset(
120 new TaskQueueThrottler(this, "renderer.scheduler")); 116 new TaskQueueThrottler(this, "renderer.scheduler"));
121 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, 117 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy,
122 weak_factory_.GetWeakPtr()); 118 weak_factory_.GetWeakPtr());
123 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( 119 end_renderer_hidden_idle_period_closure_.Reset(base::Bind(
124 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); 120 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr()));
125 121
126 suspend_timers_when_backgrounded_closure_.Reset( 122 suspend_timers_when_backgrounded_closure_.Reset(
127 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, 123 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded,
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 default_loading_task_runner_->SetBlameContext(blame_context); 1612 default_loading_task_runner_->SetBlameContext(blame_context);
1617 default_timer_task_runner_->SetBlameContext(blame_context); 1613 default_timer_task_runner_->SetBlameContext(blame_context);
1618 compositor_task_runner_->SetBlameContext(blame_context); 1614 compositor_task_runner_->SetBlameContext(blame_context);
1619 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); 1615 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context);
1620 } 1616 }
1621 1617
1622 void RendererSchedulerImpl::SetRAILModeObserver(RAILModeObserver* observer) { 1618 void RendererSchedulerImpl::SetRAILModeObserver(RAILModeObserver* observer) {
1623 MainThreadOnly().rail_mode_observer = observer; 1619 MainThreadOnly().rail_mode_observer = observer;
1624 } 1620 }
1625 1621
1626 bool RendererSchedulerImpl::MainThreadSeemsUnresponsive() { 1622 bool RendererSchedulerImpl::MainThreadSeemsUnresponsive(
1623 base::TimeDelta main_thread_responsiveness_threshold) {
1627 base::TimeTicks now = tick_clock()->NowTicks(); 1624 base::TimeTicks now = tick_clock()->NowTicks();
1628 base::TimeDelta estimated_queueing_time; 1625 base::TimeDelta estimated_queueing_time;
1629 1626
1630 bool can_read = false; 1627 bool can_read = false;
1631 QueueingTimeEstimator::State queueing_time_estimator_state; 1628 QueueingTimeEstimator::State queueing_time_estimator_state;
1632 1629
1633 base::subtle::Atomic32 version; 1630 base::subtle::Atomic32 version;
1634 seqlock_queueing_time_estimator_.seqlock.TryRead(&can_read, &version); 1631 seqlock_queueing_time_estimator_.seqlock.TryRead(&can_read, &version);
1635 1632
1636 // If we fail to determine if the main thread is busy, assume whether or not 1633 // If we fail to determine if the main thread is busy, assume whether or not
1637 // it's busy hasn't change since the last time we asked. 1634 // it's busy hasn't change since the last time we asked.
1638 if (!can_read) 1635 if (!can_read)
1639 return CompositorThreadOnly().main_thread_seems_unresponsive; 1636 return CompositorThreadOnly().main_thread_seems_unresponsive;
1640 1637
1641 queueing_time_estimator_state = seqlock_queueing_time_estimator_.data.state(); 1638 queueing_time_estimator_state = seqlock_queueing_time_estimator_.data.state();
1642 1639
1643 // If we fail to determine if the main thread is busy, assume whether or not 1640 // If we fail to determine if the main thread is busy, assume whether or not
1644 // it's busy hasn't change since the last time we asked. 1641 // it's busy hasn't change since the last time we asked.
1645 if (seqlock_queueing_time_estimator_.seqlock.ReadRetry(version)) 1642 if (seqlock_queueing_time_estimator_.seqlock.ReadRetry(version))
1646 return CompositorThreadOnly().main_thread_seems_unresponsive; 1643 return CompositorThreadOnly().main_thread_seems_unresponsive;
1647 1644
1648 QueueingTimeEstimator queueing_time_estimator(queueing_time_estimator_state); 1645 QueueingTimeEstimator queueing_time_estimator(queueing_time_estimator_state);
1649 1646
1650 estimated_queueing_time = 1647 estimated_queueing_time =
1651 queueing_time_estimator.EstimateQueueingTimeIncludingCurrentTask(now); 1648 queueing_time_estimator.EstimateQueueingTimeIncludingCurrentTask(now);
1652 1649
1653 bool main_thread_seems_unresponsive = 1650 bool main_thread_seems_unresponsive =
1654 estimated_queueing_time > main_thread_responsiveness_threshold_; 1651 estimated_queueing_time > main_thread_responsiveness_threshold;
1655 CompositorThreadOnly().main_thread_seems_unresponsive = 1652 CompositorThreadOnly().main_thread_seems_unresponsive =
1656 main_thread_seems_unresponsive; 1653 main_thread_seems_unresponsive;
1657 1654
1658 return main_thread_seems_unresponsive; 1655 return main_thread_seems_unresponsive;
1659 } 1656 }
1660 1657
1661 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) { 1658 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) {
1662 helper_.RegisterTimeDomain(time_domain); 1659 helper_.RegisterTimeDomain(time_domain);
1663 } 1660 }
1664 1661
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 case TimeDomainType::VIRTUAL: 1883 case TimeDomainType::VIRTUAL:
1887 return "virtual"; 1884 return "virtual";
1888 default: 1885 default:
1889 NOTREACHED(); 1886 NOTREACHED();
1890 return nullptr; 1887 return nullptr;
1891 } 1888 }
1892 } 1889 }
1893 1890
1894 } // namespace scheduler 1891 } // namespace scheduler
1895 } // namespace blink 1892 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698