Skip to content

Commit d4ff258

Browse files
committed
Adding AllocatorMemoryTiersTest for NUMA bindings
1 parent d23774a commit d4ff258

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

cachelib/allocator/tests/AllocatorMemoryTiersTest.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ namespace tests {
2323
using LruAllocatorMemoryTiersTest = AllocatorMemoryTiersTest<LruAllocator>;
2424

2525
// TODO(MEMORY_TIER): add more tests with different eviction policies
26-
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersInvalid) { this->testMultiTiersInvalid(); }
27-
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersValid) { this->testMultiTiersValid(); }
26+
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersFromFileInvalid) { this->testMultiTiersFormFileInvalid(); }
27+
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersFromFileValid) { this->testMultiTiersFromFileValid(); }
2828
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersValidMixed) { this->testMultiTiersValidMixed(); }
29+
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersNumaBindingsSysVValid) { this->testMultiTiersNumaBindingsSysVValid(); }
30+
TEST_F(LruAllocatorMemoryTiersTest, MultiTiersNumaBindingsPosixValid) { this->testMultiTiersNumaBindingsPosixValid(); }
2931

3032
} // end of namespace tests
3133
} // end of namespace cachelib

cachelib/allocator/tests/AllocatorMemoryTiersTest.h

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace tests {
2727
template <typename AllocatorT>
2828
class AllocatorMemoryTiersTest : public AllocatorTest<AllocatorT> {
2929
public:
30-
void testMultiTiersInvalid() {
30+
void testMultiTiersFormFileInvalid() {
3131
typename AllocatorT::Config config;
3232
config.setCacheSize(100 * Slab::kSize);
3333
config.configureMemoryTiers({
@@ -42,7 +42,7 @@ class AllocatorMemoryTiersTest : public AllocatorTest<AllocatorT> {
4242
std::invalid_argument);
4343
}
4444

45-
void testMultiTiersValid() {
45+
void testMultiTiersFromFileValid() {
4646
typename AllocatorT::Config config;
4747
config.setCacheSize(100 * Slab::kSize);
4848
config.enableCachePersistence("/tmp");
@@ -83,6 +83,47 @@ class AllocatorMemoryTiersTest : public AllocatorTest<AllocatorT> {
8383
ASSERT(handle != nullptr);
8484
ASSERT_NO_THROW(alloc->insertOrReplace(handle));
8585
}
86+
87+
void testMultiTiersNumaBindingsSysVValid() {
88+
typename AllocatorT::Config config;
89+
config.setCacheSize(100 * Slab::kSize);
90+
config.enableCachePersistence("/tmp");
91+
config.configureMemoryTiers({
92+
MemoryTierCacheConfig::fromShm()
93+
.setRatio(1).setMemBind({0}),
94+
MemoryTierCacheConfig::fromShm()
95+
.setRatio(1).setMemBind({0})
96+
});
97+
98+
auto alloc = std::make_unique<AllocatorT>(AllocatorT::SharedMemNew, config);
99+
ASSERT(alloc != nullptr);
100+
101+
auto pool = alloc->addPool("default", alloc->getCacheMemoryStats().cacheSize);
102+
auto handle = alloc->allocate(pool, "key", std::string("value").size());
103+
ASSERT(handle != nullptr);
104+
ASSERT_NO_THROW(alloc->insertOrReplace(handle));
105+
}
106+
107+
void testMultiTiersNumaBindingsPosixValid() {
108+
typename AllocatorT::Config config;
109+
config.setCacheSize(100 * Slab::kSize);
110+
config.enableCachePersistence("/tmp");
111+
config.usePosixForShm();
112+
config.configureMemoryTiers({
113+
MemoryTierCacheConfig::fromShm()
114+
.setRatio(1).setMemBind({0}),
115+
MemoryTierCacheConfig::fromShm()
116+
.setRatio(1).setMemBind({0})
117+
});
118+
119+
auto alloc = std::make_unique<AllocatorT>(AllocatorT::SharedMemNew, config);
120+
ASSERT(alloc != nullptr);
121+
122+
auto pool = alloc->addPool("default", alloc->getCacheMemoryStats().cacheSize);
123+
auto handle = alloc->allocate(pool, "key", std::string("value").size());
124+
ASSERT(handle != nullptr);
125+
ASSERT_NO_THROW(alloc->insertOrReplace(handle));
126+
}
86127
};
87128
} // namespace tests
88129
} // namespace cachelib

0 commit comments

Comments
 (0)