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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resource_update_controller.h ('k') | cc/resource_update_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resource_update_controller.cc
diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc
index 10c3b4db849bd602d1d50685618ea512b775b813..f2bab9d1e0098da923dc4bab273033a273b6af0f 100644
--- a/cc/resource_update_controller.cc
+++ b/cc/resource_update_controller.cc
@@ -95,18 +95,19 @@ void ResourceUpdateController::performMoreUpdates(
// Call updateMoreTexturesNow() directly unless it's the first update
// attempt. This ensures that we empty the update queue in a finite
// amount of time.
- if (m_firstUpdateAttempt) {
- // Post a 0-delay task when no updates were left. When it runs,
- // readyToFinalizeTextureUpdates() will be called.
- if (!updateMoreTexturesIfEnoughTimeRemaining()) {
- m_taskPosted = true;
- m_thread->postTask(base::Bind(&ResourceUpdateController::onTimerFired,
- m_weakFactory.GetWeakPtr()));
- }
-
- m_firstUpdateAttempt = false;
- } else
+ if (!m_firstUpdateAttempt)
updateMoreTexturesNow();
+
+ // Post a 0-delay task when no updates were left. When it runs,
+ // readyToFinalizeTextureUpdates() will be called.
+ if (!updateMoreTexturesIfEnoughTimeRemaining()) {
+ m_taskPosted = true;
+ m_thread->postTask(
+ base::Bind(&ResourceUpdateController::onTimerFired,
+ m_weakFactory.GetWeakPtr()));
+ }
+
+ m_firstUpdateAttempt = false;
}
void ResourceUpdateController::discardUploadsToEvictedResources()
@@ -240,27 +241,38 @@ size_t ResourceUpdateController::maxBlockingUpdates() const
return updateMoreTexturesSize() * maxBlockingUpdateIntervals;
}
+base::TimeDelta ResourceUpdateController::pendingUpdateTime() const
+{
+ base::TimeDelta updateOneResourceTime =
+ updateMoreTexturesTime() / updateMoreTexturesSize();
+ return updateOneResourceTime * m_resourceProvider->numBlockingUploads();
+}
+
bool ResourceUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
{
- // Blocking uploads will increase when we're too aggressive in our upload
- // time estimate. We use a different timeout here to prevent unnecessary
- // amounts of idle time when blocking uploads have reached the max.
- if (m_resourceProvider->numBlockingUploads() >= maxBlockingUpdates()) {
- m_taskPosted = true;
- m_thread->postDelayedTask(base::Bind(&ResourceUpdateController::onTimerFired,
- m_weakFactory.GetWeakPtr()),
- uploaderBusyTickRate * 1000);
- return true;
- }
+ while (m_resourceProvider->numBlockingUploads() < maxBlockingUpdates()) {
+ if (!m_queue->fullUploadSize())
+ return false;
+
+ if (!m_timeLimit.is_null()) {
+ // Estimated completion time of all pending updates.
+ base::TimeTicks completionTime = this->now() + pendingUpdateTime();
+
+ // Time remaining based on current completion estimate.
+ base::TimeDelta timeRemaining = m_timeLimit - completionTime;
- if (!m_queue->fullUploadSize())
- return false;
+ if (timeRemaining < updateMoreTexturesTime())
+ return true;
+ }
- bool hasTimeRemaining = m_timeLimit.is_null() ||
- this->now() < m_timeLimit - updateMoreTexturesTime();
- if (hasTimeRemaining)
updateMoreTexturesNow();
+ }
+ m_taskPosted = true;
+ m_thread->postDelayedTask(
+ base::Bind(&ResourceUpdateController::onTimerFired,
+ m_weakFactory.GetWeakPtr()),
+ uploaderBusyTickRate * 1000);
return true;
}
@@ -268,10 +280,6 @@ void ResourceUpdateController::updateMoreTexturesNow()
{
size_t uploads = std::min(
m_queue->fullUploadSize(), updateMoreTexturesSize());
- m_taskPosted = true;
- m_thread->postDelayedTask(base::Bind(&ResourceUpdateController::onTimerFired,
- m_weakFactory.GetWeakPtr()),
- updateMoreTexturesTime().InSecondsF() / updateMoreTexturesSize() * uploads * 1000);
if (!uploads)
return;
« 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