diff --git a/cachelib/allocator/CacheAllocatorConfig.h b/cachelib/allocator/CacheAllocatorConfig.h index e38ccc04db..25fde5ab5f 100644 --- a/cachelib/allocator/CacheAllocatorConfig.h +++ b/cachelib/allocator/CacheAllocatorConfig.h @@ -883,12 +883,6 @@ CacheAllocatorConfig::getMemoryTierConfigs() const { sum_sizes += tier_config.getSize(); } - if (size != sum_sizes) { - // Adjust capacity of the last tier to account for rounding error - config.back().setSize( - config.back().getSize() + (getCacheSize() - sum_sizes)); - } - return config; } diff --git a/cachelib/allocator/tests/MemoryTiersTest.cpp b/cachelib/allocator/tests/MemoryTiersTest.cpp index 6e5616fcdb..b8a71b55fd 100644 --- a/cachelib/allocator/tests/MemoryTiersTest.cpp +++ b/cachelib/allocator/tests/MemoryTiersTest.cpp @@ -52,10 +52,11 @@ class MemoryTiersTest: public AllocatorTest { size_t sum_ratios = std::accumulate(configs.begin(), configs.end(), 0, [](const size_t i, const MemoryTierCacheConfig& config) { return i + config.getRatio();}); - EXPECT_EQ(sum_sizes, expectedTotalCacheSize); - size_t partition_size = 0, remaining_capacity = actualConfig.getCacheSize(); + size_t partition_size = 0; if (sum_ratios) { partition_size = actualConfig.getCacheSize() / sum_ratios; + /* Sum of sizes can be lower due to rounding down to partition_size. */ + EXPECT_GE(sum_sizes, expectedTotalCacheSize - partition_size); } for(auto i = 0; i < configs.size(); ++i) { @@ -65,10 +66,7 @@ class MemoryTiersTest: public AllocatorTest { if (configs[i].getRatio() && (i < configs.size() - 1)) { EXPECT_EQ(configs[i].getSize(), partition_size * configs[i].getRatio()); } - remaining_capacity -= configs[i].getSize(); } - - EXPECT_EQ(remaining_capacity, 0); } LruAllocatorConfig createTestCacheConfig(