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

Side by Side Diff: cc/resource_update_controller.cc

Issue 11347019: cc: Maximize pending updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/resource_update_controller.h ('k') | cc/resource_update_controller_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/resource_update_controller.h" 7 #include "cc/resource_update_controller.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/prioritized_texture.h" 10 #include "cc/prioritized_texture.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 { 88 {
89 m_timeLimit = timeLimit; 89 m_timeLimit = timeLimit;
90 90
91 // Update already in progress. 91 // Update already in progress.
92 if (m_taskPosted) 92 if (m_taskPosted)
93 return; 93 return;
94 94
95 // Call updateMoreTexturesNow() directly unless it's the first update 95 // Call updateMoreTexturesNow() directly unless it's the first update
96 // attempt. This ensures that we empty the update queue in a finite 96 // attempt. This ensures that we empty the update queue in a finite
97 // amount of time. 97 // amount of time.
98 if (m_firstUpdateAttempt) { 98 if (!m_firstUpdateAttempt)
99 // Post a 0-delay task when no updates were left. When it runs, 99 updateMoreTexturesNow();
100 // readyToFinalizeTextureUpdates() will be called.
101 if (!updateMoreTexturesIfEnoughTimeRemaining()) {
102 m_taskPosted = true;
103 m_thread->postTask(base::Bind(&ResourceUpdateController::onTimerFire d,
104 m_weakFactory.GetWeakPtr()));
105 }
106 100
107 m_firstUpdateAttempt = false; 101 // Post a 0-delay task when no updates were left. When it runs,
108 } else 102 // readyToFinalizeTextureUpdates() will be called.
109 updateMoreTexturesNow(); 103 if (!updateMoreTexturesIfEnoughTimeRemaining()) {
104 m_taskPosted = true;
105 m_thread->postTask(
106 base::Bind(&ResourceUpdateController::onTimerFired,
107 m_weakFactory.GetWeakPtr()));
108 }
109
110 m_firstUpdateAttempt = false;
110 } 111 }
111 112
112 void ResourceUpdateController::discardUploadsToEvictedResources() 113 void ResourceUpdateController::discardUploadsToEvictedResources()
113 { 114 {
114 m_queue->clearUploadsToEvictedResources(); 115 m_queue->clearUploadsToEvictedResources();
115 } 116 }
116 117
117 void ResourceUpdateController::updateTexture(ResourceUpdate update) 118 void ResourceUpdateController::updateTexture(ResourceUpdate update)
118 { 119 {
119 if (update.picture) { 120 if (update.picture) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 size_t ResourceUpdateController::updateMoreTexturesSize() const 234 size_t ResourceUpdateController::updateMoreTexturesSize() const
234 { 235 {
235 return m_textureUpdatesPerTick; 236 return m_textureUpdatesPerTick;
236 } 237 }
237 238
238 size_t ResourceUpdateController::maxBlockingUpdates() const 239 size_t ResourceUpdateController::maxBlockingUpdates() const
239 { 240 {
240 return updateMoreTexturesSize() * maxBlockingUpdateIntervals; 241 return updateMoreTexturesSize() * maxBlockingUpdateIntervals;
241 } 242 }
242 243
244 base::TimeDelta ResourceUpdateController::pendingUpdateTime() const
245 {
246 base::TimeDelta updateOneResourceTime =
247 updateMoreTexturesTime() / updateMoreTexturesSize();
248 return updateOneResourceTime * m_resourceProvider->numBlockingUploads();
249 }
250
243 bool ResourceUpdateController::updateMoreTexturesIfEnoughTimeRemaining() 251 bool ResourceUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
244 { 252 {
245 // Blocking uploads will increase when we're too aggressive in our upload 253 while (m_resourceProvider->numBlockingUploads() < maxBlockingUpdates()) {
246 // time estimate. We use a different timeout here to prevent unnecessary 254 if (!m_queue->fullUploadSize())
247 // amounts of idle time when blocking uploads have reached the max. 255 return false;
248 if (m_resourceProvider->numBlockingUploads() >= maxBlockingUpdates()) { 256
249 m_taskPosted = true; 257 if (!m_timeLimit.is_null()) {
250 m_thread->postDelayedTask(base::Bind(&ResourceUpdateController::onTimerF ired, 258 // Estimated completion time of all pending updates.
251 m_weakFactory.GetWeakPtr()), 259 base::TimeTicks completionTime = this->now() + pendingUpdateTime();
252 uploaderBusyTickRate * 1000); 260
253 return true; 261 // Time remaining based on current completion estimate.
262 base::TimeDelta timeRemaining = m_timeLimit - completionTime;
263
264 if (timeRemaining < updateMoreTexturesTime())
265 return true;
266 }
267
268 updateMoreTexturesNow();
254 } 269 }
255 270
256 if (!m_queue->fullUploadSize()) 271 m_taskPosted = true;
257 return false; 272 m_thread->postDelayedTask(
258 273 base::Bind(&ResourceUpdateController::onTimerFired,
259 bool hasTimeRemaining = m_timeLimit.is_null() || 274 m_weakFactory.GetWeakPtr()),
260 this->now() < m_timeLimit - updateMoreTexturesTime(); 275 uploaderBusyTickRate * 1000);
261 if (hasTimeRemaining)
262 updateMoreTexturesNow();
263
264 return true; 276 return true;
265 } 277 }
266 278
267 void ResourceUpdateController::updateMoreTexturesNow() 279 void ResourceUpdateController::updateMoreTexturesNow()
268 { 280 {
269 size_t uploads = std::min( 281 size_t uploads = std::min(
270 m_queue->fullUploadSize(), updateMoreTexturesSize()); 282 m_queue->fullUploadSize(), updateMoreTexturesSize());
271 m_taskPosted = true;
272 m_thread->postDelayedTask(base::Bind(&ResourceUpdateController::onTimerFired ,
273 m_weakFactory.GetWeakPtr()),
274 updateMoreTexturesTime().InSecondsF() / updateMore TexturesSize() * uploads * 1000);
275 283
276 if (!uploads) 284 if (!uploads)
277 return; 285 return;
278 286
279 while (m_queue->fullUploadSize() && uploads--) 287 while (m_queue->fullUploadSize() && uploads--)
280 updateTexture(m_queue->takeFirstFullUpload()); 288 updateTexture(m_queue->takeFirstFullUpload());
281 289
282 m_resourceProvider->flushUploads(); 290 m_resourceProvider->flushUploads();
283 } 291 }
284 292
285 } // namespace cc 293 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_update_controller.h ('k') | cc/resource_update_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698