#include <ExecStreamGovernor.h>
Inheritance diagram for ExecStreamGovernor:
Public Member Functions | |
virtual | ~ExecStreamGovernor () |
virtual bool | setResourceKnob (ExecStreamResourceKnobs const &knob, ExecStreamResourceKnobType knobType)=0 |
Informs the resource governor of a new knob setting. | |
virtual bool | setResourceAvailability (ExecStreamResourceQuantity const &available, ExecStreamResourceType resourceType)=0 |
Informs the resource governor of a new resource availablity. | |
virtual void | requestResources (ExecStreamGraph &graph)=0 |
Requests resources for an exec stream graph and assigns resources to each exec stream in the graph. | |
virtual void | returnResources (ExecStreamGraph &graph)=0 |
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 | |
ExecStreamGovernor (ExecStreamResourceKnobs const &knobSettings, ExecStreamResourceQuantity const &resourcesAvailable, SharedTraceTarget pTraceTarget, std::string name) | |
Initializes the resource governor object, including initializing current resource availability. | |
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. |
Definition at line 89 of file ExecStreamGovernor.h.
typedef std::map<ExecStreamGraph *, SharedExecStreamResourceQuantity> ExecStreamGovernor::ExecStreamGraphResourceMap [protected] |
Definition at line 95 of file ExecStreamGovernor.h.
ExecStreamGovernor::ExecStreamGovernor | ( | ExecStreamResourceKnobs const & | knobSettings, | |
ExecStreamResourceQuantity const & | resourcesAvailable, | |||
SharedTraceTarget | pTraceTarget, | |||
std::string | name | |||
) | [explicit, protected] |
Initializes the resource governor object, including initializing current resource availability.
knobSettings | initial knob settings | |
resourcesAvailable | initial available resources | |
pTraceTarget | the TraceTarget to which messages will be sent, or NULL to disable tracing entirely | |
name | the name to use for tracing this resource governor |
Definition at line 30 of file ExecStreamGovernor.cpp.
References ExecStreamResourceKnobs::cacheReservePercentage, ExecStreamResourceKnobs::expectedConcurrentStatements, knobSettings, ExecStreamResourceQuantity::nCachePages, resourcesAssigned, and resourcesAvailable.
00035 : TraceSource(pTraceTargetInit, nameInit) 00036 { 00037 knobSettings.cacheReservePercentage = 00038 knobSettingsInit.cacheReservePercentage; 00039 knobSettings.expectedConcurrentStatements = 00040 knobSettingsInit.expectedConcurrentStatements; 00041 00042 resourcesAvailable.nCachePages = 00043 resourcesAvailableInit.nCachePages * 00044 (100 - knobSettings.cacheReservePercentage) / 100; 00045 resourcesAssigned.nCachePages = 0; 00046 }
ExecStreamGovernor::~ExecStreamGovernor | ( | ) | [virtual] |
Definition at line 48 of file ExecStreamGovernor.cpp.
References resourceMap.
00049 { 00050 assert(resourceMap.empty()); 00051 }
void ExecStreamGovernor::traceCachePageRequest | ( | uint | assigned, | |
ExecStreamResourceRequirements const & | reqt, | |||
std::string const & | name | |||
) | [protected] |
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 SimpleExecStreamGovernor::assignCachePages(), and SimpleExecStreamGovernor::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 }
virtual bool ExecStreamGovernor::setResourceKnob | ( | ExecStreamResourceKnobs const & | knob, | |
ExecStreamResourceKnobType | knobType | |||
) | [pure 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 |
Implemented in SimpleExecStreamGovernor.
virtual bool ExecStreamGovernor::setResourceAvailability | ( | ExecStreamResourceQuantity const & | available, | |
ExecStreamResourceType | resourceType | |||
) | [pure 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 |
Implemented in SimpleExecStreamGovernor.
virtual void ExecStreamGovernor::requestResources | ( | ExecStreamGraph & | graph | ) | [pure 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 |
Implemented in SimpleExecStreamGovernor.
virtual void ExecStreamGovernor::returnResources | ( | ExecStreamGraph & | graph | ) | [pure 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 |
Implemented in SimpleExecStreamGovernor.
void ExecStreamGovernor::writeStats | ( | StatsTarget & | target | ) | [virtual] |
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, knobSettings, mutex, ExecStreamResourceQuantity::nCachePages, resourcesAssigned, 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(), SimpleExecStreamGovernor::assignCachePages(), SimpleExecStreamGovernor::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 }
Current resource knob settings.
Definition at line 100 of file ExecStreamGovernor.h.
Referenced by SimpleExecStreamGovernor::computePerGraphAllocation(), ExecStreamGovernor(), SimpleExecStreamGovernor::setResourceAvailability(), SimpleExecStreamGovernor::setResourceKnob(), and writeStats().
Keeps track of the total resources that are currently available for assignment.
Definition at line 106 of file ExecStreamGovernor.h.
Referenced by SimpleExecStreamGovernor::computePerGraphAllocation(), ExecStreamGovernor(), SimpleExecStreamGovernor::requestResources(), SimpleExecStreamGovernor::returnResources(), SimpleExecStreamGovernor::setResourceAvailability(), SimpleExecStreamGovernor::setResourceKnob(), and writeStats().
Keeps track of resources that have been assigned.
Definition at line 111 of file ExecStreamGovernor.h.
Referenced by SimpleExecStreamGovernor::computePerGraphAllocation(), ExecStreamGovernor(), SimpleExecStreamGovernor::requestResources(), SimpleExecStreamGovernor::returnResources(), SimpleExecStreamGovernor::setResourceAvailability(), SimpleExecStreamGovernor::setResourceKnob(), and writeStats().
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 SimpleExecStreamGovernor::requestResources(), SimpleExecStreamGovernor::returnResources(), and ~ExecStreamGovernor().
StrictMutex ExecStreamGovernor::mutex [protected] |
Used to synchronize access.
Definition at line 122 of file ExecStreamGovernor.h.
Referenced by SimpleExecStreamGovernor::requestResources(), SimpleExecStreamGovernor::returnResources(), SimpleExecStreamGovernor::setResourceAvailability(), SimpleExecStreamGovernor::setResourceKnob(), and writeStats().