MCPcopy Create free account
hub / github.com/facebook/CacheLib / saveState

Method saveState

cachelib/allocator/memory/MemoryPool.cpp:362–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362serialization::MemoryPoolObject MemoryPool::saveState() const {
363 if (!slabAllocator_.isRestorable()) {
364 throw std::logic_error("Memory Pool can not be restored");
365 }
366
367 serialization::MemoryPoolObject object;
368
369 *object.id() = id_;
370 *object.maxSize() = maxSize_;
371 *object.currSlabAllocSize() = currSlabAllocSize_;
372 *object.currAllocSize() = currAllocSize_;
373
374 for (auto slab : freeSlabs_) {
375 object.freeSlabIdxs()->push_back(slabAllocator_.slabIdx(slab));
376 }
377
378 for (auto size : acSizes_) {
379 object.acSizes()->push_back(size);
380 }
381
382 for (const std::unique_ptr<AllocationClass>& allocClass : ac_) {
383 object.ac()->push_back(allocClass->saveState());
384 }
385
386 *object.numSlabResize() = nSlabResize_;
387 *object.numSlabRebalance() = nSlabRebalance_;
388 *object.numSlabsAdvised() = curSlabsAdvised_;
389
390 return object;
391}
392
393FOLLY_DISABLE_ADDRESS_SANITIZER void memsetNoAsan(void* ptr,
394 uint8_t c,

Callers 7

TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
ASSERT_THROWFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45

Calls 3

slabIdxMethod · 0.80
isRestorableMethod · 0.45
idMethod · 0.45

Tested by 7

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
ASSERT_THROWFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36