Class Buffer_Namespace::BufferMgr¶
-
class
BufferMgr
: public AbstractBufferMgr¶ Note(s): Forbid Copying Idiom 4.1.
Subclassed by Buffer_Namespace::CpuBufferMgr, Buffer_Namespace::GpuCudaBufferMgr
Public 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 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.
-
~BufferMgr
()¶ Destructor.
Frees the heap-allocated buffer pool memory.
-
void
reinit
()¶
-
std::string
printSlab
(size_t slab_num)¶
-
std::string
printSlabs
()¶
-
void
clearSlabs
()¶
-
std::string
printMap
()¶
-
void
printSegs
()¶
-
std::string
printSeg
(BufferList::iterator &seg_it)¶
-
std::string
keyToString
(const ChunkKey &key)¶
-
size_t
getInUseSize
()¶
-
size_t
getMaxSize
()¶
-
size_t
getAllocated
()¶
-
size_t
getMaxBufferSize
()¶
-
size_t
getMaxSlabSize
()¶
-
size_t
getPageSize
()¶
-
bool
isAllocationCapped
()¶
-
const std::vector<BufferList> &
getSlabSegments
()¶
-
AbstractBuffer *
createBuffer
(const ChunkKey &key, const size_t page_size = 0, const size_t initial_size = 0)¶ Creates a chunk with the specified key and page size.
Throws a runtime_error if the Chunk already exists.
-
void
deleteBuffer
(const ChunkKey &key, const bool purge = true)¶ Deletes the chunk with the specified key.
This method throws a runtime_error when deleting a Chunk that does not exist.
-
void
deleteBuffersWithPrefix
(const ChunkKey &key_prefix, const bool purge = true)¶
-
AbstractBuffer *
getBuffer
(const ChunkKey &key, const size_t num_bytes = 0)¶ 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.
-
bool
isBufferOnDevice
(const ChunkKey &key)¶ Puts the contents of d into the Buffer with ChunkKey key.
- Return
AbstractBuffer*
- Parameters
key
: - Unique identifier for a Chunk.d
: - An object representing the source data for the Chunk.
-
void
fetchBuffer
(const ChunkKey &key, AbstractBuffer *dest_buffer, const size_t num_bytes = 0)¶
-
AbstractBuffer *
putBuffer
(const ChunkKey &key, AbstractBuffer *d, const size_t num_bytes = 0)¶
-
void
checkpoint
()¶
-
void
checkpoint
(const int db_id, const int tb_id)¶
-
void
removeTableRelatedDS
(const int db_id, const int table_id)¶
-
AbstractBuffer *
alloc
(const size_t num_bytes = 0)¶ client is responsible for deleting memory allocated for b->mem_
-
void
free
(AbstractBuffer *buffer)¶
-
size_t
size
()¶ Returns the total number of bytes allocated.
-
size_t
getNumChunks
()¶
-
BufferList::iterator
reserveBuffer
(BufferList::iterator &seg_it, const size_t num_bytes)¶
-
void
getChunkMetadataVecForKeyPrefix
(ChunkMetadataVector &chunk_metadata_vec, const ChunkKey &key_prefix)¶
Protected Attributes
-
const size_t
max_buffer_pool_size_
¶
-
const size_t
min_slab_size_
¶ max number of bytes allocated for the buffer pool
-
const size_t
max_slab_size_
¶ minimum size of the individual memory allocations that compose the buffer pool (up to maxBufferSize_)
-
const size_t
page_size_
¶ size of the individual memory allocations that compose the buffer pool (up to maxBufferSize_)
-
std::vector<int8_t *>
slabs_
¶
-
std::vector<BufferList>
slab_segments_
¶ vector of beginning memory addresses for each allocation of the buffer pool
Private Functions
-
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
()¶
-
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.
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
- Return
An iterator to the reserved buffer. We guarantee that this buffer won’t be evicted by PINNING it - caller should change this to USED if applicable
Private Members
-
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
current_max_slab_page_size_
¶
-
bool
allocations_capped_
¶
-
AbstractBufferMgr *
parent_mgr_
¶
-
int
max_buffer_id_
¶
-
unsigned int
buffer_epoch_
¶
-
BufferList
unsized_segs_
¶
-