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

Unified Diff: cc/texture_uploader.cc

Issue 11028129: cc: Improve texture per second calculation and overhead (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/texture_uploader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/texture_uploader.cc
diff --git a/cc/texture_uploader.cc b/cc/texture_uploader.cc
index 64b3de52424a4ed223a204145ef769843bfe7c79..cad2b4839377c217af45c30302b3f273ce824733 100644
--- a/cc/texture_uploader.cc
+++ b/cc/texture_uploader.cc
@@ -20,7 +20,8 @@
namespace {
// How many previous uploads to use when predicting future throughput.
-static const size_t uploadHistorySize = 100;
+static const size_t uploadHistorySizeMax = 1000;
+static const size_t uploadHistorySizeInitial = 100;
// Global estimated number of textures per second to maintain estimates across
// subsequent instances of TextureUploader.
@@ -87,12 +88,12 @@ bool TextureUploader::Query::isNonBlocking()
TextureUploader::TextureUploader(
WebKit::WebGraphicsContext3D* context, bool useMapTexSubImage)
: m_context(context)
- , m_texturesPerSecondHistory(uploadHistorySize,
- estimatedTexturesPerSecondGlobal)
, m_numBlockingTextureUploads(0)
, m_useMapTexSubImage(useMapTexSubImage)
, m_subImageSize(0)
{
+ for (size_t i = uploadHistorySizeInitial; i > 0; i--)
+ m_texturesPerSecondHistory.insert(estimatedTexturesPerSecondGlobal);
}
TextureUploader::~TextureUploader()
@@ -123,15 +124,10 @@ double TextureUploader::estimatedTexturesPerSecond()
{
processQueries();
- // The history should never be empty because we initialize all elements with an estimate.
- DCHECK(m_texturesPerSecondHistory.size() == uploadHistorySize);
-
- // Sort the history and use the median as our estimate.
- std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(),
- m_texturesPerSecondHistory.end());
- std::sort(sortedHistory.begin(), sortedHistory.end());
-
- estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 / 3];
+ // Use the median as our estimate.
+ std::set<double>::iterator median = m_texturesPerSecondHistory.begin();
+ std::advance(median, m_texturesPerSecondHistory.size() / 2);
+ estimatedTexturesPerSecondGlobal = *median;
TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecondGlobal);
return estimatedTexturesPerSecondGlobal;
}
@@ -339,10 +335,13 @@ void TextureUploader::processQueries()
if (!m_pendingQueries.first()->isNonBlocking())
m_numBlockingTextureUploads--;
- // Remove the oldest values from our history and insert the new one
+ // Remove the min and max value from our history and insert the new one.
double texturesPerSecond = 1.0 / (usElapsed * 1e-6);
- m_texturesPerSecondHistory.pop_back();
- m_texturesPerSecondHistory.push_front(texturesPerSecond);
+ if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax) {
+ m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin());
+ m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end());
+ }
+ m_texturesPerSecondHistory.insert(texturesPerSecond);
m_availableQueries.append(m_pendingQueries.takeFirst());
}
« no previous file with comments | « cc/texture_uploader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698