| 49 | } |
| 50 | |
| 51 | void PoolOptimizer::optimizeCompactCacheSizes() { |
| 52 | try { |
| 53 | auto strategy = cache_.getPoolOptimizeStrategy(); |
| 54 | if (!strategy) { |
| 55 | strategy = strategy_; |
| 56 | } |
| 57 | const auto context = strategy->pickVictimAndReceiverCompactCaches(cache_); |
| 58 | if (context.victimPoolId == Slab::kInvalidPoolId || |
| 59 | context.receiverPoolId == Slab::kInvalidPoolId) { |
| 60 | XLOG(DBG, "Cannot find victim and receiver for pool optimization"); |
| 61 | } else { |
| 62 | const auto memoryToMove = |
| 63 | cache_.getCompactCache(context.victimPoolId).getConfiguredSize() * |
| 64 | ccacheStepSizePercent_ / 100; |
| 65 | cache_.resizePools(context.victimPoolId, context.receiverPoolId, |
| 66 | memoryToMove); |
| 67 | cache_.resizeCompactCaches(); |
| 68 | XLOG(DBG, "Moving a slab from Pool {} to Pool {}", |
| 69 | static_cast<int>(context.victimPoolId), |
| 70 | static_cast<int>(context.receiverPoolId)); |
| 71 | } |
| 72 | } catch (const std::exception& ex) { |
| 73 | XLOGF(CRITICAL, "Optimization interrupted due to exception: {}", ex.what()); |
| 74 | XDCHECK(false); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void PoolOptimizer::work() { |
| 79 | progress_++; |
nothing calls this directly
no test coverage detected