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

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: Created 4 years 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 base::Bind(&RendererSchedulerImpl::UpdatePolicy, 101 base::Bind(&RendererSchedulerImpl::UpdatePolicy,
105 base::Unretained(this)), 102 base::Unretained(this)),
106 helper_.ControlTaskRunner()), 103 helper_.ControlTaskRunner()),
107 seqlock_queueing_time_estimator_( 104 seqlock_queueing_time_estimator_(
108 QueueingTimeEstimator(this, base::TimeDelta::FromSeconds(1))), 105 QueueingTimeEstimator(this, base::TimeDelta::FromSeconds(1))),
109 main_thread_only_(this, 106 main_thread_only_(this,
110 compositor_task_runner_, 107 compositor_task_runner_,
111 helper_.scheduler_tqm_delegate().get(), 108 helper_.scheduler_tqm_delegate().get(),
112 helper_.scheduler_tqm_delegate()->NowTicks()), 109 helper_.scheduler_tqm_delegate()->NowTicks()),
113 policy_may_need_update_(&any_thread_lock_), 110 policy_may_need_update_(&any_thread_lock_),
114 main_thread_responsiveness_threshold_(kMainThreadResponsivenessThreshold),
115 weak_factory_(this) { 111 weak_factory_(this) {
116 task_queue_throttler_.reset( 112 task_queue_throttler_.reset(
117 new TaskQueueThrottler(this, "renderer.scheduler")); 113 new TaskQueueThrottler(this, "renderer.scheduler"));
118 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, 114 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy,
119 weak_factory_.GetWeakPtr()); 115 weak_factory_.GetWeakPtr());
120 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( 116 end_renderer_hidden_idle_period_closure_.Reset(base::Bind(
121 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); 117 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr()));
122 118
123 suspend_timers_when_backgrounded_closure_.Reset( 119 suspend_timers_when_backgrounded_closure_.Reset(
124 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, 120 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded,
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 default_loading_task_runner_->SetBlameContext(blame_context); 1595 default_loading_task_runner_->SetBlameContext(blame_context);
1600 default_timer_task_runner_->SetBlameContext(blame_context); 1596 default_timer_task_runner_->SetBlameContext(blame_context);
1601 compositor_task_runner_->SetBlameContext(blame_context); 1597 compositor_task_runner_->SetBlameContext(blame_context);
1602 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); 1598 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context);
1603 } 1599 }
1604 1600
1605 void RendererSchedulerImpl::SetRAILModeObserver(RAILModeObserver* observer) { 1601 void RendererSchedulerImpl::SetRAILModeObserver(RAILModeObserver* observer) {
1606 MainThreadOnly().rail_mode_observer = observer; 1602 MainThreadOnly().rail_mode_observer = observer;
1607 } 1603 }
1608 1604
1609 bool RendererSchedulerImpl::MainThreadSeemsUnresponsive() { 1605 bool RendererSchedulerImpl::MainThreadSeemsUnresponsive(
1606 base::TimeDelta main_thread_responsiveness_threshold) {
1610 base::TimeTicks now = tick_clock()->NowTicks(); 1607 base::TimeTicks now = tick_clock()->NowTicks();
1611 base::TimeDelta estimated_queueing_time; 1608 base::TimeDelta estimated_queueing_time;
1612 1609
1613 bool can_read = false; 1610 bool can_read = false;
1614 QueueingTimeEstimator::State queueing_time_estimator_state; 1611 QueueingTimeEstimator::State queueing_time_estimator_state;
1615 1612
1616 base::subtle::Atomic32 version; 1613 base::subtle::Atomic32 version;
1617 seqlock_queueing_time_estimator_.seqlock.TryRead(&can_read, &version); 1614 seqlock_queueing_time_estimator_.seqlock.TryRead(&can_read, &version);
1618 1615
1619 // If we fail to determine if the main thread is busy, assume whether or not 1616 // If we fail to determine if the main thread is busy, assume whether or not
1620 // it's busy hasn't change since the last time we asked. 1617 // it's busy hasn't change since the last time we asked.
1621 if (!can_read) 1618 if (!can_read)
1622 return CompositorThreadOnly().main_thread_seems_unresponsive; 1619 return CompositorThreadOnly().main_thread_seems_unresponsive;
1623 1620
1624 queueing_time_estimator_state = seqlock_queueing_time_estimator_.data.state(); 1621 queueing_time_estimator_state = seqlock_queueing_time_estimator_.data.state();
1625 1622
1626 // If we fail to determine if the main thread is busy, assume whether or not 1623 // If we fail to determine if the main thread is busy, assume whether or not
1627 // it's busy hasn't change since the last time we asked. 1624 // it's busy hasn't change since the last time we asked.
1628 if (seqlock_queueing_time_estimator_.seqlock.ReadRetry(version)) 1625 if (seqlock_queueing_time_estimator_.seqlock.ReadRetry(version))
1629 return CompositorThreadOnly().main_thread_seems_unresponsive; 1626 return CompositorThreadOnly().main_thread_seems_unresponsive;
1630 1627
1631 QueueingTimeEstimator queueing_time_estimator(queueing_time_estimator_state); 1628 QueueingTimeEstimator queueing_time_estimator(queueing_time_estimator_state);
1632 1629
1633 estimated_queueing_time = 1630 estimated_queueing_time =
1634 queueing_time_estimator.EstimateQueueingTimeIncludingCurrentTask(now); 1631 queueing_time_estimator.EstimateQueueingTimeIncludingCurrentTask(now);
1635 1632
1636 bool main_thread_seems_unresponsive = 1633 bool main_thread_seems_unresponsive =
1637 estimated_queueing_time > main_thread_responsiveness_threshold_; 1634 estimated_queueing_time > main_thread_responsiveness_threshold;
1638 CompositorThreadOnly().main_thread_seems_unresponsive = 1635 CompositorThreadOnly().main_thread_seems_unresponsive =
1639 main_thread_seems_unresponsive; 1636 main_thread_seems_unresponsive;
1640 1637
1641 return main_thread_seems_unresponsive; 1638 return main_thread_seems_unresponsive;
1642 } 1639 }
1643 1640
1644 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) { 1641 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) {
1645 helper_.RegisterTimeDomain(time_domain); 1642 helper_.RegisterTimeDomain(time_domain);
1646 } 1643 }
1647 1644
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 case TimeDomainType::VIRTUAL: 1866 case TimeDomainType::VIRTUAL:
1870 return "virtual"; 1867 return "virtual";
1871 default: 1868 default:
1872 NOTREACHED(); 1869 NOTREACHED();
1873 return nullptr; 1870 return nullptr;
1874 } 1871 }
1875 } 1872 }
1876 1873
1877 } // namespace scheduler 1874 } // namespace scheduler
1878 } // namespace blink 1875 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698