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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h

Issue 2761503002: [scheduler] CPUTimeBudgetPool: Require a minimal level of budget to run (Closed)
Patch Set: Remove #include <*stream> Created 3 years, 9 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 | « no previous file | third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_
7 7
8 #include <unordered_set> 8 #include <unordered_set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 virtual void AsValueInto(base::trace_event::TracedValue* state, 77 virtual void AsValueInto(base::trace_event::TracedValue* state,
78 base::TimeTicks now) const = 0; 78 base::TimeTicks now) const = 0;
79 }; 79 };
80 80
81 // CPUTimeBudgetPool represents a collection of task queues which share a limit 81 // CPUTimeBudgetPool represents a collection of task queues which share a limit
82 // on total cpu time. 82 // on total cpu time.
83 class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool { 83 class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool {
84 public: 84 public:
85 CPUTimeBudgetPool(const char* name, 85 CPUTimeBudgetPool(const char* name,
86 BudgetPoolController* budget_pool_controller, 86 BudgetPoolController* budget_pool_controller,
87 base::TimeTicks now, 87 base::TimeTicks now);
88 base::Optional<base::TimeDelta> max_budget_level,
89 base::Optional<base::TimeDelta> max_throttling_duration);
90 88
91 ~CPUTimeBudgetPool(); 89 ~CPUTimeBudgetPool();
92 90
91 // Set max budget level, base::nullopt represent absence of max level.
92 // Max budget level prevents accumulating arbitrary large budgets when
93 // page is inactive for a very long time.
94 void SetMaxBudgetLevel(base::TimeTicks now,
95 base::Optional<base::TimeDelta> max_budget_level);
96
97 // Set max throttling duration, base::nullopt represents absense of it.
98 // Max throttling duration prevents page from being throttled for
99 // a very long period after a single long task.
100 void SetMaxThrottlingDelay(
101 base::TimeTicks now,
102 base::Optional<base::TimeDelta> max_throttling_delay);
103
104 // Set minimal budget level required to run a task. If budget pool was
105 // exhausted, it needs to accumulate at least |min_budget_to_run| time units
106 // to unblock and run tasks again. When unblocked, it still can run tasks
107 // when budget is positive but less than this level until being blocked
108 // until being blocked when budget reaches zero.
109 // This is needed for integration with WakeupBudgetPool to prevent a situation
110 // when wakeup happened but time budget pool allows only one task to run at
111 // the moment.
112 // It is recommended to use the same value for this and WakeupBudgetPool's
113 // wakeup window length.
114 // NOTE: This does not have an immediate effect and does not call
115 // BudgetPoolController::UnblockQueue.
116 void SetMinBudgetLevelToRun(base::TimeTicks now,
117 base::TimeDelta min_budget_level_to_run);
118
93 // Throttle task queues from this time budget pool if tasks are running 119 // Throttle task queues from this time budget pool if tasks are running
94 // for more than |cpu_percentage| per cent of wall time. 120 // for more than |cpu_percentage| per cent of wall time.
95 // This function does not affect internal time budget level. 121 // This function does not affect internal time budget level.
96 void SetTimeBudgetRecoveryRate(base::TimeTicks now, double cpu_percentage); 122 void SetTimeBudgetRecoveryRate(base::TimeTicks now, double cpu_percentage);
97 123
98 // Increase budget level by given value. This function DOES NOT unblock 124 // Increase budget level by given value. This function DOES NOT unblock
99 // queues even if they are allowed to run with increased budget level. 125 // queues even if they are allowed to run with increased budget level.
100 void GrantAdditionalBudget(base::TimeTicks now, base::TimeDelta budget_level); 126 void GrantAdditionalBudget(base::TimeTicks now, base::TimeDelta budget_level);
101 127
102 // Set callback which will be called every time when this budget pool 128 // Set callback which will be called every time when this budget pool
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 void EnforceBudgetLevelRestrictions(); 161 void EnforceBudgetLevelRestrictions();
136 162
137 const char* name_; // NOT OWNED 163 const char* name_; // NOT OWNED
138 164
139 BudgetPoolController* budget_pool_controller_; 165 BudgetPoolController* budget_pool_controller_;
140 166
141 // Max budget level which we can accrue. 167 // Max budget level which we can accrue.
142 // Tasks will be allowed to run for this time before being throttled 168 // Tasks will be allowed to run for this time before being throttled
143 // after a very long period of inactivity. 169 // after a very long period of inactivity.
144 base::Optional<base::TimeDelta> max_budget_level_; 170 base::Optional<base::TimeDelta> max_budget_level_;
145 // Max throttling duration places a lower limit on time budget level, 171 // Max throttling delay places a lower limit on time budget level,
146 // ensuring that one long task does not cause extremely long throttling. 172 // ensuring that one long task does not cause extremely long throttling.
147 // Note that this is not the guarantee that every task will run 173 // Note that this is not a guarantee that every task will run
148 // after desired run time + max throttling duration, but a guarantee 174 // after desired run time + max throttling duration, but a guarantee
149 // that at least one task will be run every max_throttling_duration. 175 // that at least one task will be run every max_throttling_delay.
150 base::Optional<base::TimeDelta> max_throttling_duration_; 176 base::Optional<base::TimeDelta> max_throttling_delay_;
177 // See CPUTimeBudgetPool::SetMinBudgetLevelToRun.
178 base::TimeDelta min_budget_level_to_run_;
151 179
152 base::TimeDelta current_budget_level_; 180 base::TimeDelta current_budget_level_;
153 base::TimeTicks last_checkpoint_; 181 base::TimeTicks last_checkpoint_;
154 double cpu_percentage_; 182 double cpu_percentage_;
155 bool is_enabled_; 183 bool is_enabled_;
156 184
157 std::unordered_set<TaskQueue*> associated_task_queues_; 185 std::unordered_set<TaskQueue*> associated_task_queues_;
158 186
159 base::Callback<void(base::TimeDelta)> reporting_callback_; 187 base::Callback<void(base::TimeDelta)> reporting_callback_;
160 188
161 DISALLOW_COPY_AND_ASSIGN(CPUTimeBudgetPool); 189 DISALLOW_COPY_AND_ASSIGN(CPUTimeBudgetPool);
162 }; 190 };
163 191
164 } // namespace scheduler 192 } // namespace scheduler
165 } // namespace blink 193 } // namespace blink
166 194
167 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ 195 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698