27 #define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED 1
44 VLOG(1) <<
"Failed to allocate " << num_bytes <<
" bytes";
45 VLOG(1) << boost::stacktrace::stacktrace();
49 VLOG(1) <<
"Failed with OutOfMemory, condition " << err;
50 VLOG(1) << boost::stacktrace::stacktrace();
55 VLOG(1) <<
"Failed to allocate " << num_bytes <<
" bytes with condition " << err;
56 VLOG(1) << boost::stacktrace::stacktrace();
62 return err +
": Failed to allocate " +
std::to_string(num_bytes) +
" bytes";
64 return "Failed to allocate memory with condition " + err;
72 :
OutOfMemory(
"FailedToCreateFirstSlab", num_bytes) {}
85 using namespace Data_Namespace;
87 namespace Buffer_Namespace {
101 const size_t max_buffer_size,
102 const size_t min_slab_size,
103 const size_t max_slab_size,
104 const size_t default_slab_size,
105 const size_t page_size,
106 AbstractBufferMgr* parent_mgr = 0);
111 std::string printSlab(
size_t slab_num);
112 std::string printSlabs()
override;
115 std::string printMap();
117 std::string printSeg(BufferList::iterator& seg_it);
119 size_t getInUseSize()
override;
120 size_t getMaxSize()
override;
121 size_t getAllocated()
override;
122 size_t getMaxBufferSize();
123 size_t getMaxSlabSize();
124 size_t getPageSize();
125 bool isAllocationCapped()
override;
126 const std::vector<BufferList>& getSlabSegments();
130 const size_t page_size = 0,
131 const size_t initial_size = 0)
override;
134 void deleteBuffer(
const ChunkKey& key,
const bool purge =
true)
override;
135 void deleteBuffersWithPrefix(
const ChunkKey& key_prefix,
136 const bool purge =
true)
override;
147 bool isBufferOnDevice(
const ChunkKey& key)
override;
148 void fetchBuffer(
const ChunkKey& key,
150 const size_t num_bytes = 0)
override;
153 const size_t num_bytes = 0)
override;
154 void checkpoint()
override;
155 void checkpoint(
const int db_id,
const int tb_id)
override;
156 void removeTableRelatedDS(
const int db_id,
const int table_id)
override;
164 size_t getNumChunks()
override;
166 BufferList::iterator reserveBuffer(BufferList::iterator& seg_it,
167 const size_t num_bytes);
169 const ChunkKey& key_prefix)
override;
175 const size_t max_slab_size_;
180 const size_t page_size_;
183 std::vector<BufferList> slab_segments_;
189 void removeSegment(BufferList::iterator& seg_it);
190 BufferList::iterator findFreeBufferInSlab(
const size_t slab_num,
191 const size_t num_pages_requested);
193 virtual void addSlab(
const size_t slab_size) = 0;
194 virtual void freeAllMem() = 0;
195 virtual void allocateBuffer(BufferList::iterator seg_it,
196 const size_t page_size,
197 const size_t num_bytes) = 0;
200 std::string keyToString(
const ChunkKey& key);
222 BufferList::iterator evict(BufferList::iterator& evict_start,
223 const size_t num_pages_requested,
238 BufferList::iterator findFreeBuffer(
size_t num_bytes);
size_t max_buffer_pool_num_pages_
size_t min_num_pages_per_slab_
std::string parse_error_str(const std::string &err, const size_t num_bytes=0)
AbstractBufferMgr * parent_mgr_
std::vector< int > ChunkKey
size_t current_max_num_pages_per_slab_
const size_t max_buffer_pool_size_
size_t max_num_pages_per_slab_
size_t num_pages_allocated_
unsigned int buffer_epoch_
OutOfMemory(size_t num_bytes)
std::map< ChunkKey, BufferList::iterator > chunk_index_
const size_t min_slab_size_
max number of bytes allocated for the buffer pool
Note(s): Forbid Copying Idiom 4.1.
OutOfMemory(const std::string &err)
TooBigForSlab(size_t num_bytes)
An AbstractBuffer is a unit of data management for a data manager.
OutOfMemory(const std::string &err, size_t num_bytes)
std::mutex buffer_id_mutex_
std::mutex sized_segs_mutex_
std::mutex unsized_segs_mutex_
FailedToCreateFirstSlab(size_t num_bytes)
const size_t default_slab_size_
size_t default_num_pages_per_slab_
FailedToCreateSlab(size_t num_bytes)
std::mutex chunk_index_mutex_
std::vector< int8_t * > slabs_
std::list< BufferSeg > BufferList