Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 run tasks again. | |
| 107 // It still can run tasks when budget is positive but less than this level. | |
|
alex clarke (OOO till 29th)
2017/03/20 09:03:03
This sentence seems to state the opposite of the p
altimin
2017/03/20 15:21:08
Done.
| |
| 108 // This is needed for integration with WakeupBudgetPool to prevent a situation | |
| 109 // when wakeup happened but time budget pool allows only one task to run at | |
| 110 // the moment. | |
| 111 // It is recommended to use the same value for this and WakeupBudgetPool's | |
| 112 // wakeup window length. | |
| 113 void SetMinBudgetLevelToRun(base::TimeTicks now, | |
| 114 base::TimeDelta min_budget_level_to_run); | |
| 115 | |
| 93 // Throttle task queues from this time budget pool if tasks are running | 116 // Throttle task queues from this time budget pool if tasks are running |
| 94 // for more than |cpu_percentage| per cent of wall time. | 117 // for more than |cpu_percentage| per cent of wall time. |
| 95 // This function does not affect internal time budget level. | 118 // This function does not affect internal time budget level. |
| 96 void SetTimeBudgetRecoveryRate(base::TimeTicks now, double cpu_percentage); | 119 void SetTimeBudgetRecoveryRate(base::TimeTicks now, double cpu_percentage); |
| 97 | 120 |
| 98 // Increase budget level by given value. This function DOES NOT unblock | 121 // Increase budget level by given value. This function DOES NOT unblock |
| 99 // queues even if they are allowed to run with increased budget level. | 122 // queues even if they are allowed to run with increased budget level. |
| 100 void GrantAdditionalBudget(base::TimeTicks now, base::TimeDelta budget_level); | 123 void GrantAdditionalBudget(base::TimeTicks now, base::TimeDelta budget_level); |
| 101 | 124 |
| 102 // Set callback which will be called every time when this budget pool | 125 // Set callback which will be called every time when this budget pool |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 void EnforceBudgetLevelRestrictions(); | 158 void EnforceBudgetLevelRestrictions(); |
| 136 | 159 |
| 137 const char* name_; // NOT OWNED | 160 const char* name_; // NOT OWNED |
| 138 | 161 |
| 139 BudgetPoolController* budget_pool_controller_; | 162 BudgetPoolController* budget_pool_controller_; |
| 140 | 163 |
| 141 // Max budget level which we can accrue. | 164 // Max budget level which we can accrue. |
| 142 // Tasks will be allowed to run for this time before being throttled | 165 // Tasks will be allowed to run for this time before being throttled |
| 143 // after a very long period of inactivity. | 166 // after a very long period of inactivity. |
| 144 base::Optional<base::TimeDelta> max_budget_level_; | 167 base::Optional<base::TimeDelta> max_budget_level_; |
| 145 // Max throttling duration places a lower limit on time budget level, | 168 // Max throttling delay places a lower limit on time budget level, |
| 146 // ensuring that one long task does not cause extremely long throttling. | 169 // ensuring that one long task does not cause extremely long throttling. |
| 147 // Note that this is not the guarantee that every task will run | 170 // Note that this is not the guarantee that every task will run |
|
alex clarke (OOO till 29th)
2017/03/20 09:03:03
... is not _a_ guarantee that ...
altimin
2017/03/20 15:21:08
Done.
| |
| 148 // after desired run time + max throttling duration, but a guarantee | 171 // after desired run time + max throttling duration, but a guarantee |
| 149 // that at least one task will be run every max_throttling_duration. | 172 // that at least one task will be run every max_throttling_delay. |
| 150 base::Optional<base::TimeDelta> max_throttling_duration_; | 173 base::Optional<base::TimeDelta> max_throttling_delay_; |
| 174 // Minimal budget required to be accumulated after queue is blocked | |
|
alex clarke (OOO till 29th)
2017/03/20 09:03:03
Could you please reword? I found this sentence con
altimin
2017/03/20 15:21:08
Done.
| |
| 175 // to prevent queue from being immediately blocked after one small task. | |
| 176 base::TimeDelta min_budget_level_to_run_; | |
| 151 | 177 |
| 152 base::TimeDelta current_budget_level_; | 178 base::TimeDelta current_budget_level_; |
| 153 base::TimeTicks last_checkpoint_; | 179 base::TimeTicks last_checkpoint_; |
| 154 double cpu_percentage_; | 180 double cpu_percentage_; |
| 155 bool is_enabled_; | 181 bool is_enabled_; |
| 156 | 182 |
| 157 std::unordered_set<TaskQueue*> associated_task_queues_; | 183 std::unordered_set<TaskQueue*> associated_task_queues_; |
| 158 | 184 |
| 159 base::Callback<void(base::TimeDelta)> reporting_callback_; | 185 base::Callback<void(base::TimeDelta)> reporting_callback_; |
| 160 | 186 |
| 161 DISALLOW_COPY_AND_ASSIGN(CPUTimeBudgetPool); | 187 DISALLOW_COPY_AND_ASSIGN(CPUTimeBudgetPool); |
| 162 }; | 188 }; |
| 163 | 189 |
| 164 } // namespace scheduler | 190 } // namespace scheduler |
| 165 } // namespace blink | 191 } // namespace blink |
| 166 | 192 |
| 167 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ | 193 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ |
| OLD | NEW |