Skip to content

Commit 1856a24

Browse files
committed
Set correct size for each memory tier
1 parent 97caba8 commit 1856a24

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
@@ -219,7 +219,7 @@ CacheAllocator<CacheTrait>::createNewMemoryAllocator(TierId tid) {
219219
config_.getCacheSize(), config_.slabMemoryBaseAddr,
220220
createShmCacheOpts(tid))
221221
.addr,
222-
config_.getCacheSize());
222+
memoryTierConfigs[tid].getSize());
223223
}
224224

225225
template <typename CacheTrait>
@@ -230,7 +230,7 @@ CacheAllocator<CacheTrait>::restoreMemoryAllocator(TierId tid) {
230230
shmManager_
231231
->attachShm(detail::kShmCacheName + std::to_string(tid),
232232
config_.slabMemoryBaseAddr, createShmCacheOpts(tid)).addr,
233-
config_.getCacheSize(),
233+
memoryTierConfigs[tid].getSize(),
234234
config_.disableFullCoredump);
235235
}
236236

cachelib/allocator/tests/AllocatorTypeTest.cpp

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

391391
TYPED_TEST(BaseAllocatorTest, BasicMultiTier) {this->testBasicMultiTier(); }
392392

393+
TYPED_TEST(BaseAllocatorTest, SingleTierSize) {this->testSingleTierMemoryAllocatorSize(); }
394+
395+
TYPED_TEST(BaseAllocatorTest, SingleTierSizeAnon) {this->testSingleTierMemoryAllocatorSizeAnonymous(); }
396+
393397
namespace { // the tests that cannot be done by TYPED_TEST.
394398

395399
using LruAllocatorTest = BaseAllocatorTest<LruAllocator>;

cachelib/allocator/tests/BaseAllocatorTest.h

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

59775977
typename AllocatorT::Config config;
5978-
config.setCacheSize(100 * 1024 * 1024); /* 100 MB */
5978+
static constexpr size_t cacheSize = 100 * 1024 * 1024; /* 100 MB */
5979+
config.setCacheSize(cacheSize);
59795980
config.enableCachePersistence(folly::sformat("/tmp/multi-tier-test/{}", ::getpid()));
59805981
config.usePosixForShm();
59815982
config.configureMemoryTiers({

0 commit comments

Comments
 (0)