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

Method getAllocationClassId

cachelib/allocator/memory/MemoryPool.cpp:194–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194ClassId MemoryPool::getAllocationClassId(uint32_t size) const {
195 if (size > acSizes_.back() || size == 0) {
196 throw std::invalid_argument(
197 fmt::format("Invalid size for alloc {} ", size));
198 }
199
200 // can operate without holding the mutex since the vector does not change.
201 const auto it = std::lower_bound(acSizes_.begin(), acSizes_.end(), size);
202
203 // we already checked for the bounds.
204 XDCHECK(it != acSizes_.end());
205
206 const auto idx = std::distance(acSizes_.begin(), it);
207 XDCHECK_LT(static_cast<size_t>(idx), ac_.size());
208 return static_cast<ClassId>(idx);
209}
210
211ClassId MemoryPool::getAllocationClassId(const void* memory) const {
212 // find the slab for this allocation and the header for the slab. None of

Callers 9

allocateInternalMethod · 0.45
releaseMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
testStatsMethod · 0.45
getSampleItemMethod · 0.45

Calls 6

getClassIdMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
getSlabHeaderMethod · 0.45
getPoolIdMethod · 0.45

Tested by 5

TEST_FFunction · 0.36
TEST_FFunction · 0.36
testStatsMethod · 0.36