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/cache/CacheImpl.h"
00026 #include "fennel/cache/LRUVictimPolicy.h"
00027 #include "fennel/cache/TwoQVictimPolicy.h"
00028 #include "fennel/common/StatsTarget.h"
00029
00030 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/cache/Cache.cpp#14 $");
00031
00032 const DeviceId Cache::NULL_DEVICE_ID = DeviceId(0);
00033
00034 Cache::~Cache()
00035 {
00036 }
00037
00038 CacheAccessor::~CacheAccessor()
00039 {
00040 }
00041
00042 class TwoQPage : public CachePage, public TwoQVictim
00043 {
00044 public:
00045 TwoQPage(Cache &cache,PBuffer buffer)
00046 : CachePage(cache,buffer)
00047 {
00048 }
00049 };
00050
00051 SharedCache Cache::newCache(
00052 CacheParams const &cacheParams,
00053 CacheAllocator *bufferAllocator)
00054 {
00055 typedef CacheImpl<
00056 TwoQPage,
00057 TwoQVictimPolicy<TwoQPage>
00058 > TwoQCache;
00059 return SharedCache(
00060 new TwoQCache(cacheParams,bufferAllocator),
00061 ClosableObjectDestructor());
00062 }
00063
00064 SharedCache Cache::getCache()
00065 {
00066 return shared_from_this();
00067 }
00068
00069 uint Cache::getMaxLockedPages()
00070 {
00071 return getAllocatedPageCount();
00072 }
00073
00074 void Cache::setMaxLockedPages(uint)
00075 {
00076 }
00077
00078 void Cache::setTxnId(TxnId)
00079 {
00080 }
00081
00082 TxnId Cache::getTxnId() const
00083 {
00084 return IMPLICIT_TXN_ID;
00085 }
00086
00087 void Cache::writeStats(StatsTarget &target)
00088 {
00089 CacheStats stats;
00090 collectStats(stats);
00091 target.writeCounter(
00092 "CacheHits", stats.nHits);
00093 target.writeCounter(
00094 "CacheHitsSinceInit", stats.nHitsSinceInit);
00095 target.writeCounter(
00096 "CacheRequests", stats.nRequests);
00097 target.writeCounter(
00098 "CacheRequestsSinceInit", stats.nRequestsSinceInit);
00099 target.writeCounter(
00100 "CacheVictimizations", stats.nVictimizations);
00101 target.writeCounter(
00102 "CacheVictimizationsSinceInit", stats.nVictimizationsSinceInit);
00103 target.writeCounter(
00104 "CacheDirtyPages", stats.nDirtyPages);
00105 target.writeCounter(
00106 "CachePagesRead", stats.nPageReads);
00107 target.writeCounter(
00108 "CachePagesReadSinceInit", stats.nPageReadsSinceInit);
00109 target.writeCounter(
00110 "CachePagesWritten", stats.nPageWrites);
00111 target.writeCounter(
00112 "CachePagesWrittenSinceInit", stats.nPageWritesSinceInit);
00113 target.writeCounter(
00114 "CachePagePrefetchesRejected", stats.nRejectedPrefetches);
00115 target.writeCounter(
00116 "CachePagePrefetchesRejectedSinceInit",
00117 stats.nRejectedPrefetchesSinceInit);
00118 target.writeCounter(
00119 "CachePageIoRetries", stats.nIoRetries);
00120 target.writeCounter(
00121 "CachePageIoRetriesSinceInit",
00122 stats.nIoRetriesSinceInit);
00123 target.writeCounter(
00124 "CachePagesPrefetched", stats.nSuccessfulPrefetches);
00125 target.writeCounter(
00126 "CachePagesPrefetchedSinceInit",
00127 stats.nSuccessfulPrefetchesSinceInit);
00128 target.writeCounter("CacheLazyWrites", stats.nLazyWrites);
00129 target.writeCounter("CacheLazyWritesSinceInit", stats.nLazyWritesSinceInit);
00130 target.writeCounter("CacheLazyWriteCalls", stats.nLazyWriteCalls);
00131 target.writeCounter(
00132 "CacheLazyWriteCallsSinceInit",
00133 stats.nLazyWriteCallsSinceInit);
00134 target.writeCounter("CacheVictimizationWrites", stats.nVictimizationWrites);
00135 target.writeCounter(
00136 "CacheVictimizationWritesSinceInit",
00137 stats.nVictimizationWritesSinceInit);
00138 target.writeCounter("CacheCheckpointWrites", stats.nCheckpointWrites);
00139 target.writeCounter(
00140 "CacheCheckpointWritesSinceInit",
00141 stats.nCheckpointWritesSinceInit);
00142 target.writeCounter(
00143 "CachePagesAllocated", stats.nMemPagesAllocated);
00144 target.writeCounter(
00145 "CachePagesUnused", stats.nMemPagesUnused);
00146 target.writeCounter(
00147 "CachePagesAllocationLimit", stats.nMemPagesMax);
00148 }
00149
00150
00151 #ifdef __MSVC__
00152 class UnreferencedCacheStructs
00153 {
00154 LRUVictim lruVictim;
00155 };
00156 #endif
00157
00158 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/cache/Cache.cpp#14 $");
00159
00160