| 301 | } |
| 302 | |
| 303 | ClassId RebalanceStrategy::pickVictimForResizing(const CacheBase& cache, |
| 304 | PoolId pid) { |
| 305 | // Pick only the victim irrespective of who is receiving the slab. This is |
| 306 | // used mostly for pool resizing. |
| 307 | auto victimClassId = executeAndRecordCurrentState<ClassId>( |
| 308 | cache, |
| 309 | pid, |
| 310 | [&](const PoolStats& stats) { return pickVictimImpl(cache, pid, stats); }, |
| 311 | Slab::kInvalidClassId); |
| 312 | |
| 313 | if (victimClassId == cachelib::Slab::kInvalidClassId) { |
| 314 | const auto poolStats = cache.getPoolStats(pid); |
| 315 | victimClassId = |
| 316 | pickVictimStrategy_->pickAllocClassForResizing(cache, pid, poolStats); |
| 317 | } |
| 318 | |
| 319 | return victimClassId; |
| 320 | } |
| 321 | |
| 322 | ClassId RebalanceStrategy::pickReceiverWithAllocFailures( |
| 323 | const CacheBase&, PoolId pid, const PoolStats& stats) { |