This is an automated email from the ASF dual-hosted git repository.
adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 324b8f2 KUDU-2920 Block cache capacity validator couldn't run on an
NVM block cache
324b8f2 is described below
commit 324b8f2dabe6686dc98cb36455ad16825730b034
Author: Volodymyr Verovkin <[email protected]>
AuthorDate: Tue Sep 10 23:41:43 2019 -0700
KUDU-2920 Block cache capacity validator couldn't run on an NVM block cache
Validator should fail for options:
--block_cache_type=DRAM
--block_cache_capacity_mb=1000000
and succeed for options:
--block_cache_type=NVM
--block_cache_capacity_mb=1000000
--nvm_cache_path=/path/to/your/tmp/dir
where 1000000 means "size of cache bigger than RAM" (1000GB)
Change-Id: I9f50e9dd901280b5c32576e43165292299922995
Reviewed-on: http://gerrit.cloudera.org:8080/14212
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
---
src/kudu/cfile/block_cache.cc | 8 +++++---
src/kudu/cfile/block_cache.h | 4 ++++
src/kudu/cfile/cfile-test.cc | 18 ++++++++++++++++++
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/kudu/cfile/block_cache.cc b/src/kudu/cfile/block_cache.cc
index 5ea8316..a464676 100644
--- a/src/kudu/cfile/block_cache.cc
+++ b/src/kudu/cfile/block_cache.cc
@@ -87,12 +87,15 @@ Cache* CreateCache(int64_t capacity) {
}
}
-// Validates the block cache capacity won't permit the cache to grow large
enough
-// to cause pernicious flushing behavior. See KUDU-2318.
+} // anonymous namespace
+
bool ValidateBlockCacheCapacity() {
if (FLAGS_force_block_cache_capacity) {
return true;
}
+ if (FLAGS_block_cache_type != "DRAM") {
+ return true;
+ }
int64_t capacity = FLAGS_block_cache_capacity_mb * 1024 * 1024;
int64_t mpt = process_memory::MemoryPressureThreshold();
if (capacity > mpt) {
@@ -115,7 +118,6 @@ bool ValidateBlockCacheCapacity() {
return true;
}
-} // anonymous namespace
GROUP_FLAG_VALIDATOR(block_cache_capacity_mb, ValidateBlockCacheCapacity);
diff --git a/src/kudu/cfile/block_cache.h b/src/kudu/cfile/block_cache.h
index e333066..e7621ec 100644
--- a/src/kudu/cfile/block_cache.h
+++ b/src/kudu/cfile/block_cache.h
@@ -221,6 +221,10 @@ inline void BlockCache::PendingEntry::reset() {
handle_.reset();
}
+// Validates the block cache capacity. Won't permit the cache to grow large
+// enough to cause pernicious flushing behavior. See KUDU-2318.
+bool ValidateBlockCacheCapacity();
+
} // namespace cfile
} // namespace kudu
diff --git a/src/kudu/cfile/cfile-test.cc b/src/kudu/cfile/cfile-test.cc
index e5c4d51..0333052 100644
--- a/src/kudu/cfile/cfile-test.cc
+++ b/src/kudu/cfile/cfile-test.cc
@@ -79,6 +79,8 @@
DECLARE_bool(cfile_write_checksums);
DECLARE_bool(cfile_verify_checksums);
DECLARE_string(block_cache_type);
+DECLARE_bool(force_block_cache_capacity);
+DECLARE_int64(block_cache_capacity_mb);
#if defined(__linux__)
DECLARE_string(nvm_cache_path);
@@ -1048,6 +1050,22 @@ TEST_P(TestCFileBothCacheMemoryTypes,
TestNvmAllocationFailure) {
}
#endif
+TEST_P(TestCFileBothCacheMemoryTypes, TestValidateBlockCacheCapacity) {
+ FLAGS_force_block_cache_capacity = false;
+ FLAGS_block_cache_capacity_mb = 100000000; // very big number (100TB)
+ switch (GetParam()) {
+ case Cache::MemoryType::DRAM:
+ ASSERT_FALSE(kudu::cfile::ValidateBlockCacheCapacity());
+ break;
+ case Cache::MemoryType::NVM:
+ ASSERT_TRUE(kudu::cfile::ValidateBlockCacheCapacity());
+ break;
+ default:
+ LOG(FATAL) << "Unknown block cache type: "
+ << static_cast<int16_t>(GetParam());
+ }
+}
+
class TestCFileDifferentCodecs : public TestCFile,
public
testing::WithParamInterface<CompressionType> {
};