OmniSciDB
a5dc49c757
|
Note(s): Forbid Copying Idiom 4.1. More...
#include <BufferMgr.h>
Public Member Functions | |
BufferMgr (const int device_id, const size_t max_buffer_size, const size_t min_slab_size, const size_t max_slab_size, const size_t default_slab_size, const size_t page_size, AbstractBufferMgr *parent_mgr=0) | |
Constructs a BufferMgr object that allocates memSize bytes. More... | |
~BufferMgr () override | |
Destructor. More... | |
std::string | printSlab (size_t slab_num) |
std::string | printSlabs () override |
void | clearSlabs () |
std::string | printMap () |
void | printSegs () |
std::string | printSeg (BufferList::iterator &seg_it) |
size_t | getInUseSize () override |
size_t | getMaxSize () override |
size_t | getAllocated () override |
size_t | getMaxBufferSize () |
size_t | getMaxSlabSize () |
size_t | getPageSize () |
bool | isAllocationCapped () override |
const std::vector< BufferList > & | getSlabSegments () |
AbstractBuffer * | createBuffer (const ChunkKey &key, const size_t page_size=0, const size_t initial_size=0) override |
Creates a chunk with the specified key and page size. More... | |
void | deleteBuffer (const ChunkKey &key, const bool purge=true) override |
Deletes the chunk with the specified key. More... | |
void | deleteBuffersWithPrefix (const ChunkKey &key_prefix, const bool purge=true) override |
AbstractBuffer * | getBuffer (const ChunkKey &key, const size_t num_bytes=0) override |
Returns the a pointer to the chunk with the specified key. More... | |
bool | isBufferOnDevice (const ChunkKey &key) override |
Puts the contents of d into the Buffer with ChunkKey key. More... | |
void | fetchBuffer (const ChunkKey &key, AbstractBuffer *dest_buffer, const size_t num_bytes=0) override |
AbstractBuffer * | putBuffer (const ChunkKey &key, AbstractBuffer *d, const size_t num_bytes=0) override |
void | checkpoint () override |
void | checkpoint (const int db_id, const int tb_id) override |
void | removeTableRelatedDS (const int db_id, const int table_id) override |
AbstractBuffer * | alloc (const size_t num_bytes=0) override |
client is responsible for deleting memory allocated for b->mem_ More... | |
void | free (AbstractBuffer *buffer) override |
size_t | size () |
Returns the total number of bytes allocated. More... | |
size_t | getNumChunks () override |
BufferList::iterator | reserveBuffer (BufferList::iterator &seg_it, const size_t num_bytes) |
void | getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunk_metadata_vec, const ChunkKey &key_prefix) override |
Protected Attributes | |
const size_t | max_buffer_pool_size_ |
const size_t | min_slab_size_ |
max number of bytes allocated for the buffer pool More... | |
const size_t | max_slab_size_ |
const size_t | default_slab_size_ |
const size_t | page_size_ |
std::vector< int8_t * > | slabs_ |
std::vector< BufferList > | slab_segments_ |
Private Member Functions | |
BufferMgr (const BufferMgr &) | |
BufferMgr & | operator= (const BufferMgr &) |
void | removeSegment (BufferList::iterator &seg_it) |
BufferList::iterator | findFreeBufferInSlab (const size_t slab_num, const size_t num_pages_requested) |
int | getBufferId () |
virtual void | addSlab (const size_t slab_size)=0 |
virtual void | freeAllMem ()=0 |
virtual void | allocateBuffer (BufferList::iterator seg_it, const size_t page_size, const size_t num_bytes)=0 |
void | clear () |
void | reinit () |
std::string | keyToString (const ChunkKey &key) |
BufferList::iterator | evict (BufferList::iterator &evict_start, const size_t num_pages_requested, const int slab_num) |
BufferList::iterator | findFreeBuffer (size_t num_bytes) |
Gets a buffer of required size and returns an iterator to it. More... | |
Private Attributes | |
std::mutex | chunk_index_mutex_ |
std::mutex | sized_segs_mutex_ |
std::mutex | unsized_segs_mutex_ |
std::mutex | buffer_id_mutex_ |
std::mutex | global_mutex_ |
std::map< ChunkKey, BufferList::iterator > | chunk_index_ |
size_t | max_buffer_pool_num_pages_ |
size_t | num_pages_allocated_ |
size_t | min_num_pages_per_slab_ |
size_t | max_num_pages_per_slab_ |
size_t | default_num_pages_per_slab_ |
size_t | current_max_num_pages_per_slab_ |
bool | allocations_capped_ |
AbstractBufferMgr * | parent_mgr_ |
int | max_buffer_id_ |
unsigned int | buffer_epoch_ |
BufferList | unsized_segs_ |
Note(s): Forbid Copying Idiom 4.1.
Definition at line 96 of file BufferMgr.h.
Buffer_Namespace::BufferMgr::BufferMgr | ( | const int | device_id, |
const size_t | max_buffer_size, | ||
const size_t | min_slab_size, | ||
const size_t | max_slab_size, | ||
const size_t | default_slab_size, | ||
const size_t | page_size, | ||
AbstractBufferMgr * | parent_mgr = 0 |
||
) |
Constructs a BufferMgr object that allocates memSize bytes.
Allocates memSize bytes for the buffer pool and initializes the free memory map.
Definition at line 47 of file BufferMgr.cpp.
References CHECK_EQ, CHECK_GE, CHECK_GT, CHECK_LE, current_max_num_pages_per_slab_, default_num_pages_per_slab_, default_slab_size_, max_buffer_pool_num_pages_, max_buffer_pool_size_, max_num_pages_per_slab_, max_slab_size_, min_num_pages_per_slab_, min_slab_size_, and page_size_.
|
override |
Destructor.
Frees the heap-allocated buffer pool memory.
Definition at line 88 of file BufferMgr.cpp.
References clear().
|
private |
|
privatepure virtual |
Implemented in Buffer_Namespace::CpuBufferMgr, Buffer_Namespace::TieredCpuBufferMgr, and Buffer_Namespace::GpuCudaBufferMgr.
Referenced by findFreeBuffer().
|
override |
client is responsible for deleting memory allocated for b->mem_
Definition at line 894 of file BufferMgr.cpp.
References createBuffer(), getBufferId(), global_mutex_, and page_size_.
|
privatepure virtual |
Implemented in Buffer_Namespace::CpuBufferMgr, and Buffer_Namespace::GpuCudaBufferMgr.
Referenced by createBuffer().
|
override |
Definition at line 696 of file BufferMgr.cpp.
References chunk_index_, chunk_index_mutex_, global_mutex_, and parent_mgr_.
|
override |
Definition at line 710 of file BufferMgr.cpp.
References chunk_index_, chunk_index_mutex_, global_mutex_, and parent_mgr_.
|
private |
Definition at line 100 of file BufferMgr.cpp.
References buffer_epoch_, chunk_index_, chunk_index_mutex_, sized_segs_mutex_, slab_segments_, slabs_, unsized_segs_, and unsized_segs_mutex_.
Referenced by clearSlabs(), and ~BufferMgr().
void Buffer_Namespace::BufferMgr::clearSlabs | ( | ) |
Definition at line 489 of file BufferMgr.cpp.
References clear(), deleteBuffer(), Buffer_Namespace::FREE, freeAllMem(), global_mutex_, logger::INFO, LOG, reinit(), and slab_segments_.
|
override |
Creates a chunk with the specified key and page size.
Throws a runtime_error if the Chunk already exists.
Definition at line 117 of file BufferMgr.cpp.
References allocateBuffer(), CHECK, chunk_index_, chunk_index_mutex_, deleteBuffer(), page_size_, unsized_segs_, unsized_segs_mutex_, and Buffer_Namespace::USED.
Referenced by alloc(), fetchBuffer(), getBuffer(), and putBuffer().
|
override |
Deletes the chunk with the specified key.
This method throws a runtime_error when deleting a Chunk that does not exist.
Definition at line 618 of file BufferMgr.cpp.
References CHECK, chunk_index_, chunk_index_mutex_, removeSegment(), and sized_segs_mutex_.
Referenced by clearSlabs(), createBuffer(), fetchBuffer(), free(), and getBuffer().
|
override |
Definition at line 636 of file BufferMgr.cpp.
References chunk_index_, chunk_index_mutex_, removeSegment(), and sized_segs_mutex_.
|
private |
Definition at line 159 of file BufferMgr.cpp.
References buffer_epoch_, CHECK, chunk_index_, Buffer_Namespace::FREE, Buffer_Namespace::BufferSeg::slab_num, slab_segments_, and Buffer_Namespace::USED.
Referenced by findFreeBuffer().
|
override |
Definition at line 791 of file BufferMgr.cpp.
References CHECK, chunk_index_, chunk_index_mutex_, Data_Namespace::AbstractBuffer::copyTo(), createBuffer(), deleteBuffer(), logger::FATAL, global_mutex_, keyToString(), LOG, page_size_, parent_mgr_, Data_Namespace::AbstractBuffer::pin(), Data_Namespace::AbstractBuffer::size(), sized_segs_mutex_, Data_Namespace::AbstractBuffer::unPin(), VLOG, and logger::WARNING.
|
private |
Gets a buffer of required size and returns an iterator to it.
If possible, this function will just select a free buffer of sufficient size and use that. If not, it will evict as many non-pinned but used buffers as needed to have enough space for the buffer
Definition at line 288 of file BufferMgr.cpp.
References addSlab(), allocations_capped_, CHECK_GT, current_max_num_pages_per_slab_, default_num_pages_per_slab_, logger::ERROR, evict(), measure< TimeT >::execution(), findFreeBufferInSlab(), logger::INFO, LOG, max_buffer_pool_num_pages_, max_num_pages_per_slab_, min_num_pages_per_slab_, num_pages_allocated_, page_size_, printSlabs(), score, slab_segments_, Buffer_Namespace::USED, and VLOG.
Referenced by reserveBuffer().
|
private |
Definition at line 260 of file BufferMgr.cpp.
References buffer_epoch_, Buffer_Namespace::FREE, slab_segments_, and Buffer_Namespace::USED.
Referenced by findFreeBuffer().
|
override |
Definition at line 900 of file BufferMgr.cpp.
References deleteBuffer(), logger::FATAL, global_mutex_, LOG, and Buffer_Namespace::Buffer::seg_it_.
|
privatepure virtual |
Implemented in Buffer_Namespace::CpuBufferMgr, Buffer_Namespace::TieredCpuBufferMgr, and Buffer_Namespace::GpuCudaBufferMgr.
Referenced by clearSlabs().
|
override |
Definition at line 520 of file BufferMgr.cpp.
References num_pages_allocated_, and page_size_.
Referenced by Data_Namespace::DataMgr::getMemoryInfoUnlocked().
|
override |
Returns the a pointer to the chunk with the specified key.
Returns a pointer to the Buffer holding the chunk, if it exists; otherwise, throws a runtime_error.
Definition at line 741 of file BufferMgr.cpp.
References buffer_epoch_, CHECK, chunk_index_, chunk_index_mutex_, createBuffer(), deleteBuffer(), logger::FATAL, global_mutex_, keyToString(), LOG, page_size_, parent_mgr_, sized_segs_mutex_, VLOG, and logger::WARNING.
|
private |
Definition at line 888 of file BufferMgr.cpp.
References buffer_id_mutex_, and max_buffer_id_.
Referenced by alloc().
|
override |
Definition at line 926 of file BufferMgr.cpp.
References logger::FATAL, and LOG.
|
override |
Definition at line 534 of file BufferMgr.cpp.
References Buffer_Namespace::FREE, page_size_, and slab_segments_.
size_t Buffer_Namespace::BufferMgr::getMaxBufferSize | ( | ) |
Definition at line 918 of file BufferMgr.cpp.
References max_buffer_pool_size_.
|
override |
Definition at line 515 of file BufferMgr.cpp.
References max_buffer_pool_num_pages_, and page_size_.
Referenced by Data_Namespace::DataMgr::getCpuBufferPoolSize(), and Data_Namespace::DataMgr::getMemoryInfoUnlocked().
size_t Buffer_Namespace::BufferMgr::getMaxSlabSize | ( | ) |
|
override |
Definition at line 909 of file BufferMgr.cpp.
References chunk_index_, and chunk_index_mutex_.
size_t Buffer_Namespace::BufferMgr::getPageSize | ( | ) |
Definition at line 529 of file BufferMgr.cpp.
References page_size_.
Referenced by Data_Namespace::DataMgr::getMemoryInfoUnlocked().
const std::vector< BufferList > & Buffer_Namespace::BufferMgr::getSlabSegments | ( | ) |
Definition at line 931 of file BufferMgr.cpp.
References slab_segments_.
Referenced by Data_Namespace::DataMgr::getMemoryInfoUnlocked().
|
override |
Definition at line 525 of file BufferMgr.cpp.
References allocations_capped_.
Referenced by Data_Namespace::DataMgr::getMemoryInfoUnlocked().
|
override |
Puts the contents of d into the Buffer with ChunkKey key.
key | - Unique identifier for a Chunk. |
d | - An object representing the source data for the Chunk. |
Definition at line 608 of file BufferMgr.cpp.
References chunk_index_, and chunk_index_mutex_.
|
private |
Definition at line 36 of file BufferMgr.cpp.
Referenced by fetchBuffer(), and getBuffer().
std::string Buffer_Namespace::BufferMgr::printMap | ( | ) |
Definition at line 567 of file BufferMgr.cpp.
References chunk_index_, chunk_index_mutex_, and printSeg().
std::string Buffer_Namespace::BufferMgr::printSeg | ( | BufferList::iterator & | seg_it | ) |
Definition at line 546 of file BufferMgr.cpp.
References Buffer_Namespace::FREE.
Referenced by printMap(), and printSegs().
void Buffer_Namespace::BufferMgr::printSegs | ( | ) |
Definition at line 589 of file BufferMgr.cpp.
References logger::INFO, LOG, printSeg(), and slab_segments_.
std::string Buffer_Namespace::BufferMgr::printSlab | ( | size_t | slab_num | ) |
Definition at line 447 of file BufferMgr.cpp.
References Buffer_Namespace::FREE, and slab_segments_.
Referenced by printSlabs().
|
override |
Definition at line 476 of file BufferMgr.cpp.
References printSlab(), and slab_segments_.
Referenced by findFreeBuffer().
|
override |
Definition at line 849 of file BufferMgr.cpp.
References Data_Namespace::AbstractBuffer::append(), CHECK, chunk_index_, chunk_index_mutex_, Data_Namespace::AbstractBuffer::clearDirtyBits(), createBuffer(), Data_Namespace::AbstractBuffer::getDeviceId(), Data_Namespace::AbstractBuffer::getMemoryPtr(), Data_Namespace::AbstractBuffer::getType(), Data_Namespace::AbstractBuffer::isAppended(), Data_Namespace::AbstractBuffer::isDirty(), Data_Namespace::AbstractBuffer::isUpdated(), page_size_, Data_Namespace::AbstractBuffer::size(), Data_Namespace::AbstractBuffer::syncEncoder(), UNREACHABLE, and Data_Namespace::AbstractBuffer::write().
|
private |
Definition at line 92 of file BufferMgr.cpp.
References allocations_capped_, current_max_num_pages_per_slab_, max_num_pages_per_slab_, and num_pages_allocated_.
Referenced by clearSlabs().
|
private |
Definition at line 665 of file BufferMgr.cpp.
References Buffer_Namespace::FREE, slab_segments_, unsized_segs_, and unsized_segs_mutex_.
Referenced by deleteBuffer(), deleteBuffersWithPrefix(), and reserveBuffer().
|
override |
Definition at line 935 of file BufferMgr.cpp.
References UNREACHABLE.
BufferList::iterator Buffer_Namespace::BufferMgr::reserveBuffer | ( | BufferList::iterator & | seg_it, |
const size_t | num_bytes | ||
) |
Definition at line 205 of file BufferMgr.cpp.
References chunk_index_, chunk_index_mutex_, findFreeBuffer(), Buffer_Namespace::FREE, page_size_, removeSegment(), slab_segments_, and slabs_.
Referenced by Buffer_Namespace::Buffer::reserve().
size_t Buffer_Namespace::BufferMgr::size | ( | ) |
Returns the total number of bytes allocated.
Definition at line 914 of file BufferMgr.cpp.
References num_pages_allocated_.
|
private |
Definition at line 215 of file BufferMgr.h.
Referenced by findFreeBuffer(), isAllocationCapped(), and reinit().
|
private |
Definition at line 218 of file BufferMgr.h.
Referenced by clear(), evict(), findFreeBufferInSlab(), and getBuffer().
|
private |
Definition at line 205 of file BufferMgr.h.
Referenced by getBufferId().
|
private |
Definition at line 208 of file BufferMgr.h.
Referenced by checkpoint(), clear(), createBuffer(), deleteBuffer(), deleteBuffersWithPrefix(), evict(), fetchBuffer(), getBuffer(), getNumChunks(), isBufferOnDevice(), printMap(), putBuffer(), and reserveBuffer().
|
private |
Definition at line 202 of file BufferMgr.h.
Referenced by checkpoint(), clear(), createBuffer(), deleteBuffer(), deleteBuffersWithPrefix(), fetchBuffer(), getBuffer(), getNumChunks(), isBufferOnDevice(), printMap(), putBuffer(), and reserveBuffer().
|
private |
Definition at line 214 of file BufferMgr.h.
Referenced by BufferMgr(), findFreeBuffer(), and reinit().
|
private |
Definition at line 213 of file BufferMgr.h.
Referenced by BufferMgr(), and findFreeBuffer().
|
protected |
max size of the individual memory allocations that compose the buffer pool (up to maxBufferSize_)
Definition at line 179 of file BufferMgr.h.
Referenced by BufferMgr(), Buffer_Namespace::TieredCpuBufferMgr::initializeMem(), Buffer_Namespace::CpuBufferMgr::initializeMem(), and Buffer_Namespace::TieredCpuBufferMgr::TieredCpuBufferMgr().
|
private |
Definition at line 206 of file BufferMgr.h.
Referenced by alloc(), checkpoint(), clearSlabs(), fetchBuffer(), free(), and getBuffer().
|
private |
Definition at line 217 of file BufferMgr.h.
Referenced by getBufferId().
|
private |
Definition at line 209 of file BufferMgr.h.
Referenced by BufferMgr(), findFreeBuffer(), and getMaxSize().
|
protected |
Definition at line 173 of file BufferMgr.h.
Referenced by BufferMgr(), and getMaxBufferSize().
|
private |
Definition at line 212 of file BufferMgr.h.
Referenced by BufferMgr(), findFreeBuffer(), and reinit().
|
protected |
minimum size of the individual memory allocations that compose the buffer pool (up to maxBufferSize_)
Definition at line 176 of file BufferMgr.h.
Referenced by BufferMgr(), and getMaxSlabSize().
|
private |
Definition at line 211 of file BufferMgr.h.
Referenced by BufferMgr(), and findFreeBuffer().
|
protected |
max number of bytes allocated for the buffer pool
Definition at line 174 of file BufferMgr.h.
Referenced by BufferMgr().
|
private |
Definition at line 210 of file BufferMgr.h.
Referenced by findFreeBuffer(), getAllocated(), reinit(), and size().
|
protected |
default size of the individual memory allocations that compose the buffer pool (up to maxBufferSize_)
Definition at line 181 of file BufferMgr.h.
Referenced by Buffer_Namespace::GpuCudaBufferMgr::addSlab(), Buffer_Namespace::TieredCpuBufferMgr::addSlab(), Buffer_Namespace::CpuBufferMgr::addSlab(), alloc(), BufferMgr(), createBuffer(), fetchBuffer(), findFreeBuffer(), getAllocated(), getBuffer(), getInUseSize(), getMaxSize(), getPageSize(), putBuffer(), and reserveBuffer().
|
private |
Definition at line 216 of file BufferMgr.h.
Referenced by checkpoint(), fetchBuffer(), and getBuffer().
|
private |
Definition at line 203 of file BufferMgr.h.
Referenced by clear(), deleteBuffer(), deleteBuffersWithPrefix(), fetchBuffer(), and getBuffer().
|
protected |
vector of beginning memory addresses for each allocation of the buffer pool
Definition at line 184 of file BufferMgr.h.
Referenced by Buffer_Namespace::GpuCudaBufferMgr::addSlab(), Buffer_Namespace::TieredCpuBufferMgr::addSlab(), Buffer_Namespace::CpuBufferMgr::addSlab(), clear(), clearSlabs(), evict(), findFreeBuffer(), findFreeBufferInSlab(), getInUseSize(), getSlabSegments(), printSegs(), printSlab(), printSlabs(), removeSegment(), and reserveBuffer().
|
protected |
Definition at line 182 of file BufferMgr.h.
Referenced by Buffer_Namespace::GpuCudaBufferMgr::addSlab(), Buffer_Namespace::TieredCpuBufferMgr::addSlab(), Buffer_Namespace::CpuBufferMgr::addSlab(), clear(), Buffer_Namespace::GpuCudaBufferMgr::freeAllMem(), and reserveBuffer().
|
private |
Definition at line 220 of file BufferMgr.h.
Referenced by clear(), createBuffer(), and removeSegment().
|
private |
Definition at line 204 of file BufferMgr.h.
Referenced by clear(), createBuffer(), and removeSegment().