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

Method pickAllocClassForResizing

cachelib/allocator/RebalanceStrategy.cpp:39–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39ClassId TotalSlabsStrategy::pickAllocClassForResizing(
40 const CacheBase&, PoolId, const PoolStats& stats) const {
41 const auto& candidates = stats.mpStats.classIds;
42
43 // Pick victim by maximum number of slabs
44 const auto ret = *std::max_element(
45 candidates.begin(), candidates.end(), [&](ClassId a, ClassId b) {
46 return stats.mpStats.acStats.at(a).totalSlabs() <
47 stats.mpStats.acStats.at(b).totalSlabs();
48 });
49
50 // if we dont find any, it is likely that the pool has its slabs in its
51 // private free list.
52 if (stats.mpStats.acStats.at(ret).totalSlabs() == 0) {
53 return Slab::kInvalidClassId;
54 }
55
56 return ret;
57}
58
59ClassId AllocationSizeStrategy::pickAllocClassForResizing(
60 const CacheBase& cache, PoolId pid, const PoolStats& stats) const {

Callers 3

pickVictimAndReceiverMethod · 0.80
pickVictimForResizingMethod · 0.80

Calls 6

totalSlabsMethod · 0.80
allocSizeForClassMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1