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

Unified Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 1950913005: scheduler: Only prioritize rAF if it is fast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/scheduler/renderer/renderer_scheduler_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/renderer/renderer_scheduler_impl.cc
diff --git a/components/scheduler/renderer/renderer_scheduler_impl.cc b/components/scheduler/renderer/renderer_scheduler_impl.cc
index 306c45cc0a783df4c849963c17ec761c1dc2a490..cdb78d8327ff08c7e4782b3daaefa916496b66a7 100644
--- a/components/scheduler/renderer/renderer_scheduler_impl.cc
+++ b/components/scheduler/renderer/renderer_scheduler_impl.cc
@@ -29,7 +29,10 @@ const int kTimerTaskEstimationSampleCount = 1000;
const double kTimerTaskEstimationPercentile = 99;
const int kShortIdlePeriodDurationSampleCount = 10;
const double kShortIdlePeriodDurationPercentile = 50;
-}
+// Amount of idle time left in a frame (as a ratio of the vsync interval) above
+// which main thread compositing can be considered fast.
+const double kFastCompositingIdleTimeThreshold = .2;
+} // namespace
RendererSchedulerImpl::RendererSchedulerImpl(
scoped_refptr<SchedulerTqmDelegate> main_task_runner)
@@ -657,6 +660,14 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) {
MainThreadOnly().current_policy_expiration_time = base::TimeTicks();
}
+ // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely
+ // slow, because that can cause starvation in other task sources.
+ bool main_thread_compositing_is_fast =
+ MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration(
+ MainThreadOnly().compositor_frame_interval) >
+ MainThreadOnly().compositor_frame_interval *
+ kFastCompositingIdleTimeThreshold;
+
Policy new_policy;
ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN;
switch (use_case) {
@@ -675,7 +686,9 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) {
break;
case UseCase::SYNCHRONIZED_GESTURE:
- new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
+ new_policy.compositor_queue_policy.priority =
+ main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY
+ : TaskQueue::NORMAL_PRIORITY;
if (touchstart_expected_soon) {
expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
} else {
@@ -688,7 +701,9 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) {
// things we should be prioritizing, so we don't attempt to block
// expensive tasks because we don't know whether they were integral to the
// page's functionality or not.
- new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
+ new_policy.compositor_queue_policy.priority =
+ main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY
+ : TaskQueue::NORMAL_PRIORITY;
break;
case UseCase::TOUCHSTART:
« no previous file with comments | « no previous file | components/scheduler/renderer/renderer_scheduler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698