ExecStreamGovernor.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/exec/ExecStreamGovernor.cpp#8 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2005-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 // Portions Copyright (C) 2004-2009 John V. Sichi
00008 //
00009 // This program is free software; you can redistribute it and/or modify it
00010 // under the terms of the GNU General Public License as published by the Free
00011 // Software Foundation; either version 2 of the License, or (at your option)
00012 // any later version approved by The Eigenbase Project.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 // End ExecStreamGovernor.cpp

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1