00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Fennel_ExecStreamGovernor_Included
00025 #define Fennel_ExecStreamGovernor_Included
00026
00027 #include "fennel/common/SharedTypes.h"
00028 #include "fennel/common/TraceSource.h"
00029 #include "fennel/common/StatsSource.h"
00030 #include "fennel/exec/ExecStreamDefs.h"
00031 #include "fennel/synch/SynchObj.h"
00032
00033 #include <boost/utility.hpp>
00034 #include <map>
00035
00036 FENNEL_BEGIN_NAMESPACE
00037
00041 enum ExecStreamResourceKnobType {
00042 EXEC_KNOB_EXPECTED_CONCURRENT_STATEMENTS,
00043 EXEC_KNOB_CACHE_RESERVE_PERCENTAGE
00044 };
00045
00050 struct FENNEL_EXEC_EXPORT ExecStreamResourceKnobs
00051 {
00055 uint expectedConcurrentStatements;
00056
00060 uint cacheReservePercentage;
00061 };
00062
00066 enum ExecStreamResourceType {
00067 EXEC_RESOURCE_THREADS,
00068 EXEC_RESOURCE_CACHE_PAGES
00069 };
00070
00074 struct FENNEL_EXEC_EXPORT ExecStreamResourceRequirements
00075 {
00076 uint minReqt;
00077 uint optReqt;
00078 ExecStreamResourceSettingType optType;
00079 };
00080
00089 class FENNEL_EXEC_EXPORT ExecStreamGovernor
00090 : public boost::noncopyable, public virtual TraceSource,
00091 public StatsSource
00092 {
00093 protected:
00094 typedef std::map<ExecStreamGraph *, SharedExecStreamResourceQuantity>
00095 ExecStreamGraphResourceMap;
00096
00100 ExecStreamResourceKnobs knobSettings;
00101
00106 ExecStreamResourceQuantity resourcesAvailable;
00107
00111 ExecStreamResourceQuantity resourcesAssigned;
00112
00117 ExecStreamGraphResourceMap resourceMap;
00118
00122 StrictMutex mutex;
00123
00134 explicit ExecStreamGovernor(
00135 ExecStreamResourceKnobs const &knobSettings,
00136 ExecStreamResourceQuantity const &resourcesAvailable,
00137 SharedTraceTarget pTraceTarget,
00138 std::string name);
00139
00148 void traceCachePageRequest(
00149 uint assigned, ExecStreamResourceRequirements const &reqt,
00150 std::string const &name);
00151
00152 public:
00153 virtual ~ExecStreamGovernor();
00154
00168 virtual bool setResourceKnob(
00169 ExecStreamResourceKnobs const &knob,
00170 ExecStreamResourceKnobType knobType) = 0;
00171
00185 virtual bool setResourceAvailability(
00186 ExecStreamResourceQuantity const &available,
00187 ExecStreamResourceType resourceType) = 0;
00188
00196 virtual void requestResources(ExecStreamGraph &graph) = 0;
00197
00205 virtual void returnResources(ExecStreamGraph &graph) = 0;
00206
00207
00208 void writeStats(StatsTarget &target);
00209 };
00210
00211 FENNEL_END_NAMESPACE
00212
00213 #endif
00214
00215