A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
|
#include <PageCache.h>
Private Attributes | |
unordered_map< CacheKey, PDBPagePtr, CacheKeyHash, CacheKeyEqual > * | cache |
pdb::PDBLoggerPtr | logger |
ConfigurationPtr | conf |
size_t | size |
size_t | maxSize |
size_t | warnSize |
size_t | evictStopSize |
pthread_rwlock_t | evictionAndFlushLock |
pthread_mutex_t | cacheMutex |
pthread_mutex_t | evictionMutex |
bool | inEviction |
pdb::PDBWorkerQueuePtr | workers |
pdb::PDBWorkPtr | evictWork |
long | accessCount |
pthread_mutex_t | countLock |
SharedMemPtr | shm |
PageCircularBufferPtr | flushBuffer |
CacheStrategy | strategy |
vector< list< LocalitySetPtr > * > * | priorityList |
This class wraps a global page cache adopting multiple eviction policy, and by default it uses MRU. Each slave node will have one page cache that can be accessed by frontend and forked backend via shared memory.
Typical scenario for scanning data Step 1. Frontend will load pages to cache by scanning partitions and input buffer Step 2. For each loaded page, frontend will pin it, and tell backend about the location of the pinned page Step 3. Backend will tell frontend to unpin a page
Typical scenario for output data Step 1. Backend will tell frontend to create a temp set or a user set, depending on output data's lifetime and visibility; Step 2. Backend will tell frontend to add a new page and pin it as dirty; Step 3. Backend will tell frontend to unpin the page; Step 4. Backend will tell frontend to pin the page again;(at this time, page may be flushed to disk file, and needs to load it to cache first) Step 5. Backend will tell frontend to unpin the page; Step 6. Backend will tell frontend to remove a temp set.
Definition at line 137 of file PageCache.h.
PageCache::PageCache | ( | ConfigurationPtr | conf, |
pdb::PDBWorkerQueuePtr | workers, | ||
PageCircularBufferPtr | flushBuffer, | ||
pdb::PDBLoggerPtr | logger, | ||
SharedMemPtr | shm, | ||
CacheStrategy | strategy = UnifiedMRU |
||
) |
Definition at line 36 of file PageCache.cc.
PageCache::~PageCache | ( | ) |
Definition at line 87 of file PageCache.cc.
void PageCache::addLocalitySetToPriorityList | ( | LocalitySetPtr | set, |
PriorityLevel | level | ||
) |
Definition at line 857 of file PageCache.cc.
char * PageCache::allocateBufferFromSharedMemoryBlocking | ( | size_t | size, |
int & | alignOffset | ||
) |
Definition at line 122 of file PageCache.cc.
PDBPagePtr PageCache::buildAndCachePageFromFileHandle | ( | int | handle, |
size_t | size, | ||
NodeID | nodeId, | ||
DatabaseID | dbId, | ||
UserTypeID | typeId, | ||
SetID | setId, | ||
PageID | pageId | ||
) |
Definition at line 176 of file PageCache.cc.
PDBPagePtr PageCache::buildPageFromSharedMemoryData | ( | PDBFilePtr | file, |
char * | pageData, | ||
FilePartitionID | partitionId, | ||
unsigned int | pageSeqInPartition, | ||
int | internalOffset, | ||
size_t | pageSize = DEFAULT_PAGE_SIZE |
||
) |
Definition at line 196 of file PageCache.cc.
void PageCache::cachePage | ( | PDBPagePtr | page, |
LocalitySet * | set = nullptr |
||
) |
bool PageCache::containsPage | ( | CacheKey | key | ) |
Definition at line 526 of file PageCache.cc.
bool PageCache::decPageRefCount | ( | CacheKey | key | ) |
Definition at line 516 of file PageCache.cc.
void PageCache::evict | ( | ) |
int PageCache::evictAllDirtyPages | ( | ) |
Definition at line 578 of file PageCache.cc.
void PageCache::evictionLock | ( | ) |
Definition at line 157 of file PageCache.cc.
void PageCache::evictionUnlock | ( | ) |
Definition at line 162 of file PageCache.cc.
bool PageCache::evictPage | ( | CacheKey | key, |
bool | tryFlushOrNot = true |
||
) |
Definition at line 642 of file PageCache.cc.
bool PageCache::evictPage | ( | PDBPagePtr | page, |
LocalitySetPtr | set = nullptr |
||
) |
Definition at line 711 of file PageCache.cc.
void PageCache::flushLock | ( | ) |
Definition at line 167 of file PageCache.cc.
bool PageCache::flushPageWithoutEviction | ( | CacheKey | key | ) |
Definition at line 621 of file PageCache.cc.
void PageCache::flushUnlock | ( | ) |
Definition at line 172 of file PageCache.cc.
bool PageCache::freePage | ( | PDBPagePtr | page | ) |
Definition at line 304 of file PageCache.cc.
void PageCache::getAndSetEvictStopSize | ( | unsigned int | numSets, |
double | evictThreshold | ||
) |
Definition at line 851 of file PageCache.cc.
void PageCache::getAndSetWarnSize | ( | unsigned int | numSets, |
double | warnThreshold | ||
) |
Definition at line 845 of file PageCache.cc.
|
inline |
Definition at line 294 of file PageCache.h.
PDBPagePtr PageCache::getNewPage | ( | NodeID | nodeId, |
CacheKey | key, | ||
LocalitySet * | set = nullptr , |
||
size_t | pageSize = DEFAULT_PAGE_SIZE |
||
) |
Definition at line 474 of file PageCache.cc.
PDBPagePtr PageCache::getNewPageNonBlocking | ( | NodeID | nodeId, |
CacheKey | key, | ||
LocalitySet * | set = nullptr , |
||
size_t | pageSize = DEFAULT_PAGE_SIZE |
||
) |
Definition at line 434 of file PageCache.cc.
PDBPagePtr PageCache::getPage | ( | SequenceFilePtr | file, |
PageID | pageId | ||
) |
Definition at line 401 of file PageCache.cc.
PDBPagePtr PageCache::getPage | ( | PartitionedFilePtr | file, |
FilePartitionID | partitionId, | ||
unsigned int | pageSeqInPartition, | ||
PageID | pageId, | ||
bool | sequential, | ||
LocalitySet * | set = nullptr |
||
) |
PDBPagePtr PageCache::getPage | ( | CacheKey | key, |
LocalitySet * | set = nullptr |
||
) |
PDBPagePtr PageCache::loadPage | ( | SequenceFilePtr | file, |
PageID | pageId | ||
) |
Definition at line 269 of file PageCache.cc.
PDBPagePtr PageCache::loadPage | ( | PDBFilePtr | file, |
FilePartitionID | partitionId, | ||
unsigned int | pageSeqInPartition, | ||
bool | sequential | ||
) |
void PageCache::pin | ( | LocalitySetPtr | set, |
LocalitySetReplacementPolicy | policy, | ||
OperationType | operationType | ||
) |
Definition at line 865 of file PageCache.cc.
void PageCache::removeLocalitySetFromPriorityList | ( | LocalitySetPtr | set, |
PriorityLevel | level | ||
) |
Definition at line 861 of file PageCache.cc.
bool PageCache::removePage | ( | CacheKey | key | ) |
Definition at line 289 of file PageCache.cc.
void PageCache::runEviction | ( | ) |
Definition at line 726 of file PageCache.cc.
char * PageCache::tryAllocateBufferFromSharedMemory | ( | size_t | size, |
int & | alignOffset | ||
) |
Definition at line 146 of file PageCache.cc.
void PageCache::unpin | ( | LocalitySetPtr | set | ) |
Definition at line 882 of file PageCache.cc.
int PageCache::unpinAndEvictAllDirtyPages | ( | ) |
Definition at line 533 of file PageCache.cc.
|
private |
Definition at line 317 of file PageCache.h.
|
private |
Definition at line 304 of file PageCache.h.
|
private |
Definition at line 312 of file PageCache.h.
|
private |
Definition at line 306 of file PageCache.h.
|
private |
Definition at line 318 of file PageCache.h.
|
private |
Definition at line 311 of file PageCache.h.
|
private |
Definition at line 313 of file PageCache.h.
|
private |
Definition at line 310 of file PageCache.h.
|
private |
Definition at line 316 of file PageCache.h.
|
private |
Definition at line 320 of file PageCache.h.
|
private |
Definition at line 314 of file PageCache.h.
|
private |
Definition at line 305 of file PageCache.h.
|
private |
Definition at line 308 of file PageCache.h.
|
private |
Definition at line 330 of file PageCache.h.
|
private |
Definition at line 319 of file PageCache.h.
|
private |
Definition at line 307 of file PageCache.h.
|
private |
Definition at line 321 of file PageCache.h.
|
private |
Definition at line 309 of file PageCache.h.
|
private |
Definition at line 315 of file PageCache.h.