| 37 | } |
| 38 | |
| 39 | ClassId 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 | |
| 59 | ClassId AllocationSizeStrategy::pickAllocClassForResizing( |
| 60 | const CacheBase& cache, PoolId pid, const PoolStats& stats) const { |