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

Method createNewPool

cachelib/allocator/memory/MemoryPoolManager.cpp:101–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101PoolId MemoryPoolManager::createNewPool(folly::StringPiece name,
102 size_t poolSize,
103 const std::set<uint32_t>& allocSizes) {
104 std::unique_lock l(lock_);
105 if (poolsByName_.find(name) != poolsByName_.end()) {
106 throw std::invalid_argument("Duplicate pool");
107 }
108
109 if (nextPoolId_ == kMaxPools) {
110 throw std::logic_error("All pools exhausted");
111 }
112
113 const size_t remaining = getRemainingSizeLocked();
114 if (remaining < poolSize) {
115 // not enough memory to create a new pool.
116 throw std::invalid_argument(fmt::format(
117 "Not enough memory ({} bytes) to create a new pool of size {} bytes",
118 remaining,
119 poolSize));
120 }
121
122 const PoolId id = nextPoolId_;
123 pools_[id] =
124 std::make_unique<MemoryPool>(id, poolSize, slabAlloc_, allocSizes);
125 poolsByName_.insert({name.str(), id});
126 nextPoolId_++;
127 return id;
128}
129
130bool MemoryPoolManager::provisionPool(
131 PoolId pid, const std::vector<uint32_t>& slabsDistribution) {

Callers 2

addPoolMethod · 0.80
TEST_FFunction · 0.80

Calls 4

strMethod · 0.80
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by 1

TEST_FFunction · 0.64