#include <SimpleExecStreamGovernor.h>
Inheritance diagram for SimpleExecStreamGovernor:
Public Member Functions | |
SimpleExecStreamGovernor (ExecStreamResourceKnobs const &knobSettings, ExecStreamResourceQuantity const &resourcesAvailable, SharedTraceTarget pTraceTarget, std::string name) | |
virtual | ~SimpleExecStreamGovernor () |
virtual bool | setResourceKnob (ExecStreamResourceKnobs const &knob, ExecStreamResourceKnobType knobType) |
Informs the resource governor of a new knob setting. | |
virtual bool | setResourceAvailability (ExecStreamResourceQuantity const &available, ExecStreamResourceType resourceType) |
Informs the resource governor of a new resource availablity. | |
virtual void | requestResources (ExecStreamGraph &graph) |
Requests resources for an exec stream graph and assigns resources to each exec stream in the graph. | |
virtual void | returnResources (ExecStreamGraph &graph) |
Returns to the available resource pool resources that have been assigned to an exec stream graph. | |
void | writeStats (StatsTarget &target) |
Writes a current stats snapshot to a StatsTarget. | |
virtual void | initTraceSource (SharedTraceTarget pTraceTarget, std::string name) |
For use when initialization has to be deferred until after construction. | |
void | trace (TraceLevel level, std::string message) const |
Records a trace message. | |
bool | isTracing () const |
| |
bool | isTracingLevel (TraceLevel level) const |
Determines whether a particular level is being traced. | |
TraceTarget & | getTraceTarget () const |
| |
SharedTraceTarget | getSharedTraceTarget () const |
| |
std::string | getTraceSourceName () const |
Gets the name of this source. | |
void | setTraceSourceName (std::string const &n) |
Sets the name of this source. | |
TraceLevel | getMinimumTraceLevel () const |
void | disableTracing () |
Protected Types | |
typedef std::map< ExecStreamGraph *, SharedExecStreamResourceQuantity > | ExecStreamGraphResourceMap |
Protected Member Functions | |
void | traceCachePageRequest (uint assigned, ExecStreamResourceRequirements const &reqt, std::string const &name) |
Traces the number of pages assigned to a stream, as well as its minimum and optimum requirements. | |
Protected Attributes | |
ExecStreamResourceKnobs | knobSettings |
Current resource knob settings. | |
ExecStreamResourceQuantity | resourcesAvailable |
Keeps track of the total resources that are currently available for assignment. | |
ExecStreamResourceQuantity | resourcesAssigned |
Keeps track of resources that have been assigned. | |
ExecStreamGraphResourceMap | resourceMap |
Used to keep track of how much resources have been assigned to each of the currently active exec stream graphs. | |
StrictMutex | mutex |
Used to synchronize access. | |
Private Member Functions | |
uint | computePerGraphAllocation () |
Computes the per graph allocation. | |
void | assignCachePages (std::vector< SharedExecStream > &streams, boost::scoped_array< ExecStreamResourceRequirements > const &reqts, bool assignMin) |
Assigns each stream either its minimum or optimum resource requirements. | |
uint | distributeCachePages (std::vector< SharedExecStream > &streams, boost::scoped_array< ExecStreamResourceRequirements > const &reqts, boost::scoped_array< double > const &sqrtDiffOptMin, double totalSqrtDiffs, uint excessAvailable, bool assignOpt) |
Distributes cache pages across streams according to the following formula:. | |
Private Attributes | |
uint | perGraphAllocation |
Portion of resources that can be allocated to an exec stream graph. |
Definition at line 40 of file SimpleExecStreamGovernor.h.
typedef std::map<ExecStreamGraph *, SharedExecStreamResourceQuantity> ExecStreamGovernor::ExecStreamGraphResourceMap [protected, inherited] |
Definition at line 95 of file ExecStreamGovernor.h.
SimpleExecStreamGovernor::SimpleExecStreamGovernor | ( | ExecStreamResourceKnobs const & | knobSettings, | |
ExecStreamResourceQuantity const & | resourcesAvailable, | |||
SharedTraceTarget | pTraceTarget, | |||
std::string | name | |||
) | [explicit] |
Definition at line 34 of file SimpleExecStreamGovernor.cpp.
References computePerGraphAllocation(), and perGraphAllocation.
00039 : TraceSource(pTraceTargetInit, nameInit), 00040 ExecStreamGovernor( 00041 knobSettings, resourcesAvailable, pTraceTargetInit, nameInit) 00042 { 00043 perGraphAllocation = computePerGraphAllocation(); 00044 }
SimpleExecStreamGovernor::~SimpleExecStreamGovernor | ( | ) | [virtual] |
uint SimpleExecStreamGovernor::computePerGraphAllocation | ( | ) | [inline, private] |
Computes the per graph allocation.
Definition at line 121 of file SimpleExecStreamGovernor.h.
References ExecStreamResourceKnobs::expectedConcurrentStatements, ExecStreamGovernor::knobSettings, ExecStreamResourceQuantity::nCachePages, ExecStreamGovernor::resourcesAssigned, and ExecStreamGovernor::resourcesAvailable.
Referenced by setResourceAvailability(), setResourceKnob(), and SimpleExecStreamGovernor().
00122 { 00123 return (resourcesAvailable.nCachePages + resourcesAssigned.nCachePages) / 00124 knobSettings.expectedConcurrentStatements; 00125 }
void SimpleExecStreamGovernor::assignCachePages | ( | std::vector< SharedExecStream > & | streams, | |
boost::scoped_array< ExecStreamResourceRequirements > const & | reqts, | |||
bool | assignMin | |||
) | [private] |
Assigns each stream either its minimum or optimum resource requirements.
streams | streams to be assigned resources | |
reqts | resource requirements for each stream | |
assignMin | if true, assign each stream its minimum; otherwise, assign each stream its optimum |
Definition at line 280 of file SimpleExecStreamGovernor.cpp.
References TraceSource::isTracingLevel(), TRACE_FINER, and ExecStreamGovernor::traceCachePageRequest().
Referenced by requestResources().
00284 { 00285 for (uint i = 0; i < streams.size(); i++) { 00286 ExecStreamResourceQuantity quantity; 00287 quantity.nCachePages = 00288 (assignMin) ? reqts[i].minReqt : reqts[i].optReqt; 00289 streams[i]->setResourceAllocation(quantity); 00290 if (isTracingLevel(TRACE_FINER)) { 00291 traceCachePageRequest( 00292 quantity.nCachePages, reqts[i], streams[i]->getName()); 00293 } 00294 } 00295 }
uint SimpleExecStreamGovernor::distributeCachePages | ( | std::vector< SharedExecStream > & | streams, | |
boost::scoped_array< ExecStreamResourceRequirements > const & | reqts, | |||
boost::scoped_array< double > const & | sqrtDiffOptMin, | |||
double | totalSqrtDiffs, | |||
uint | excessAvailable, | |||
bool | assignOpt | |||
) | [private] |
Distributes cache pages across streams according to the following formula:.
base amount for stream +
(# of extra pages above total min available to the stream graph) *
sqrt((opt for stream) - (min for stream)) /
sum of the sqrt of the differences between the opt and min for streams
that will receive excess allocations
where the base amount is either the min or opt requirements of the
stream
streams | streams to be assigned resources | |
reqts | resource requirements for each stream | |
sqrtDiffOptMin | sqrt of the difference between the opt and min for each stream | |
totalSqrtDiffs | sum of the sqrt of the differences between the opt and min for each stream | |
excessAvailable | excess cache pages to be distributed across certain streams | |
assignOpt | if true, assign at least the optimum amount to each stream; otherwise, assign at least the minimum amount |
Definition at line 297 of file SimpleExecStreamGovernor.cpp.
References EXEC_RESOURCE_ACCURATE, EXEC_RESOURCE_UNBOUNDED, TraceSource::isTracingLevel(), ExecStreamResourceRequirements::minReqt, ExecStreamResourceQuantity::nCachePages, ExecStreamResourceRequirements::optReqt, ExecStreamResourceRequirements::optType, TRACE_FINER, and ExecStreamGovernor::traceCachePageRequest().
Referenced by requestResources().
00303 { 00304 // if there's enough to assign the optimum amount to each stream, then 00305 // adjust totalSqrtDiffs so we don't allocate any extra to the 00306 // streams with accurate settings 00307 if (assignOpt) { 00308 totalSqrtDiffs = 0; 00309 for (uint i = 0; i < streams.size(); i++) { 00310 if (reqts[i].optType != EXEC_RESOURCE_ACCURATE) { 00311 totalSqrtDiffs += sqrtDiffOptMin[i]; 00312 } 00313 } 00314 } 00315 00316 uint excessAssigned = 0; 00317 uint totalAssigned = 0; 00318 for (uint i = 0; i < streams.size(); i++) { 00319 uint amount; 00320 ExecStreamResourceRequirements &reqt = reqts[i]; 00321 if (assignOpt && reqt.optType == EXEC_RESOURCE_ACCURATE) { 00322 amount = 0; 00323 } else { 00324 amount = (uint) floor(excessAvailable * sqrtDiffOptMin[i] / 00325 totalSqrtDiffs); 00326 } 00327 assert(amount <= (excessAvailable - excessAssigned)); 00328 excessAssigned += amount; 00329 00330 ExecStreamResourceQuantity quantity; 00331 if (assignOpt) { 00332 assert(reqt.optType != EXEC_RESOURCE_UNBOUNDED); 00333 quantity.nCachePages = reqt.optReqt; 00334 } else { 00335 quantity.nCachePages = reqt.minReqt; 00336 } 00337 quantity.nCachePages += amount; 00338 totalAssigned += quantity.nCachePages; 00339 streams[i]->setResourceAllocation(quantity); 00340 if (isTracingLevel(TRACE_FINER)) { 00341 traceCachePageRequest( 00342 quantity.nCachePages, reqt, streams[i]->getName()); 00343 } 00344 } 00345 00346 return totalAssigned; 00347 }
bool SimpleExecStreamGovernor::setResourceKnob | ( | ExecStreamResourceKnobs const & | knob, | |
ExecStreamResourceKnobType | knobType | |||
) | [virtual] |
Informs the resource governor of a new knob setting.
Called by ALTER SYSTEM SET commands that dynamically modify parameters controlling resource allocation.
knob | new resource knob setting | |
knobType | indicates which knob setting to change |
Implements ExecStreamGovernor.
Definition at line 50 of file SimpleExecStreamGovernor.cpp.
References ExecStreamResourceKnobs::cacheReservePercentage, computePerGraphAllocation(), EXEC_KNOB_CACHE_RESERVE_PERCENTAGE, EXEC_KNOB_EXPECTED_CONCURRENT_STATEMENTS, ExecStreamResourceKnobs::expectedConcurrentStatements, ExecStreamGovernor::knobSettings, ExecStreamGovernor::mutex, ExecStreamResourceQuantity::nCachePages, perGraphAllocation, ExecStreamGovernor::resourcesAssigned, ExecStreamGovernor::resourcesAvailable, and TRACE_FINE.
00052 { 00053 StrictMutexGuard mutexGuard(mutex); 00054 00055 switch (knobType) { 00056 case EXEC_KNOB_EXPECTED_CONCURRENT_STATEMENTS: 00057 knobSettings.expectedConcurrentStatements = 00058 knob.expectedConcurrentStatements; 00059 perGraphAllocation = computePerGraphAllocation(); 00060 FENNEL_TRACE( 00061 TRACE_FINE, 00062 "Expected concurrent statements set to " << 00063 knobSettings.expectedConcurrentStatements << 00064 ". Per graph allocation is now " << perGraphAllocation << 00065 " cache pages."); 00066 break; 00067 00068 case EXEC_KNOB_CACHE_RESERVE_PERCENTAGE: 00069 // make sure we have enough unassigned pages to set aside the new 00070 // reserve amount 00071 double percent = (100 - knobSettings.cacheReservePercentage) / 100.0; 00072 uint totalPagesAvailable = (uint) 00073 ((resourcesAvailable.nCachePages + resourcesAssigned.nCachePages) / 00074 percent); 00075 uint numReserve = 00076 totalPagesAvailable * knob.cacheReservePercentage / 100; 00077 if (totalPagesAvailable - numReserve < resourcesAssigned.nCachePages) { 00078 return false; 00079 } 00080 knobSettings.cacheReservePercentage = knob.cacheReservePercentage; 00081 resourcesAvailable.nCachePages = 00082 totalPagesAvailable - numReserve - resourcesAssigned.nCachePages; 00083 perGraphAllocation = computePerGraphAllocation(); 00084 FENNEL_TRACE( 00085 TRACE_FINE, 00086 "Cache reserve percentage set to " << 00087 knobSettings.cacheReservePercentage << 00088 ". Per graph allocation is now " << perGraphAllocation << 00089 " cache pages."); 00090 break; 00091 } 00092 00093 return true; 00094 }
bool SimpleExecStreamGovernor::setResourceAvailability | ( | ExecStreamResourceQuantity const & | available, | |
ExecStreamResourceType | resourceType | |||
) | [virtual] |
Informs the resource governor of a new resource availablity.
Called by ALTER SYSTEM SET commands that dynamically modify resources available.
available | amount of resources now available | |
resourceType | type of resource to be set |
Implements ExecStreamGovernor.
Definition at line 96 of file SimpleExecStreamGovernor.cpp.
References ExecStreamResourceKnobs::cacheReservePercentage, computePerGraphAllocation(), EXEC_RESOURCE_CACHE_PAGES, EXEC_RESOURCE_THREADS, ExecStreamGovernor::knobSettings, ExecStreamGovernor::mutex, ExecStreamResourceQuantity::nCachePages, ExecStreamResourceQuantity::nThreads, perGraphAllocation, ExecStreamGovernor::resourcesAssigned, ExecStreamGovernor::resourcesAvailable, and TRACE_FINE.
00099 { 00100 StrictMutexGuard mutexGuard(mutex); 00101 00102 switch (resourceType) { 00103 case EXEC_RESOURCE_CACHE_PAGES: 00104 { 00105 uint pagesAvailable = 00106 available.nCachePages * 00107 (100 - knobSettings.cacheReservePercentage) / 100; 00108 if (pagesAvailable < resourcesAssigned.nCachePages) { 00109 return false; 00110 } 00111 resourcesAvailable.nCachePages = 00112 (pagesAvailable - resourcesAssigned.nCachePages); 00113 perGraphAllocation = computePerGraphAllocation(); 00114 FENNEL_TRACE( 00115 TRACE_FINE, 00116 resourcesAvailable.nCachePages << 00117 " cache pages now available for assignment. " << 00118 "Per graph allocation is now " << perGraphAllocation << 00119 " cache pages."); 00120 break; 00121 } 00122 00123 case EXEC_RESOURCE_THREADS: 00124 resourcesAvailable.nThreads = available.nThreads; 00125 break; 00126 } 00127 00128 return true; 00129 }
void SimpleExecStreamGovernor::requestResources | ( | ExecStreamGraph & | graph | ) | [virtual] |
Requests resources for an exec stream graph and assigns resources to each exec stream in the graph.
graph | the exec stream graph for which resources are being requested |
Implements ExecStreamGovernor.
Definition at line 130 of file SimpleExecStreamGovernor.cpp.
References assignCachePages(), distributeCachePages(), EXEC_RESOURCE_ACCURATE, EXEC_RESOURCE_ESTIMATE, EXEC_RESOURCE_UNBOUNDED, ExecStreamGraph::getSortedStreams(), min(), ExecStreamResourceRequirements::minReqt, ExecStreamGovernor::mutex, ExecStreamResourceQuantity::nCachePages, ExecStreamResourceQuantity::nThreads, ExecStreamResourceRequirements::optReqt, ExecStreamResourceRequirements::optType, perGraphAllocation, ExecStreamGovernor::resourceMap, ExecStreamGovernor::resourcesAssigned, ExecStreamGovernor::resourcesAvailable, and TRACE_FINE.
00131 { 00132 FENNEL_TRACE(TRACE_FINE, "requestResources"); 00133 00134 StrictMutexGuard mutexGuard(mutex); 00135 00136 std::vector<SharedExecStream> sortedStreams = graph.getSortedStreams(); 00137 boost::scoped_array<ExecStreamResourceRequirements> resourceReqts; 00138 boost::scoped_array<double> sqrtDiffOptMin; 00139 uint nStreams = sortedStreams.size(); 00140 00141 resourceReqts.reset(new ExecStreamResourceRequirements[nStreams]); 00142 sqrtDiffOptMin.reset(new double[nStreams]); 00143 00144 // scale down the number of pages that can be allocated based on how 00145 // much still remains 00146 uint allocationAmount = 00147 std::min(resourcesAvailable.nCachePages, perGraphAllocation); 00148 FENNEL_TRACE( 00149 TRACE_FINE, 00150 allocationAmount << " cache pages available for stream graph"); 00151 00152 // Total the minimum and optimum resource requirements and determine 00153 // if we have any estimate/unbounded optimum settings 00154 uint totalMin = 0; 00155 uint totalOpt = 0; 00156 double totalSqrtDiffs = 0; 00157 bool allAccurate = true; 00158 for (uint i = 0; i < nStreams; i++) { 00159 ExecStreamResourceQuantity minQuantity, optQuantity; 00160 ExecStreamResourceSettingType optType; 00161 sortedStreams[i]->getResourceRequirements( 00162 minQuantity, optQuantity, optType); 00163 assert( 00164 optType == EXEC_RESOURCE_UNBOUNDED || 00165 minQuantity.nCachePages <= optQuantity.nCachePages); 00166 assert(minQuantity.nThreads <= optQuantity.nThreads); 00167 00168 ExecStreamResourceRequirements &reqt = resourceReqts[i]; 00169 reqt.minReqt = minQuantity.nCachePages; 00170 totalMin += reqt.minReqt; 00171 reqt.optType = optType; 00172 00173 switch (optType) { 00174 case EXEC_RESOURCE_ACCURATE: 00175 reqt.optReqt = optQuantity.nCachePages; 00176 sqrtDiffOptMin[i] = sqrt(double(reqt.optReqt - reqt.minReqt)); 00177 break; 00178 case EXEC_RESOURCE_ESTIMATE: 00179 reqt.optReqt = optQuantity.nCachePages; 00180 sqrtDiffOptMin[i] = sqrt(double(reqt.optReqt - reqt.minReqt)); 00181 allAccurate = false; 00182 break; 00183 case EXEC_RESOURCE_UNBOUNDED: 00184 // in the unbounded case, since we're trying to use as much 00185 // memory as available, set the difference to how much is 00186 // available; this way, we set it to something large relative 00187 // to availability, but still set it to a finite value to 00188 // allow some allocation to go towards those streams that 00189 // have estimated optimums 00190 sqrtDiffOptMin[i] = sqrt(double(allocationAmount)); 00191 allAccurate = false; 00192 // in the unbounded case, we don't have an optimum setting, so 00193 // set it to assume the full allocation amount plus the min 00194 reqt.optReqt = reqt.minReqt + allocationAmount; 00195 break; 00196 } 00197 totalOpt += reqt.optReqt; 00198 totalSqrtDiffs += sqrtDiffOptMin[i]; 00199 } 00200 00201 // not enough pages even to assign the minimum requirements 00202 if (totalMin > allocationAmount && 00203 totalMin > resourcesAvailable.nCachePages) 00204 { 00205 FENNEL_TRACE( 00206 TRACE_FINE, 00207 "Minimum request of " << totalMin << " cache pages not met"); 00208 throw ScratchMemExcn(); 00209 } 00210 00211 uint totalAssigned; 00212 00213 // only enough to assign the minimum 00214 if (totalMin >= allocationAmount) { 00215 assignCachePages(sortedStreams, resourceReqts, true); 00216 totalAssigned = totalMin; 00217 FENNEL_TRACE( 00218 TRACE_FINE, 00219 "Mininum request of " << totalMin << " cache pages assigned"); 00220 00221 } else if (totalOpt <= allocationAmount) { 00222 // if all streams have accurate optimum settings, and we have enough 00223 // to assign the optimum amount, then do so 00224 if (allAccurate) { 00225 assignCachePages(sortedStreams, resourceReqts, false); 00226 totalAssigned = totalOpt; 00227 FENNEL_TRACE( 00228 TRACE_FINE, 00229 "Optimum request of " << totalOpt << " cache pages assigned"); 00230 00231 } else { 00232 // even though total optimum is less than the allocation amount, 00233 // since some streams have estimate settings, we want to try and 00234 // give a little extra to those streams; the streams that have 00235 // accurate settings will receive their full optimum amount; 00236 // note that in this case, there should not be any streams with 00237 // optimum settings 00238 uint assigned = 00239 distributeCachePages( 00240 sortedStreams, resourceReqts, sqrtDiffOptMin, 00241 totalSqrtDiffs, allocationAmount - totalOpt, true); 00242 totalAssigned = assigned; 00243 FENNEL_TRACE( 00244 TRACE_FINE, 00245 assigned << 00246 " cache pages assigned, based on an optimum request for " << 00247 totalOpt << " cache pages"); 00248 } 00249 00250 } else { 00251 // allocate the minimum to each stream and then distribute what 00252 // remains 00253 uint assigned = 00254 distributeCachePages( 00255 sortedStreams, resourceReqts, sqrtDiffOptMin, totalSqrtDiffs, 00256 allocationAmount - totalMin, false); 00257 totalAssigned = assigned; 00258 FENNEL_TRACE( 00259 TRACE_FINE, 00260 assigned << 00261 " cache pages assigned based on an optimum request for " << 00262 totalOpt << " cache pages"); 00263 } 00264 00265 // update structures to reflect what's been assigned 00266 resourcesAssigned.nCachePages += totalAssigned; 00267 resourcesAvailable.nCachePages -= totalAssigned; 00268 SharedExecStreamResourceQuantity 00269 pQuantity(new ExecStreamResourceQuantity()); 00270 pQuantity->nCachePages = totalAssigned; 00271 resourceMap.insert( 00272 ExecStreamGraphResourceMap::value_type(&graph, pQuantity)); 00273 00274 FENNEL_TRACE( 00275 TRACE_FINE, 00276 resourcesAvailable.nCachePages << 00277 " cache pages remaining for assignment"); 00278 }
void SimpleExecStreamGovernor::returnResources | ( | ExecStreamGraph & | graph | ) | [virtual] |
Returns to the available resource pool resources that have been assigned to an exec stream graph.
graph | the exec stream graph that is returning its resources |
Implements ExecStreamGovernor.
Definition at line 349 of file SimpleExecStreamGovernor.cpp.
References ExecStreamGovernor::mutex, ExecStreamResourceQuantity::nCachePages, ExecStreamGovernor::resourceMap, ExecStreamGovernor::resourcesAssigned, ExecStreamGovernor::resourcesAvailable, and TRACE_FINE.
00350 { 00351 StrictMutexGuard mutexGuard(mutex); 00352 00353 ExecStreamGraphResourceMap::const_iterator iter = resourceMap.find(&graph); 00354 if (iter == resourceMap.end()) { 00355 // no allocation may have been done 00356 return; 00357 } 00358 SharedExecStreamResourceQuantity pQuantity = iter->second; 00359 resourcesAssigned.nCachePages -= pQuantity->nCachePages; 00360 resourcesAvailable.nCachePages += pQuantity->nCachePages; 00361 FENNEL_TRACE( 00362 TRACE_FINE, 00363 "Returned " << pQuantity->nCachePages << " cache pages. " << 00364 resourcesAvailable.nCachePages << 00365 " cache pages now available for assignment"); 00366 00367 resourceMap.erase(&graph); 00368 }
void ExecStreamGovernor::traceCachePageRequest | ( | uint | assigned, | |
ExecStreamResourceRequirements const & | reqt, | |||
std::string const & | name | |||
) | [protected, inherited] |
Traces the number of pages assigned to a stream, as well as its minimum and optimum requirements.
assigned | number of cache pages assigned to the stream | |
reqt | resource requirements for the stream | |
name | name of the stream |
Definition at line 53 of file ExecStreamGovernor.cpp.
References EXEC_RESOURCE_ACCURATE, EXEC_RESOURCE_ESTIMATE, EXEC_RESOURCE_UNBOUNDED, ExecStreamResourceRequirements::minReqt, ExecStreamResourceRequirements::optReqt, ExecStreamResourceRequirements::optType, and TRACE_FINER.
Referenced by assignCachePages(), and distributeCachePages().
00057 { 00058 switch (reqt.optType) { 00059 case EXEC_RESOURCE_ACCURATE: 00060 FENNEL_TRACE( 00061 TRACE_FINER, 00062 "Stream " << name << " assigned " << assigned << 00063 " pages based on accurate (min,opt) request of " << "(" << 00064 reqt.minReqt << "," << reqt.optReqt << ") pages"); 00065 break; 00066 case EXEC_RESOURCE_ESTIMATE: 00067 FENNEL_TRACE( 00068 TRACE_FINER, 00069 "Stream " << name << " assigned " << assigned << 00070 " pages based on estimated (min,opt) request of " << "(" << 00071 reqt.minReqt << "," << reqt.optReqt << ") pages"); 00072 break; 00073 case EXEC_RESOURCE_UNBOUNDED: 00074 FENNEL_TRACE( 00075 TRACE_FINER, 00076 "Stream " << name << " assigned " << assigned << 00077 " pages based on an unbounded opt request with " << 00078 reqt.minReqt << " min pages"); 00079 } 00080 }
void ExecStreamGovernor::writeStats | ( | StatsTarget & | target | ) | [virtual, inherited] |
Writes a current stats snapshot to a StatsTarget.
target | receives the stats |
Implements StatsSource.
Definition at line 82 of file ExecStreamGovernor.cpp.
References ExecStreamResourceKnobs::cacheReservePercentage, ExecStreamResourceKnobs::expectedConcurrentStatements, ExecStreamGovernor::knobSettings, ExecStreamGovernor::mutex, ExecStreamResourceQuantity::nCachePages, ExecStreamGovernor::resourcesAssigned, ExecStreamGovernor::resourcesAvailable, and StatsTarget::writeCounter().
00083 { 00084 StrictMutexGuard mutexGuard(mutex); 00085 target.writeCounter( 00086 "ExpectedConcurrentStatements", 00087 knobSettings.expectedConcurrentStatements); 00088 target.writeCounter( 00089 "CacheReservePercentage", 00090 knobSettings.cacheReservePercentage); 00091 target.writeCounter( 00092 "CachePagesGoverned", 00093 resourcesAvailable.nCachePages); 00094 target.writeCounter( 00095 "CachePagesReserved", 00096 resourcesAssigned.nCachePages); 00097 }
void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, | |
std::string | name | |||
) | [virtual, inherited] |
For use when initialization has to be deferred until after construction.
pTraceTarget | the TraceTarget to which messages will be sent | |
name | the name of this source |
Definition at line 46 of file TraceSource.cpp.
References TraceSource::isTracing(), TraceSource::minimumLevel, TraceSource::name, TraceSource::pTraceTarget, and TRACE_OFF.
Referenced by TestBase::beforeTestCase(), TestBase::TestBase(), and TraceSource::TraceSource().
00049 { 00050 assert(!pTraceTarget.get()); 00051 00052 pTraceTarget = pTraceTargetInit; 00053 name = nameInit; 00054 if (isTracing()) { 00055 minimumLevel = pTraceTarget->getSourceTraceLevel(name); 00056 } else { 00057 minimumLevel = TRACE_OFF; 00058 } 00059 }
void TraceSource::trace | ( | TraceLevel | level, | |
std::string | message | |||
) | const [inherited] |
Records a trace message.
Normally only called via FENNEL_TRACE.
level | severity level of event being trace | |
message | the text of the message |
Definition at line 61 of file TraceSource.cpp.
References TraceSource::getTraceTarget(), TraceSource::isTracing(), TraceSource::name, and TraceTarget::notifyTrace().
Referenced by Calculator::exec(), and ExecStreamScheduler::traceStreamBufferContents().
00062 { 00063 if (isTracing()) { 00064 getTraceTarget().notifyTrace(name,level,message); 00065 } 00066 }
bool TraceSource::isTracing | ( | ) | const [inline, inherited] |
Definition at line 88 of file TraceSource.h.
Referenced by TraceSource::initTraceSource(), CalcExecStream::prepare(), and TraceSource::trace().
00089 { 00090 return pTraceTarget.get() ? true : false; 00091 }
bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
Determines whether a particular level is being traced.
level | trace level to test |
Definition at line 100 of file TraceSource.h.
Referenced by ExecStreamScheduler::addGraph(), assignCachePages(), distributeCachePages(), Calculator::exec(), ExecStreamScheduler::ExecStreamScheduler(), LcsClusterNodeWriter::getLastClusterPageForWrite(), LcsClusterNodeWriter::moveFromTempToIndex(), JavaSinkExecStream::stuffByteBuffer(), and ExecStreamScheduler::traceStreamBuffers().
00101 { 00102 return level >= minimumLevel; 00103 }
TraceTarget& TraceSource::getTraceTarget | ( | ) | const [inline, inherited] |
Definition at line 108 of file TraceSource.h.
Referenced by TraceSource::trace().
00109 { 00110 assert(isTracing()); 00111 return *(pTraceTarget.get()); 00112 }
SharedTraceTarget TraceSource::getSharedTraceTarget | ( | ) | const [inline, inherited] |
Definition at line 117 of file TraceSource.h.
Referenced by Database::init(), LcsClusterAppendExecStream::initLoad(), and CalcExecStream::prepare().
00118 { 00119 return pTraceTarget; 00120 }
std::string TraceSource::getTraceSourceName | ( | ) | const [inline, inherited] |
Gets the name of this source.
Useful to construct nested names for subcomponents that are also TraceSources.
Definition at line 127 of file TraceSource.h.
Referenced by LcsClusterAppendExecStream::initLoad().
00128 { 00129 return name; 00130 }
void TraceSource::setTraceSourceName | ( | std::string const & | n | ) | [inline, inherited] |
Sets the name of this source.
Useful to construct dynamic names for fine-grained filtering.
Definition at line 136 of file TraceSource.h.
00137 { 00138 name = n; 00139 }
TraceLevel TraceSource::getMinimumTraceLevel | ( | ) | const [inline, inherited] |
void TraceSource::disableTracing | ( | ) | [inherited] |
Definition at line 68 of file TraceSource.cpp.
References TraceSource::minimumLevel, TraceSource::pTraceTarget, and TRACE_OFF.
Referenced by TestBase::afterTestCase().
00069 { 00070 pTraceTarget.reset(); 00071 minimumLevel = TRACE_OFF; 00072 }
Portion of resources that can be allocated to an exec stream graph.
Definition at line 46 of file SimpleExecStreamGovernor.h.
Referenced by requestResources(), setResourceAvailability(), setResourceKnob(), and SimpleExecStreamGovernor().
ExecStreamResourceKnobs ExecStreamGovernor::knobSettings [protected, inherited] |
Current resource knob settings.
Definition at line 100 of file ExecStreamGovernor.h.
Referenced by computePerGraphAllocation(), ExecStreamGovernor::ExecStreamGovernor(), setResourceAvailability(), setResourceKnob(), and ExecStreamGovernor::writeStats().
ExecStreamResourceQuantity ExecStreamGovernor::resourcesAvailable [protected, inherited] |
Keeps track of the total resources that are currently available for assignment.
Definition at line 106 of file ExecStreamGovernor.h.
Referenced by computePerGraphAllocation(), ExecStreamGovernor::ExecStreamGovernor(), requestResources(), returnResources(), setResourceAvailability(), setResourceKnob(), and ExecStreamGovernor::writeStats().
ExecStreamResourceQuantity ExecStreamGovernor::resourcesAssigned [protected, inherited] |
Keeps track of resources that have been assigned.
Definition at line 111 of file ExecStreamGovernor.h.
Referenced by computePerGraphAllocation(), ExecStreamGovernor::ExecStreamGovernor(), requestResources(), returnResources(), setResourceAvailability(), setResourceKnob(), and ExecStreamGovernor::writeStats().
ExecStreamGraphResourceMap ExecStreamGovernor::resourceMap [protected, inherited] |
Used to keep track of how much resources have been assigned to each of the currently active exec stream graphs.
Definition at line 117 of file ExecStreamGovernor.h.
Referenced by requestResources(), returnResources(), and ExecStreamGovernor::~ExecStreamGovernor().
StrictMutex ExecStreamGovernor::mutex [protected, inherited] |
Used to synchronize access.
Definition at line 122 of file ExecStreamGovernor.h.
Referenced by requestResources(), returnResources(), setResourceAvailability(), setResourceKnob(), and ExecStreamGovernor::writeStats().