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
main
Bo Wang 2 years ago committed by Facebook GitHub Bot
parent 9645e66fc9
commit 86c2d0a95d
  1. 2
      cache/compressed_secondary_cache.cc
  2. 11
      cache/lru_cache.cc
  3. 1
      cache/lru_cache.h

@ -139,7 +139,7 @@ std::string CompressedSecondaryCache::GetPrintableOptions() const {
snprintf(buffer, kBufferSize, " compression_type : %s\n", snprintf(buffer, kBufferSize, " compression_type : %s\n",
CompressionTypeToString(cache_options_.compression_type).c_str()); CompressionTypeToString(cache_options_.compression_type).c_str());
ret.append(buffer); ret.append(buffer);
snprintf(buffer, kBufferSize, " compression_type : %d\n", snprintf(buffer, kBufferSize, " compress_format_version : %d\n",
cache_options_.compress_format_version); cache_options_.compress_format_version);
ret.append(buffer); ret.append(buffer);
return ret; return ret;

11
cache/lru_cache.cc vendored

@ -757,6 +757,17 @@ void LRUCache::WaitAll(std::vector<Handle*>& 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 } // namespace lru_cache
std::shared_ptr<Cache> NewLRUCache( std::shared_ptr<Cache> NewLRUCache(

1
cache/lru_cache.h vendored

@ -482,6 +482,7 @@ class LRUCache
virtual DeleterFn GetDeleter(Handle* handle) const override; virtual DeleterFn GetDeleter(Handle* handle) const override;
virtual void DisownData() override; virtual void DisownData() override;
virtual void WaitAll(std::vector<Handle*>& handles) override; virtual void WaitAll(std::vector<Handle*>& handles) override;
std::string GetPrintableOptions() const override;
// Retrieves number of elements in LRU, for unit test purpose only. // Retrieves number of elements in LRU, for unit test purpose only.
size_t TEST_GetLRUSize(); size_t TEST_GetLRUSize();

Loading…
Cancel
Save