Chromium Code Reviews| Index: cc/ThrottledTextureUploader.cpp |
| diff --git a/cc/ThrottledTextureUploader.cpp b/cc/ThrottledTextureUploader.cpp |
| index c152598aa648e1586aa9b892e16bd4e53750797d..9c9e50d9ef3a6581c399c53329f8f995efeb7adf 100644 |
| --- a/cc/ThrottledTextureUploader.cpp |
| +++ b/cc/ThrottledTextureUploader.cpp |
| @@ -15,7 +15,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 ThrottledTextureUploader. |
| @@ -87,7 +88,8 @@ bool ThrottledTextureUploader::Query::isNonBlocking() |
| ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context) |
| : m_context(context) |
| - , m_texturesPerSecondHistory(uploadHistorySize, estimatedTexturesPerSecondGlobal) |
| + , m_texturesPerSecondHistory(uploadHistorySizeInitial, |
| + estimatedTexturesPerSecondGlobal) |
| , m_numBlockingTextureUploads(0) |
| { |
| } |
| @@ -120,15 +122,12 @@ double ThrottledTextureUploader::estimatedTexturesPerSecond() |
| { |
| processQueries(); |
| - // The history should never be empty because we initialize all elements with an estimate. |
| - ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize); |
| - |
| - // Sort the history and use the median as our estimate. |
| + // Sort the history and use the 3/4 median as our optimistic estimate. |
| std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), |
| m_texturesPerSecondHistory.end()); |
| std::sort(sortedHistory.begin(), sortedHistory.end()); |
|
reveman
2012/10/11 17:59:46
with the history now relatively large, does it mak
|
| - estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 / 3]; |
| + estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 3 / 4]; |
| TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecondGlobal); |
| return estimatedTexturesPerSecondGlobal; |
| } |
| @@ -178,7 +177,8 @@ void ThrottledTextureUploader::processQueries() |
| // Remove the oldest values from our history and insert the new one |
| double texturesPerSecond = 1.0 / (usElapsed * 1e-6); |
| - m_texturesPerSecondHistory.pop_back(); |
| + if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax) |
| + m_texturesPerSecondHistory.pop_back(); |
| m_texturesPerSecondHistory.push_front(texturesPerSecond); |
| m_availableQueries.append(m_pendingQueries.takeFirst()); |