OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DataMgr.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #include "DataMgr/DataMgr.h"
25 #include "CudaMgr/CudaMgr.h"
27 #include "FileMgr/GlobalFileMgr.h"
29 
30 #ifdef __APPLE__
31 #include <sys/sysctl.h>
32 #include <sys/types.h>
33 #endif
34 
35 #include <boost/filesystem.hpp>
36 
37 #include <algorithm>
38 #include <limits>
39 
40 extern bool g_enable_fsi;
41 
42 namespace Data_Namespace {
43 
44 DataMgr::DataMgr(const std::string& dataDir,
45  const SystemParameters& system_parameters,
46  std::unique_ptr<CudaMgr_Namespace::CudaMgr> cudaMgr,
47  const bool useGpus,
48  const size_t reservedGpuMem,
49  const size_t numReaderThreads,
50  const DiskCacheConfig cache_config)
51  : cudaMgr_{std::move(cudaMgr)}
52  , dataDir_{dataDir}
53  , hasGpus_{false}
54  , reservedGpuMem_{reservedGpuMem} {
55  if (useGpus) {
56  if (cudaMgr_) {
57  hasGpus_ = true;
58  } else {
59  LOG(ERROR) << "CudaMgr instance is invalid, falling back to CPU-only mode.";
60  hasGpus_ = false;
61  }
62  } else {
63  // NOTE: useGpus == false with a valid cudaMgr is a potentially valid configuration.
64  // i.e. QueryEngine can be set to cpu-only for a cuda-enabled build, but still have
65  // rendering enabled. The renderer would require a CudaMgr in this case, in addition
66  // to a GpuCudaBufferMgr for cuda-backed thrust allocations.
67  // We're still setting hasGpus_ to false in that case tho to enforce cpu-only query
68  // execution.
69  hasGpus_ = false;
70  }
71 
72  populateMgrs(system_parameters, numReaderThreads, cache_config);
73  createTopLevelMetadata();
74 }
75 
77  int numLevels = bufferMgrs_.size();
78  for (int level = numLevels - 1; level >= 0; --level) {
79  for (size_t device = 0; device < bufferMgrs_[level].size(); device++) {
80  delete bufferMgrs_[level][device];
81  }
82  }
83 }
84 
86  SystemMemoryUsage usage;
87 
88 #ifdef __linux__
89 
90  // Determine Linux available memory and total memory.
91  // Available memory is different from free memory because
92  // when Linux sees free memory, it tries to use it for
93  // stuff like disk caching. However, the memory is not
94  // reserved and is still available to be allocated by
95  // user processes.
96  // Parsing /proc/meminfo for this info isn't very elegant
97  // but as a virtual file it should be reasonably fast.
98  // See also:
99  // https://github.com/torvalds/linux/commit/34e431b0ae398fc54ea69ff85ec700722c9da773
101  usage.free = mi["MemAvailable"];
102  usage.total = mi["MemTotal"];
103 
104  // Determine process memory in use.
105  // See also:
106  // https://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-runtime-using-c
107  // http://man7.org/linux/man-pages/man5/proc.5.html
108  int64_t size = 0;
109  int64_t resident = 0;
110  int64_t shared = 0;
111 
112  std::ifstream fstatm("/proc/self/statm");
113  fstatm >> size >> resident >> shared;
114  fstatm.close();
115 
116  long page_size =
117  sysconf(_SC_PAGE_SIZE); // in case x86-64 is configured to use 2MB pages
118 
119  usage.resident = resident * page_size;
120  usage.vtotal = size * page_size;
121  usage.regular = (resident - shared) * page_size;
122  usage.shared = shared * page_size;
123 
125  usage.frag = bi.getFragmentationPercent();
126 
127 #else
128 
129  usage.total = 0;
130  usage.free = 0;
131  usage.resident = 0;
132  usage.vtotal = 0;
133  usage.regular = 0;
134  usage.shared = 0;
135  usage.frag = 0;
136 
137 #endif
138 
139  return usage;
140 }
141 
143 #ifdef __APPLE__
144  int mib[2];
145  size_t physical_memory;
146  size_t length;
147  // Get the Physical memory size
148  mib[0] = CTL_HW;
149  mib[1] = HW_MEMSIZE;
150  length = sizeof(size_t);
151  sysctl(mib, 2, &physical_memory, &length, NULL, 0);
152  return physical_memory;
153 #elif defined(_MSC_VER)
154  MEMORYSTATUSEX status;
155  status.dwLength = sizeof(status);
156  GlobalMemoryStatusEx(&status);
157  return status.ullTotalPhys;
158 #else // Linux
159  long pages = sysconf(_SC_PHYS_PAGES);
160  long page_size = sysconf(_SC_PAGE_SIZE);
161  return pages * page_size;
162 #endif
163 }
164 
165 // This function exists for testing purposes so that we can test a reset of the cache.
167  const size_t num_reader_threads,
168  const SystemParameters& sys_params) {
169  int numLevels = bufferMgrs_.size();
170  for (int level = numLevels - 1; level >= 0; --level) {
171  for (size_t device = 0; device < bufferMgrs_[level].size(); device++) {
172  delete bufferMgrs_[level][device];
173  }
174  }
175  bufferMgrs_.clear();
176  populateMgrs(sys_params, num_reader_threads, cache_config);
178 }
179 
180 void DataMgr::populateMgrs(const SystemParameters& system_parameters,
181  const size_t userSpecifiedNumReaderThreads,
182  const DiskCacheConfig& cache_config) {
183  // no need for locking, as this is only called in the constructor
184  bufferMgrs_.resize(2);
186  dataDir_, userSpecifiedNumReaderThreads, cache_config));
187 
188  levelSizes_.push_back(1);
189  size_t page_size{512};
190  size_t cpuBufferSize = system_parameters.cpu_buffer_mem_bytes;
191  if (cpuBufferSize == 0) { // if size is not specified
192  const auto total_system_memory = getTotalSystemMemory();
193  VLOG(1) << "Detected " << (float)total_system_memory / (1024 * 1024)
194  << "M of total system memory.";
195  cpuBufferSize = total_system_memory *
196  0.8; // should get free memory instead of this ugly heuristic
197  }
198  size_t minCpuSlabSize = std::min(system_parameters.min_cpu_slab_size, cpuBufferSize);
199  minCpuSlabSize = (minCpuSlabSize / page_size) * page_size;
200  size_t maxCpuSlabSize = std::min(system_parameters.max_cpu_slab_size, cpuBufferSize);
201  maxCpuSlabSize = (maxCpuSlabSize / page_size) * page_size;
202  LOG(INFO) << "Min CPU Slab Size is " << (float)minCpuSlabSize / (1024 * 1024) << "MB";
203  LOG(INFO) << "Max CPU Slab Size is " << (float)maxCpuSlabSize / (1024 * 1024) << "MB";
204  LOG(INFO) << "Max memory pool size for CPU is " << (float)cpuBufferSize / (1024 * 1024)
205  << "MB";
206  if (hasGpus_ || cudaMgr_) {
207  LOG(INFO) << "Reserved GPU memory is " << (float)reservedGpuMem_ / (1024 * 1024)
208  << "MB includes render buffer allocation";
209  bufferMgrs_.resize(3);
210  bufferMgrs_[1].push_back(new Buffer_Namespace::CpuBufferMgr(0,
211  cpuBufferSize,
212  cudaMgr_.get(),
213  minCpuSlabSize,
214  maxCpuSlabSize,
215  page_size,
216  bufferMgrs_[0][0]));
217  levelSizes_.push_back(1);
218  int numGpus = cudaMgr_->getDeviceCount();
219  for (int gpuNum = 0; gpuNum < numGpus; ++gpuNum) {
220  size_t gpuMaxMemSize =
221  system_parameters.gpu_buffer_mem_bytes != 0
222  ? system_parameters.gpu_buffer_mem_bytes
223  : (cudaMgr_->getDeviceProperties(gpuNum)->globalMem) - (reservedGpuMem_);
224  size_t minGpuSlabSize =
225  std::min(system_parameters.min_gpu_slab_size, gpuMaxMemSize);
226  minGpuSlabSize = (minGpuSlabSize / page_size) * page_size;
227  size_t maxGpuSlabSize =
228  std::min(system_parameters.max_gpu_slab_size, gpuMaxMemSize);
229  maxGpuSlabSize = (maxGpuSlabSize / page_size) * page_size;
230  LOG(INFO) << "Min GPU Slab size for GPU " << gpuNum << " is "
231  << (float)minGpuSlabSize / (1024 * 1024) << "MB";
232  LOG(INFO) << "Max GPU Slab size for GPU " << gpuNum << " is "
233  << (float)maxGpuSlabSize / (1024 * 1024) << "MB";
234  LOG(INFO) << "Max memory pool size for GPU " << gpuNum << " is "
235  << (float)gpuMaxMemSize / (1024 * 1024) << "MB";
236  bufferMgrs_[2].push_back(new Buffer_Namespace::GpuCudaBufferMgr(gpuNum,
237  gpuMaxMemSize,
238  cudaMgr_.get(),
239  minGpuSlabSize,
240  maxGpuSlabSize,
241  page_size,
242  bufferMgrs_[1][0]));
243  }
244  levelSizes_.push_back(numGpus);
245  } else {
246  bufferMgrs_[1].push_back(new Buffer_Namespace::CpuBufferMgr(0,
247  cpuBufferSize,
248  cudaMgr_.get(),
249  minCpuSlabSize,
250  maxCpuSlabSize,
251  page_size,
252  bufferMgrs_[0][0]));
253  levelSizes_.push_back(1);
254  }
255 }
256 
257 void DataMgr::convertDB(const std::string basePath) {
258  // no need for locking, as this is only called in the constructor
259 
260  /* check that "mapd_data" directory exists and it's empty */
261  std::string mapdDataPath(basePath + "/../mapd_data/");
262  boost::filesystem::path path(mapdDataPath);
263  if (boost::filesystem::exists(path)) {
264  if (!boost::filesystem::is_directory(path)) {
265  LOG(FATAL) << "Path to directory mapd_data to convert DB is not a directory.";
266  }
267  } else { // data directory does not exist
268  LOG(FATAL) << "Path to directory mapd_data to convert DB does not exist.";
269  }
270 
271  File_Namespace::GlobalFileMgr* gfm{nullptr};
272  gfm = dynamic_cast<PersistentStorageMgr*>(bufferMgrs_[0][0])->getGlobalFileMgr();
273  CHECK(gfm);
274 
275  size_t defaultPageSize = gfm->getDefaultPageSize();
276  LOG(INFO) << "Database conversion started.";
278  gfm,
279  defaultPageSize,
280  basePath); // this call also copies data into new DB structure
281  delete fm_base_db;
282 
283  /* write content of DB into newly created/converted DB structure & location */
284  checkpoint(); // outputs data files as well as metadata files
285  LOG(INFO) << "Database conversion completed.";
286 }
287 
289  const { // create metadata shared by all tables of all DBs
290  ChunkKey chunkKey(2);
291  chunkKey[0] = 0; // top level db_id
292  chunkKey[1] = 0; // top level tb_id
293 
294  File_Namespace::GlobalFileMgr* gfm{nullptr};
295  gfm = dynamic_cast<PersistentStorageMgr*>(bufferMgrs_[0][0])->getGlobalFileMgr();
296  CHECK(gfm);
297 
298  auto fm_top = gfm->getFileMgr(chunkKey);
299  if (dynamic_cast<File_Namespace::FileMgr*>(fm_top)) {
300  static_cast<File_Namespace::FileMgr*>(fm_top)->createTopLevelMetadata();
301  }
302 }
303 
304 std::vector<MemoryInfo> DataMgr::getMemoryInfo(const MemoryLevel memLevel) {
305  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
306 
307  std::vector<MemoryInfo> mem_info;
308  if (memLevel == MemoryLevel::CPU_LEVEL) {
309  Buffer_Namespace::CpuBufferMgr* cpu_buffer =
310  dynamic_cast<Buffer_Namespace::CpuBufferMgr*>(
312  CHECK(cpu_buffer);
313  MemoryInfo mi;
314 
315  mi.pageSize = cpu_buffer->getPageSize();
316  mi.maxNumPages = cpu_buffer->getMaxSize() / mi.pageSize;
317  mi.isAllocationCapped = cpu_buffer->isAllocationCapped();
318  mi.numPageAllocated = cpu_buffer->getAllocated() / mi.pageSize;
319 
320  const auto& slab_segments = cpu_buffer->getSlabSegments();
321  for (size_t slab_num = 0; slab_num < slab_segments.size(); ++slab_num) {
322  for (auto segment : slab_segments[slab_num]) {
323  MemoryData md;
324  md.slabNum = slab_num;
325  md.startPage = segment.start_page;
326  md.numPages = segment.num_pages;
327  md.touch = segment.last_touched;
328  md.memStatus = segment.mem_status;
329  md.chunk_key.insert(
330  md.chunk_key.end(), segment.chunk_key.begin(), segment.chunk_key.end());
331  mi.nodeMemoryData.push_back(md);
332  }
333  }
334  mem_info.push_back(mi);
335  } else if (hasGpus_) {
336  int numGpus = cudaMgr_->getDeviceCount();
337  for (int gpuNum = 0; gpuNum < numGpus; ++gpuNum) {
339  dynamic_cast<Buffer_Namespace::GpuCudaBufferMgr*>(
341  CHECK(gpu_buffer);
342  MemoryInfo mi;
343 
344  mi.pageSize = gpu_buffer->getPageSize();
345  mi.maxNumPages = gpu_buffer->getMaxSize() / mi.pageSize;
346  mi.isAllocationCapped = gpu_buffer->isAllocationCapped();
347  mi.numPageAllocated = gpu_buffer->getAllocated() / mi.pageSize;
348 
349  const auto& slab_segments = gpu_buffer->getSlabSegments();
350  for (size_t slab_num = 0; slab_num < slab_segments.size(); ++slab_num) {
351  for (auto segment : slab_segments[slab_num]) {
352  MemoryData md;
353  md.slabNum = slab_num;
354  md.startPage = segment.start_page;
355  md.numPages = segment.num_pages;
356  md.touch = segment.last_touched;
357  md.chunk_key.insert(
358  md.chunk_key.end(), segment.chunk_key.begin(), segment.chunk_key.end());
359  md.memStatus = segment.mem_status;
360  mi.nodeMemoryData.push_back(md);
361  }
362  }
363  mem_info.push_back(mi);
364  }
365  }
366  return mem_info;
367 }
368 
369 std::string DataMgr::dumpLevel(const MemoryLevel memLevel) {
370  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
371 
372  // if gpu we need to iterate through all the buffermanagers for each card
373  if (memLevel == MemoryLevel::GPU_LEVEL) {
374  int numGpus = cudaMgr_->getDeviceCount();
375  std::ostringstream tss;
376  for (int gpuNum = 0; gpuNum < numGpus; ++gpuNum) {
377  tss << bufferMgrs_[memLevel][gpuNum]->printSlabs();
378  }
379  return tss.str();
380  } else {
381  return bufferMgrs_[memLevel][0]->printSlabs();
382  }
383 }
384 
385 void DataMgr::clearMemory(const MemoryLevel memLevel) {
386  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
387 
388  // if gpu we need to iterate through all the buffermanagers for each card
389  if (memLevel == MemoryLevel::GPU_LEVEL) {
390  if (cudaMgr_) {
391  int numGpus = cudaMgr_->getDeviceCount();
392  for (int gpuNum = 0; gpuNum < numGpus; ++gpuNum) {
393  LOG(INFO) << "clear slabs on gpu " << gpuNum;
394  bufferMgrs_[memLevel][gpuNum]->clearSlabs();
395  }
396  } else {
397  LOG(WARNING) << "Unable to clear GPU memory: No GPUs detected";
398  }
399  } else {
400  bufferMgrs_[memLevel][0]->clearSlabs();
401  }
402 }
403 
405  const MemoryLevel memLevel,
406  const int deviceId) {
407  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
408  return bufferMgrs_[memLevel][deviceId]->isBufferOnDevice(key);
409 }
410 
412  const ChunkKey& keyPrefix) {
413  bufferMgrs_[0][0]->getChunkMetadataVecForKeyPrefix(chunkMetadataVec, keyPrefix);
414 }
415 
417  const MemoryLevel memoryLevel,
418  const int deviceId,
419  const size_t page_size) {
420  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
421  int level = static_cast<int>(memoryLevel);
422  return bufferMgrs_[level][deviceId]->createBuffer(key, page_size);
423 }
424 
426  const MemoryLevel memoryLevel,
427  const int deviceId,
428  const size_t numBytes) {
429  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
430  const auto level = static_cast<size_t>(memoryLevel);
431  CHECK_LT(level, levelSizes_.size()); // make sure we have a legit buffermgr
432  CHECK_LT(deviceId, levelSizes_[level]); // make sure we have a legit buffermgr
433  return bufferMgrs_[level][deviceId]->getBuffer(key, numBytes);
434 }
435 
437  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
438 
439  int numLevels = bufferMgrs_.size();
440  for (int level = numLevels - 1; level >= 0; --level) {
441  for (int device = 0; device < levelSizes_[level]; ++device) {
442  bufferMgrs_[level][device]->deleteBuffersWithPrefix(keyPrefix);
443  }
444  }
445 }
446 
447 // only deletes the chunks at the given memory level
449  const MemoryLevel memLevel) {
450  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
451 
452  if (bufferMgrs_.size() <= memLevel) {
453  return;
454  }
455  for (int device = 0; device < levelSizes_[memLevel]; ++device) {
456  bufferMgrs_[memLevel][device]->deleteBuffersWithPrefix(keyPrefix);
457  }
458 }
459 
461  const int deviceId,
462  const size_t numBytes) {
463  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
464  const auto level = static_cast<int>(memoryLevel);
465  CHECK_LT(deviceId, levelSizes_[level]);
466  return bufferMgrs_[level][deviceId]->alloc(numBytes);
467 }
468 
470  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
471  int level = static_cast<int>(buffer->getType());
472  bufferMgrs_[level][buffer->getDeviceId()]->free(buffer);
473 }
474 
475 void DataMgr::copy(AbstractBuffer* destBuffer, AbstractBuffer* srcBuffer) {
476  destBuffer->write(srcBuffer->getMemoryPtr(),
477  srcBuffer->size(),
478  0,
479  srcBuffer->getType(),
480  srcBuffer->getDeviceId());
481 }
482 
483 // could add function below to do arbitrary copies between buffers
484 
485 // void DataMgr::copy(AbstractBuffer *destBuffer, const AbstractBuffer *srcBuffer, const
486 // size_t numBytes, const size_t destOffset, const size_t srcOffset) {
487 //} /
488 
489 void DataMgr::checkpoint(const int db_id, const int tb_id) {
490  // TODO(adb): do we need a buffer mgr lock here?
491  for (auto levelIt = bufferMgrs_.rbegin(); levelIt != bufferMgrs_.rend(); ++levelIt) {
492  // use reverse iterator so we start at GPU level, then CPU then DISK
493  for (auto deviceIt = levelIt->begin(); deviceIt != levelIt->end(); ++deviceIt) {
494  (*deviceIt)->checkpoint(db_id, tb_id);
495  }
496  }
497 }
498 
500  // TODO(adb): SAA
501  for (auto levelIt = bufferMgrs_.rbegin(); levelIt != bufferMgrs_.rend(); ++levelIt) {
502  // use reverse iterator so we start at GPU level, then CPU then DISK
503  for (auto deviceIt = levelIt->begin(); deviceIt != levelIt->end(); ++deviceIt) {
504  (*deviceIt)->checkpoint();
505  }
506  }
507 }
508 
509 void DataMgr::removeTableRelatedDS(const int db_id, const int tb_id) {
510  std::lock_guard<std::mutex> buffer_lock(buffer_access_mutex_);
511  bufferMgrs_[0][0]->removeTableRelatedDS(db_id, tb_id);
512 }
513 
514 void DataMgr::setTableEpoch(const int db_id, const int tb_id, const int start_epoch) {
515  File_Namespace::GlobalFileMgr* gfm{nullptr};
516  gfm = dynamic_cast<PersistentStorageMgr*>(bufferMgrs_[0][0])->getGlobalFileMgr();
517  CHECK(gfm);
518  gfm->setTableEpoch(db_id, tb_id, start_epoch);
519 }
520 
521 size_t DataMgr::getTableEpoch(const int db_id, const int tb_id) {
522  File_Namespace::GlobalFileMgr* gfm{nullptr};
523  gfm = dynamic_cast<PersistentStorageMgr*>(bufferMgrs_[0][0])->getGlobalFileMgr();
524  CHECK(gfm);
525  return gfm->getTableEpoch(db_id, tb_id);
526 }
527 
529  File_Namespace::GlobalFileMgr* global_file_mgr{nullptr};
530  global_file_mgr =
531  dynamic_cast<PersistentStorageMgr*>(bufferMgrs_[0][0])->getGlobalFileMgr();
532  CHECK(global_file_mgr);
533  return global_file_mgr;
534 }
535 
536 std::ostream& operator<<(std::ostream& os, const DataMgr::SystemMemoryUsage& mem_info) {
537  os << "jsonlog ";
538  os << "{";
539  os << " \"name\": \"CPU Memory Info\",";
540  os << " \"TotalMB\": " << mem_info.total / (1024. * 1024.) << ",";
541  os << " \"FreeMB\": " << mem_info.free / (1024. * 1024.) << ",";
542  os << " \"ProcessMB\": " << mem_info.resident / (1024. * 1024.) << ",";
543  os << " \"VirtualMB\": " << mem_info.vtotal / (1024. * 1024.) << ",";
544  os << " \"ProcessPlusSwapMB\": " << mem_info.regular / (1024. * 1024.) << ",";
545  os << " \"ProcessSharedMB\": " << mem_info.shared / (1024. * 1024.) << ",";
546  os << " \"FragmentationPercent\": " << mem_info.frag;
547  os << " }";
548  return os;
549 }
550 
552  return dynamic_cast<PersistentStorageMgr*>(bufferMgrs_[0][0]);
553 }
554 
555 } // namespace Data_Namespace
size_t getAllocated() override
Definition: BufferMgr.cpp:493
std::mutex buffer_access_mutex_
Definition: DataMgr.h:243
std::vector< int > ChunkKey
Definition: types.h:37
std::vector< MemoryData > nodeMemoryData
Definition: DataMgr.h:65
Buffer_Namespace::MemStatus memStatus
Definition: DataMgr.h:57
size_t getMaxSize() override
Definition: BufferMgr.cpp:488
std::vector< std::vector< AbstractBufferMgr * > > bufferMgrs_
Definition: DataMgr.h:238
std::vector< int > levelSizes_
Definition: DataMgr.h:210
std::ostream & operator<<(std::ostream &os, const DataMgr::SystemMemoryUsage &mem_info)
Definition: DataMgr.cpp:536
#define LOG(tag)
Definition: Logger.h:188
SystemMemoryUsage getSystemMemoryUsage() const
Definition: DataMgr.cpp:85
void populateMgrs(const SystemParameters &system_parameters, const size_t userSpecifiedNumReaderThreads, const DiskCacheConfig &cache_config)
Definition: DataMgr.cpp:180
DataMgr(const std::string &dataDir, const SystemParameters &system_parameters, std::unique_ptr< CudaMgr_Namespace::CudaMgr > cudaMgr, const bool useGpus, const size_t reservedGpuMem=(1<< 27), const size_t numReaderThreads=0, const DiskCacheConfig cacheConfig=DiskCacheConfig())
Definition: DataMgr.cpp:44
PersistentStorageMgr * getPersistentStorageMgr() const
Definition: DataMgr.cpp:551
virtual int8_t * getMemoryPtr()=0
virtual MemoryLevel getType() const =0
void clearMemory(const MemoryLevel memLevel)
Definition: DataMgr.cpp:385
std::string dumpLevel(const MemoryLevel memLevel)
Definition: DataMgr.cpp:369
void convertDB(const std::string basePath)
Definition: DataMgr.cpp:257
static size_t getTotalSystemMemory()
Definition: DataMgr.cpp:142
size_t getTableEpoch(const int db_id, const int tb_id)
Definition: DataMgr.cpp:521
void createTopLevelMetadata() const
Definition: DataMgr.cpp:288
bool isAllocationCapped() override
Definition: BufferMgr.cpp:498
std::unique_ptr< CudaMgr_Namespace::CudaMgr > cudaMgr_
Definition: DataMgr.h:239
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix)
Definition: DataMgr.cpp:411
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata >>> ChunkMetadataVector
An AbstractBuffer is a unit of data management for a data manager.
virtual void write(int8_t *src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_buffer_type=CPU_LEVEL, const int src_device_id=-1)=0
std::vector< MemoryInfo > getMemoryInfo(const MemoryLevel memLevel)
Definition: DataMgr.cpp:304
File_Namespace::GlobalFileMgr * getGlobalFileMgr() const
Definition: DataMgr.cpp:528
Parse /proc/meminfo into key/value pairs.
Definition: DataMgr.h:69
#define CHECK_LT(x, y)
Definition: Logger.h:207
void deleteChunksWithPrefix(const ChunkKey &keyPrefix)
Definition: DataMgr.cpp:436
static PersistentStorageMgr * createPersistentStorageMgr(const std::string &data_dir, const size_t num_reader_threads, const DiskCacheConfig &disk_cache_config)
const std::vector< BufferList > & getSlabSegments()
Definition: BufferMgr.cpp:868
bool isBufferOnDevice(const ChunkKey &key, const MemoryLevel memLevel, const int deviceId)
Definition: DataMgr.cpp:404
AbstractBuffer * getChunkBuffer(const ChunkKey &key, const MemoryLevel memoryLevel, const int deviceId=0, const size_t numBytes=0)
Definition: DataMgr.cpp:425
void removeTableRelatedDS(const int db_id, const int tb_id)
Definition: DataMgr.cpp:509
#define CHECK(condition)
Definition: Logger.h:197
void resetPersistentStorage(const DiskCacheConfig &cache_config, const size_t num_reader_threads, const SystemParameters &sys_params)
Definition: DataMgr.cpp:166
void copy(AbstractBuffer *destBuffer, AbstractBuffer *srcBuffer)
Definition: DataMgr.cpp:475
std::vector< int32_t > chunk_key
Definition: DataMgr.h:56
AbstractBuffer * createChunkBuffer(const ChunkKey &key, const MemoryLevel memoryLevel, const int deviceId=0, const size_t page_size=0)
Definition: DataMgr.cpp:416
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:469
bool g_enable_fsi
Definition: Catalog.cpp:91
#define VLOG(n)
Definition: Logger.h:291
Parse /proc/buddyinfo into a Fragmentation health score.
Definition: DataMgr.h:102
void setTableEpoch(const int db_id, const int tb_id, const int start_epoch)
Definition: DataMgr.cpp:514
AbstractBuffer * alloc(const MemoryLevel memoryLevel, const int deviceId, const size_t numBytes)
Definition: DataMgr.cpp:460
std::string dataDir_
Definition: DataMgr.h:240