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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc

Issue 2505693002: [scheduler] Initial budget for time-based throttling. (Closed)
Patch Set: Renamed SetTimeBudget to SetTimeBudgetRecoveryRate Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/task_queue_throttler.h" 5 #include "platform/scheduler/renderer/task_queue_throttler.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 : name_(name), 74 : name_(name),
75 task_queue_throttler_(task_queue_throttler), 75 task_queue_throttler_(task_queue_throttler),
76 max_budget_level_(max_budget_level), 76 max_budget_level_(max_budget_level),
77 max_throttling_duration_(max_throttling_duration), 77 max_throttling_duration_(max_throttling_duration),
78 last_checkpoint_(now), 78 last_checkpoint_(now),
79 cpu_percentage_(1), 79 cpu_percentage_(1),
80 is_enabled_(true) {} 80 is_enabled_(true) {}
81 81
82 TaskQueueThrottler::TimeBudgetPool::~TimeBudgetPool() {} 82 TaskQueueThrottler::TimeBudgetPool::~TimeBudgetPool() {}
83 83
84 void TaskQueueThrottler::TimeBudgetPool::SetTimeBudget(base::TimeTicks now, 84 void TaskQueueThrottler::TimeBudgetPool::SetTimeBudgetRecoveryRate(
85 double cpu_percentage) { 85 base::TimeTicks now,
86 double cpu_percentage) {
86 Advance(now); 87 Advance(now);
87 cpu_percentage_ = cpu_percentage; 88 cpu_percentage_ = cpu_percentage;
88 EnforceBudgetLevelRestrictions(); 89 EnforceBudgetLevelRestrictions();
89 } 90 }
90 91
91 void TaskQueueThrottler::TimeBudgetPool::AddQueue(base::TimeTicks now, 92 void TaskQueueThrottler::TimeBudgetPool::AddQueue(base::TimeTicks now,
92 TaskQueue* queue) { 93 TaskQueue* queue) {
93 std::pair<TaskQueueMap::iterator, bool> insert_result = 94 std::pair<TaskQueueMap::iterator, bool> insert_result =
94 task_queue_throttler_->queue_details_.insert( 95 task_queue_throttler_->queue_details_.insert(
95 std::make_pair(queue, Metadata(0, queue->IsQueueEnabled()))); 96 std::make_pair(queue, Metadata(0, queue->IsQueueEnabled())));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 149 }
149 150
150 // TODO(altimin): We need to disable TimeBudgetQueues here or they will 151 // TODO(altimin): We need to disable TimeBudgetQueues here or they will
151 // regenerate extra time budget when they are disabled. 152 // regenerate extra time budget when they are disabled.
152 } 153 }
153 154
154 bool TaskQueueThrottler::TimeBudgetPool::IsThrottlingEnabled() const { 155 bool TaskQueueThrottler::TimeBudgetPool::IsThrottlingEnabled() const {
155 return is_enabled_; 156 return is_enabled_;
156 } 157 }
157 158
159 void TaskQueueThrottler::TimeBudgetPool::GrantAdditionalBudget(
160 base::TimeTicks now,
161 base::TimeDelta budget_level) {
162 Advance(now);
163 current_budget_level_ += budget_level;
164 EnforceBudgetLevelRestrictions();
165 }
166
158 void TaskQueueThrottler::TimeBudgetPool::SetReportingCallback( 167 void TaskQueueThrottler::TimeBudgetPool::SetReportingCallback(
159 base::Callback<void(base::TimeDelta)> reporting_callback) { 168 base::Callback<void(base::TimeDelta)> reporting_callback) {
160 reporting_callback_ = reporting_callback; 169 reporting_callback_ = reporting_callback;
161 } 170 }
162 171
163 void TaskQueueThrottler::TimeBudgetPool::Close() { 172 void TaskQueueThrottler::TimeBudgetPool::Close() {
164 DCHECK_EQ(0u, associated_task_queues_.size()); 173 DCHECK_EQ(0u, associated_task_queues_.size());
165 174
166 task_queue_throttler_->time_budget_pools_.erase(this); 175 task_queue_throttler_->time_budget_pools_.erase(this);
167 } 176 }
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 635
627 queue->SetQueueEnabled(false); 636 queue->SetQueueEnabled(false);
628 queue->SetTimeDomain(time_domain_.get()); 637 queue->SetTimeDomain(time_domain_.get());
629 MaybeSchedulePumpQueue(FROM_HERE, lazy_now.Now(), queue, 638 MaybeSchedulePumpQueue(FROM_HERE, lazy_now.Now(), queue,
630 GetNextAllowedRunTime(lazy_now.Now(), queue)); 639 GetNextAllowedRunTime(lazy_now.Now(), queue));
631 } 640 }
632 } 641 }
633 642
634 } // namespace scheduler 643 } // namespace scheduler
635 } // namespace blink 644 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698