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

Side by Side Diff: cc/ThrottledTextureUploader.cpp

Issue 11028129: cc: Improve texture per second calculation and overhead (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 #include "ThrottledTextureUploader.h" 6 #include "ThrottledTextureUploader.h"
7 7
8 #include "Extensions3DChromium.h" 8 #include "Extensions3DChromium.h"
9 #include "TraceEvent.h" 9 #include "TraceEvent.h"
10 #include <algorithm> 10 #include <algorithm>
11 #include <public/Platform.h> 11 #include <public/Platform.h>
12 #include <public/WebGraphicsContext3D.h> 12 #include <public/WebGraphicsContext3D.h>
13 #include <vector> 13 #include <vector>
14 14
15 namespace { 15 namespace {
16 16
17 // How many previous uploads to use when predicting future throughput. 17 // How many previous uploads to use when predicting future throughput.
18 static const size_t uploadHistorySize = 100; 18 static const size_t uploadHistorySizeMax = 1000;
19 static const size_t uploadHistorySizeInitial = 100;
19 20
20 // Global estimated number of textures per second to maintain estimates across 21 // Global estimated number of textures per second to maintain estimates across
21 // subsequent instances of ThrottledTextureUploader. 22 // subsequent instances of ThrottledTextureUploader.
22 // More than one thread will not access this variable, so we do not need to sync hronize access. 23 // More than one thread will not access this variable, so we do not need to sync hronize access.
23 static double estimatedTexturesPerSecondGlobal = 48.0 * 60.0; 24 static double estimatedTexturesPerSecondGlobal = 48.0 * 60.0;
24 25
25 } // anonymous namespace 26 } // anonymous namespace
26 27
27 namespace cc { 28 namespace cc {
28 29
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 m_isNonBlocking = true; 81 m_isNonBlocking = true;
81 } 82 }
82 83
83 bool ThrottledTextureUploader::Query::isNonBlocking() 84 bool ThrottledTextureUploader::Query::isNonBlocking()
84 { 85 {
85 return m_isNonBlocking; 86 return m_isNonBlocking;
86 } 87 }
87 88
88 ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context) 89 ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context)
89 : m_context(context) 90 : m_context(context)
90 , m_texturesPerSecondHistory(uploadHistorySize, estimatedTexturesPerSecondGl obal) 91 , m_texturesPerSecondHistory(uploadHistorySizeInitial,
92 estimatedTexturesPerSecondGlobal)
91 , m_numBlockingTextureUploads(0) 93 , m_numBlockingTextureUploads(0)
92 { 94 {
93 } 95 }
94 96
95 ThrottledTextureUploader::~ThrottledTextureUploader() 97 ThrottledTextureUploader::~ThrottledTextureUploader()
96 { 98 {
97 } 99 }
98 100
99 size_t ThrottledTextureUploader::numBlockingUploads() 101 size_t ThrottledTextureUploader::numBlockingUploads()
100 { 102 {
(...skipping 12 matching lines...) Expand all
113 it->get()->markAsNonBlocking(); 115 it->get()->markAsNonBlocking();
114 } 116 }
115 117
116 ASSERT(!m_numBlockingTextureUploads); 118 ASSERT(!m_numBlockingTextureUploads);
117 } 119 }
118 120
119 double ThrottledTextureUploader::estimatedTexturesPerSecond() 121 double ThrottledTextureUploader::estimatedTexturesPerSecond()
120 { 122 {
121 processQueries(); 123 processQueries();
122 124
123 // The history should never be empty because we initialize all elements with an estimate. 125 // Sort the history and use the 3/4 median as our optimistic estimate.
124 ASSERT(m_texturesPerSecondHistory.size() == uploadHistorySize);
125
126 // Sort the history and use the median as our estimate.
127 std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(), 126 std::vector<double> sortedHistory(m_texturesPerSecondHistory.begin(),
128 m_texturesPerSecondHistory.end()); 127 m_texturesPerSecondHistory.end());
129 std::sort(sortedHistory.begin(), sortedHistory.end()); 128 std::sort(sortedHistory.begin(), sortedHistory.end());
reveman 2012/10/11 17:59:46 with the history now relatively large, does it mak
130 129
131 estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 2 / 3]; 130 estimatedTexturesPerSecondGlobal = sortedHistory[sortedHistory.size() * 3 / 4];
132 TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecon dGlobal); 131 TRACE_COUNTER1("cc", "estimatedTexturesPerSecond", estimatedTexturesPerSecon dGlobal);
133 return estimatedTexturesPerSecondGlobal; 132 return estimatedTexturesPerSecondGlobal;
134 } 133 }
135 134
136 void ThrottledTextureUploader::beginQuery() 135 void ThrottledTextureUploader::beginQuery()
137 { 136 {
138 processQueries(); 137 processQueries();
139 138
140 if (m_availableQueries.isEmpty()) 139 if (m_availableQueries.isEmpty())
141 m_availableQueries.append(Query::create(m_context)); 140 m_availableQueries.append(Query::create(m_context));
(...skipping 29 matching lines...) Expand all
171 break; 170 break;
172 171
173 unsigned usElapsed = m_pendingQueries.first()->value(); 172 unsigned usElapsed = m_pendingQueries.first()->value();
174 WebKit::Platform::current()->histogramCustomCounts("Renderer4.TextureGpu UploadTimeUS", usElapsed, 0, 100000, 50); 173 WebKit::Platform::current()->histogramCustomCounts("Renderer4.TextureGpu UploadTimeUS", usElapsed, 0, 100000, 50);
175 174
176 if (!m_pendingQueries.first()->isNonBlocking()) 175 if (!m_pendingQueries.first()->isNonBlocking())
177 m_numBlockingTextureUploads--; 176 m_numBlockingTextureUploads--;
178 177
179 // Remove the oldest values from our history and insert the new one 178 // Remove the oldest values from our history and insert the new one
180 double texturesPerSecond = 1.0 / (usElapsed * 1e-6); 179 double texturesPerSecond = 1.0 / (usElapsed * 1e-6);
181 m_texturesPerSecondHistory.pop_back(); 180 if (m_texturesPerSecondHistory.size() >= uploadHistorySizeMax)
181 m_texturesPerSecondHistory.pop_back();
182 m_texturesPerSecondHistory.push_front(texturesPerSecond); 182 m_texturesPerSecondHistory.push_front(texturesPerSecond);
183 183
184 m_availableQueries.append(m_pendingQueries.takeFirst()); 184 m_availableQueries.append(m_pendingQueries.takeFirst());
185 } 185 }
186 } 186 }
187 187
188 } 188 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698