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

Method optimizeCompactCacheSizes

cachelib/allocator/PoolOptimizer.cpp:51–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void 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
78void PoolOptimizer::work() {
79 progress_++;

Callers

nothing calls this directly

Calls 6

whatMethod · 0.80
getConfiguredSizeMethod · 0.45
resizePoolsMethod · 0.45
resizeCompactCachesMethod · 0.45

Tested by

no test coverage detected