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

Method addPool

cachelib/allocator/memory/MemoryAllocator.cpp:117–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117PoolId MemoryAllocator::addPool(folly::StringPiece name,
118 size_t size,
119 const std::set<uint32_t>& allocSizes,
120 bool ensureProvisionable) {
121 const std::set<uint32_t>& poolAllocSizes =
122 allocSizes.empty() ? config_.allocSizes : allocSizes;
123
124 if (poolAllocSizes.size() > MemoryAllocator::kMaxClasses) {
125 throw std::invalid_argument("Too many allocation classes");
126 }
127
128 if (ensureProvisionable &&
129 cachelib::Slab::kSize * poolAllocSizes.size() > size) {
130 throw std::invalid_argument(fmt::format(
131 "Pool {} cannot have at least one slab for each allocation class. "
132 "{} bytes required, {} bytes given.",
133 name,
134 cachelib::Slab::kSize * poolAllocSizes.size(),
135 size));
136 }
137
138 return memoryPoolManager_.createNewPool(name, size, poolAllocSizes);
139}
140
141PoolId MemoryAllocator::getPoolId(std::string_view name) const noexcept {
142 try {

Callers 15

TEST_FFunction · 0.45
TEST_FFunction · 0.45
testStatsMethod · 0.45
testItemSizeMethod · 0.45
testCacheCreationTimeMethod · 0.45
testCCacheWarmRollMethod · 0.45
testEvictionsMethod · 0.45
testRemovalsMethod · 0.45

Calls 3

createNewPoolMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 15

TEST_FFunction · 0.36
TEST_FFunction · 0.36
testStatsMethod · 0.36
testItemSizeMethod · 0.36
testCacheCreationTimeMethod · 0.36
testCCacheWarmRollMethod · 0.36
testEvictionsMethod · 0.36
testRemovalsMethod · 0.36