From 86c2d0a95dc033a2caad957ea1364a35ba14a5f2 Mon Sep 17 00:00:00 2001 From: Bo Wang Date: Wed, 13 Jul 2022 12:30:44 -0700 Subject: [PATCH] Add the secondary cache information into LRUCache:: GetPrintableOptions (#10346) Summary: If the primary cache is LRU cache and there is a secondary cache, add Secondary Cache printable options into LRUCache::GetPrintableOptions. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10346 Test Plan: 1. Current Unit Tests should pass. 2. Use db_bench (with compressed_secondary_cache ) and the LOG should includes the new printable options from Seoncdary Cache. Reviewed By: jay-zhuang Differential Revision: D37779310 Pulled By: gitbw95 fbshipit-source-id: 88ce1f7df6b5f25740e598d9e7fa91e4c414cb8f --- cache/compressed_secondary_cache.cc | 2 +- cache/lru_cache.cc | 11 +++++++++++ cache/lru_cache.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cache/compressed_secondary_cache.cc b/cache/compressed_secondary_cache.cc index a996bab9e..d52d94c94 100644 --- a/cache/compressed_secondary_cache.cc +++ b/cache/compressed_secondary_cache.cc @@ -139,7 +139,7 @@ std::string CompressedSecondaryCache::GetPrintableOptions() const { snprintf(buffer, kBufferSize, " compression_type : %s\n", CompressionTypeToString(cache_options_.compression_type).c_str()); ret.append(buffer); - snprintf(buffer, kBufferSize, " compression_type : %d\n", + snprintf(buffer, kBufferSize, " compress_format_version : %d\n", cache_options_.compress_format_version); ret.append(buffer); return ret; diff --git a/cache/lru_cache.cc b/cache/lru_cache.cc index 147ae5bcb..b059b5a51 100644 --- a/cache/lru_cache.cc +++ b/cache/lru_cache.cc @@ -757,6 +757,17 @@ void LRUCache::WaitAll(std::vector& handles) { } } +std::string LRUCache::GetPrintableOptions() const { + std::string ret; + ret.reserve(20000); + ret.append(ShardedCache::GetPrintableOptions()); + if (secondary_cache_) { + ret.append(" secondary_cache:\n"); + ret.append(secondary_cache_->GetPrintableOptions()); + } + return ret; +} + } // namespace lru_cache std::shared_ptr NewLRUCache( diff --git a/cache/lru_cache.h b/cache/lru_cache.h index 5c1081a82..f52d7bfc6 100644 --- a/cache/lru_cache.h +++ b/cache/lru_cache.h @@ -482,6 +482,7 @@ class LRUCache virtual DeleterFn GetDeleter(Handle* handle) const override; virtual void DisownData() override; virtual void WaitAll(std::vector& handles) override; + std::string GetPrintableOptions() const override; // Retrieves number of elements in LRU, for unit test purpose only. size_t TEST_GetLRUSize();