Skip to content

Commit 9827818

Browse files
Jaesoo Leefacebook-github-bot
authored andcommitted
fix flaky tests in NvmCacheTests
Summary: This change fixes following flaky tests in NvmCacheTests. * NvmCacheTest.Delete * NvmCacheTest.NvmEvicted * NvmCacheTest.EvictToNvmGetCheckCtime The root cause of the failures are essentially the same as D42443647 (facebook@5e7ff9a) which fixed the problem for NvmCacheTest.EvictToNvmGet; we are inserting enough items that could be spilled to NVM cache, where the NvmCache::put() can be dropped and the item is evicted completely when the delete operations (and tombstones) issued as part of the insertion are still outstanding. In order to fix the problem, this change flushes the NVM cache periodically during the insertions. Also, since this could cause more regions are used, the size of NVM cache needs to be increased. This change bumps the default size of NVM cache to 200MB (previous 100MB). Also, the size of persist storage used in the test PersistenceCache has been bumped by 100MB accordingly, i.e., from 400MB to 500MB. This change addresses the github issue facebook#169 Reviewed By: therealgymmy Differential Revision: D43592888 fbshipit-source-id: f0968884eb39fb5728b59129e98345df3240f01e
1 parent e8151ad commit 9827818

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

cachelib/allocator/nvmcache/tests/NvmCacheTests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,13 @@ TEST_F(NvmCacheTest, EvictToNvmGetCheckCtime) {
245245
ASSERT_NE(nullptr, it);
246246
cache_->insertOrReplace(it);
247247
keyToCtime.insert({key, it->getCreationTime()});
248+
// Avoid any nvm eviction being dropped due to the race with still
249+
// outstanding remove operation for insertion
250+
if (i % 100 == 0) {
251+
nvm.flushNvmCache();
252+
}
248253
}
254+
nvm.flushNvmCache();
249255

250256
const auto nEvictions = this->evictionCount() - evictBefore;
251257
ASSERT_LT(0, nEvictions);
@@ -331,6 +337,11 @@ TEST_F(NvmCacheTest, Delete) {
331337
auto it = nvm.allocate(pid, key, 15 * 1024);
332338
ASSERT_NE(nullptr, it);
333339
nvm.insertOrReplace(it);
340+
// Avoid any nvm eviction being dropped due to the race with still
341+
// outstanding remove operation for insertion
342+
if (i % 100 == 0) {
343+
nvm.flushNvmCache();
344+
}
334345
}
335346
nvm.flushNvmCache();
336347

@@ -533,6 +544,11 @@ TEST_F(NvmCacheTest, NvmEvicted) {
533544
auto it = nvm.allocate(pid, key, allocSize);
534545
ASSERT_NE(nullptr, it);
535546
nvm.insertOrReplace(it);
547+
// Avoid any nvm eviction being dropped due to the race with still
548+
// outstanding remove operation for insertion
549+
if (i % 100 == 0) {
550+
nvm.flushNvmCache();
551+
}
536552
}
537553
nvm.flushNvmCache();
538554

cachelib/allocator/tests/NvmTestUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace utils {
2727
using NavyConfig = navy::NavyConfig;
2828
inline NavyConfig getNvmTestConfig(const std::string& cacheDir) {
2929
NavyConfig config{};
30-
config.setSimpleFile(cacheDir + "/navy", 100 * 1024ULL * 1024ULL);
30+
config.setSimpleFile(cacheDir + "/navy", 200 * 1024ULL * 1024ULL);
3131
config.setDeviceMetadataSize(4 * 1024 * 1024);
3232
config.setBlockSize(1024);
3333
config.setNavyReqOrderingShards(10);

cachelib/persistence/tests/PersistenceCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class PersistenceCache {
213213
public:
214214
const uint32_t kNumKeys = 1024 * 1024; // 1 million
215215
const size_t kCacheSize = 100 * kNumKeys; // 100MB
216-
const size_t kCapacity = 4 * kCacheSize; // 400MB
216+
const size_t kCapacity = 5 * kCacheSize; // 500MB
217217

218218
std::unique_ptr<folly::IOBuf> buffer_;
219219
std::string cacheDir_;

0 commit comments

Comments
 (0)