00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/exec/ExecStreamGovernor.h"
00026 #include "fennel/common/StatsTarget.h"
00027
00028 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/exec/ExecStreamGovernor.cpp#8 $");
00029
00030 ExecStreamGovernor::ExecStreamGovernor(
00031 ExecStreamResourceKnobs const &knobSettingsInit,
00032 ExecStreamResourceQuantity const &resourcesAvailableInit,
00033 SharedTraceTarget pTraceTargetInit,
00034 std::string nameInit)
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 }
00047
00048 ExecStreamGovernor::~ExecStreamGovernor()
00049 {
00050 assert(resourceMap.empty());
00051 }
00052
00053 void ExecStreamGovernor::traceCachePageRequest(
00054 uint assigned,
00055 ExecStreamResourceRequirements const &reqt,
00056 std::string const &name)
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 }
00081
00082 void ExecStreamGovernor::writeStats(StatsTarget &target)
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 }
00098
00099 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/exec/ExecStreamGovernor.cpp#8 $");
00100
00101