Skip to content

Commit 4477fec

Browse files
igchorvinser52
authored andcommitted
Set correct size for each memory tier
1 parent 0e8af04 commit 4477fec

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

cachelib/allocator/CacheAllocator-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ CacheAllocator<CacheTrait>::createNewMemoryAllocator(TierId tid) {
216216
config_.getCacheSize(), config_.slabMemoryBaseAddr,
217217
createShmCacheOpts(tid))
218218
.addr,
219-
config_.getCacheSize());
219+
memoryTierConfigs[tid].getSize());
220220
}
221221

222222
template <typename CacheTrait>
@@ -227,7 +227,7 @@ CacheAllocator<CacheTrait>::restoreMemoryAllocator(TierId tid) {
227227
shmManager_
228228
->attachShm(detail::kShmCacheName + std::to_string(tid),
229229
config_.slabMemoryBaseAddr, createShmCacheOpts(tid)).addr,
230-
config_.getCacheSize(),
230+
memoryTierConfigs[tid].getSize(),
231231
config_.disableFullCoredump);
232232
}
233233

cachelib/allocator/tests/AllocatorTypeTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ TYPED_TEST(BaseAllocatorTest, Nascent) { this->testNascent(); }
397397

398398
TYPED_TEST(BaseAllocatorTest, BasicMultiTier) {this->testBasicMultiTier(); }
399399

400+
TYPED_TEST(BaseAllocatorTest, SingleTierSize) {this->testSingleTierMemoryAllocatorSize(); }
401+
402+
TYPED_TEST(BaseAllocatorTest, SingleTierSizeAnon) {this->testSingleTierMemoryAllocatorSizeAnonymous(); }
403+
400404
namespace { // the tests that cannot be done by TYPED_TEST.
401405

402406
using LruAllocatorTest = BaseAllocatorTest<LruAllocator>;

cachelib/allocator/tests/BaseAllocatorTest.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6078,7 +6078,8 @@ class BaseAllocatorTest : public AllocatorTest<AllocatorT> {
60786078
};
60796079

60806080
typename AllocatorT::Config config;
6081-
config.setCacheSize(100 * 1024 * 1024); /* 100 MB */
6081+
static constexpr size_t cacheSize = 100 * 1024 * 1024; /* 100 MB */
6082+
config.setCacheSize(cacheSize);
60826083
config.enableCachePersistence(folly::sformat("/tmp/multi-tier-test/{}", ::getpid()));
60836084
config.usePosixForShm();
60846085
config.configureMemoryTiers({

0 commit comments

Comments
 (0)