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

Method completeSlabRelease

cachelib/allocator/memory/MemoryPool.cpp:536–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536void MemoryPool::completeSlabRelease(const SlabReleaseContext& context) {
537 if (context.isReleased()) {
538 // the slab release is already completed.
539 return;
540 }
541
542 if (context.getReceiverClassId() != Slab::kInvalidClassId &&
543 context.getMode() != SlabReleaseMode::kRebalance) {
544 throw std::invalid_argument(fmt::format(
545 "A valid receiver {} is specified but the rebalancing mode is "
546 "not SlabReleaseMode::kRebalance",
547 context.getReceiverClassId()));
548 }
549
550 auto slab = context.getSlab();
551 auto mode = context.getMode();
552 auto classId = context.getClassId();
553 auto zeroOnRelease = context.shouldZeroOnRelease();
554 auto& allocClass = getAllocationClassFor(classId);
555
556 // complete the slab release process.
557 allocClass.completeSlabRelease(context);
558
559 XDCHECK_EQ(slabAllocator_.getSlabHeader(slab)->getPoolId(), getId());
560 XDCHECK_EQ(slabAllocator_.getSlabHeader(slab)->getClassId(),
561 Slab::kInvalidClassId);
562 XDCHECK_EQ(slabAllocator_.getSlabHeader(slab)->getAllocSize(), 0u);
563
564 releaseSlab(mode, slab, zeroOnRelease, context.getReceiverClassId());
565}
566
567MPStats MemoryPool::getStats() const {
568 LockHolder l(lock_);

Callers 5

releaseSlabMethod · 0.45
releaseMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45

Calls 9

isReleasedMethod · 0.80
getReceiverClassIdMethod · 0.80
getModeMethod · 0.80
getSlabMethod · 0.80
getClassIdMethod · 0.80
shouldZeroOnReleaseMethod · 0.80
getPoolIdMethod · 0.45
getSlabHeaderMethod · 0.45
getAllocSizeMethod · 0.45

Tested by 3

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36