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

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

Issue 2017763003: Suspend more task queues for background renderers (experimental) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Sami's review Created 4 years, 6 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 | « components/scheduler/renderer/renderer_scheduler_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 idle_time_estimator(compositor_task_runner, 112 idle_time_estimator(compositor_task_runner,
113 time_source, 113 time_source,
114 kShortIdlePeriodDurationSampleCount, 114 kShortIdlePeriodDurationSampleCount,
115 kShortIdlePeriodDurationPercentile), 115 kShortIdlePeriodDurationPercentile),
116 current_use_case(UseCase::NONE), 116 current_use_case(UseCase::NONE),
117 timer_queue_suspend_count(0), 117 timer_queue_suspend_count(0),
118 navigation_task_expected_count(0), 118 navigation_task_expected_count(0),
119 expensive_task_policy(ExpensiveTaskPolicy::RUN), 119 expensive_task_policy(ExpensiveTaskPolicy::RUN),
120 renderer_hidden(false), 120 renderer_hidden(false),
121 renderer_backgrounded(false), 121 renderer_backgrounded(false),
122 renderer_suspended(false),
122 timer_queue_suspension_when_backgrounded_enabled(false), 123 timer_queue_suspension_when_backgrounded_enabled(false),
123 timer_queue_suspended_when_backgrounded(false), 124 timer_queue_suspended_when_backgrounded(false),
124 was_shutdown(false), 125 was_shutdown(false),
125 loading_tasks_seem_expensive(false), 126 loading_tasks_seem_expensive(false),
126 timer_tasks_seem_expensive(false), 127 timer_tasks_seem_expensive(false),
127 touchstart_expected_soon(false), 128 touchstart_expected_soon(false),
128 have_seen_a_begin_main_frame(false), 129 have_seen_a_begin_main_frame(false),
129 have_reported_blocking_intervention_in_current_policy(false), 130 have_reported_blocking_intervention_in_current_policy(false),
130 have_reported_blocking_intervention_since_navigation(false), 131 have_reported_blocking_intervention_since_navigation(false),
131 has_visible_render_widget_with_touch_handler(false), 132 has_visible_render_widget_with_touch_handler(false),
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 break; 826 break;
826 } 827 }
827 828
828 MainThreadOnly().expensive_task_policy = expensive_task_policy; 829 MainThreadOnly().expensive_task_policy = expensive_task_policy;
829 830
830 if (MainThreadOnly().timer_queue_suspend_count != 0 || 831 if (MainThreadOnly().timer_queue_suspend_count != 0 ||
831 MainThreadOnly().timer_queue_suspended_when_backgrounded) { 832 MainThreadOnly().timer_queue_suspended_when_backgrounded) {
832 new_policy.timer_queue_policy.is_enabled = false; 833 new_policy.timer_queue_policy.is_enabled = false;
833 } 834 }
834 835
836 if (MainThreadOnly().renderer_suspended) {
837 new_policy.loading_queue_policy.is_enabled = false;
838 DCHECK(!new_policy.timer_queue_policy.is_enabled);
839 }
840
835 // Tracing is done before the early out check, because it's quite possible we 841 // Tracing is done before the early out check, because it's quite possible we
836 // will otherwise miss this information in traces. 842 // will otherwise miss this information in traces.
837 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 843 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
838 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", 844 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler",
839 this, AsValueLocked(now)); 845 this, AsValueLocked(now));
840 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", 846 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case",
841 use_case); 847 use_case);
842 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 848 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
843 "touchstart_expected_soon", 849 "touchstart_expected_soon",
844 MainThreadOnly().touchstart_expected_soon); 850 MainThreadOnly().touchstart_expected_soon);
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 base::TimeDelta::FromMilliseconds( 1213 base::TimeDelta::FromMilliseconds(
1208 kIdlePeriodStarvationThresholdMillis); 1214 kIdlePeriodStarvationThresholdMillis);
1209 } 1215 }
1210 1216
1211 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { 1217 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() {
1212 DCHECK(MainThreadOnly().renderer_backgrounded); 1218 DCHECK(MainThreadOnly().renderer_backgrounded);
1213 if (MainThreadOnly().timer_queue_suspended_when_backgrounded) 1219 if (MainThreadOnly().timer_queue_suspended_when_backgrounded)
1214 return; 1220 return;
1215 1221
1216 MainThreadOnly().timer_queue_suspended_when_backgrounded = true; 1222 MainThreadOnly().timer_queue_suspended_when_backgrounded = true;
1223 MainThreadOnly().renderer_suspended = true;
Sami 2016/05/31 10:11:21 I guess this is just for testing, but ultimately y
hajimehoshi 2016/05/31 11:10:07 Ah, this was my mistake: Setting this variable sho
1217 ForceUpdatePolicy(); 1224 ForceUpdatePolicy();
1218 } 1225 }
1219 1226
1220 void RendererSchedulerImpl::ResumeTimerQueueWhenForegrounded() { 1227 void RendererSchedulerImpl::ResumeTimerQueueWhenForegrounded() {
1221 DCHECK(!MainThreadOnly().renderer_backgrounded); 1228 DCHECK(!MainThreadOnly().renderer_backgrounded);
1222 if (!MainThreadOnly().timer_queue_suspended_when_backgrounded) 1229 if (!MainThreadOnly().timer_queue_suspended_when_backgrounded)
1223 return; 1230 return;
1224 1231
1225 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; 1232 MainThreadOnly().timer_queue_suspended_when_backgrounded = false;
1233 MainThreadOnly().renderer_suspended = false;
1226 ForceUpdatePolicy(); 1234 ForceUpdatePolicy();
1227 } 1235 }
1228 1236
1229 void RendererSchedulerImpl::ResetForNavigationLocked() { 1237 void RendererSchedulerImpl::ResetForNavigationLocked() {
1230 helper_.CheckOnValidThread(); 1238 helper_.CheckOnValidThread();
1231 any_thread_lock_.AssertAcquired(); 1239 any_thread_lock_.AssertAcquired();
1232 AnyThread().user_model.Reset(helper_.scheduler_tqm_delegate()->NowTicks()); 1240 AnyThread().user_model.Reset(helper_.scheduler_tqm_delegate()->NowTicks());
1233 AnyThread().have_seen_touchstart = false; 1241 AnyThread().have_seen_touchstart = false;
1234 MainThreadOnly().loading_task_cost_estimator.Clear(); 1242 MainThreadOnly().loading_task_cost_estimator.Clear();
1235 MainThreadOnly().timer_task_cost_estimator.Clear(); 1243 MainThreadOnly().timer_task_cost_estimator.Clear();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 BroadcastConsoleWarning( 1332 BroadcastConsoleWarning(
1325 "Blink deferred a task in order to make scrolling smoother. " 1333 "Blink deferred a task in order to make scrolling smoother. "
1326 "Your timer and network tasks should take less than 50ms to run " 1334 "Your timer and network tasks should take less than 50ms to run "
1327 "to avoid this. Please see " 1335 "to avoid this. Please see "
1328 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" 1336 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail"
1329 " and https://crbug.com/574343#c40 for more information."); 1337 " and https://crbug.com/574343#c40 for more information.");
1330 } 1338 }
1331 } 1339 }
1332 1340
1333 } // namespace scheduler 1341 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698