diff --git a/db/db_test2.cc b/db/db_test2.cc index e3148ef5c..8fdcfda2c 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -1505,6 +1505,10 @@ class MockPersistentCache : public PersistentCache { bool IsCompressed() override { return is_compressed_; } + std::string GetPrintableOptions() const override { + return "MockPersistentCache"; + } + port::Mutex lock_; std::map data_; const bool is_compressed_ = true; diff --git a/include/rocksdb/persistent_cache.h b/include/rocksdb/persistent_cache.h index f93139736..352a43314 100644 --- a/include/rocksdb/persistent_cache.h +++ b/include/rocksdb/persistent_cache.h @@ -54,6 +54,8 @@ class PersistentCache { // Persistent cache can be initialized as a tier of caches. The stats are per // tire top-down virtual StatsType Stats() = 0; + + virtual std::string GetPrintableOptions() const = 0; }; // Factor method to create a new persistent cache diff --git a/table/block_based_table_factory.cc b/table/block_based_table_factory.cc index e9499cd67..f4e6902cc 100644 --- a/table/block_based_table_factory.cc +++ b/table/block_based_table_factory.cc @@ -139,6 +139,14 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const { table_options_.block_cache->GetCapacity()); ret.append(buffer); } + snprintf(buffer, kBufferSize, " persistent_cache: %p\n", + static_cast(table_options_.persistent_cache.get())); + ret.append(buffer); + if (table_options_.persistent_cache) { + snprintf(buffer, kBufferSize, " persistent_cache_options:\n"); + ret.append(buffer); + ret.append(table_options_.persistent_cache->GetPrintableOptions()); + } snprintf(buffer, kBufferSize, " block_cache_compressed: %p\n", static_cast(table_options_.block_cache_compressed.get())); ret.append(buffer); diff --git a/utilities/persistent_cache/block_cache_tier.h b/utilities/persistent_cache/block_cache_tier.h index a33dc369a..dece806fc 100644 --- a/utilities/persistent_cache/block_cache_tier.h +++ b/utilities/persistent_cache/block_cache_tier.h @@ -64,6 +64,8 @@ class BlockCacheTier : public PersistentCacheTier { bool IsCompressed() override { return opt_.is_compressed; } + std::string GetPrintableOptions() const override { return opt_.ToString(); } + PersistentCache::StatsType Stats() override; void TEST_Flush() override { diff --git a/utilities/persistent_cache/persistent_cache_tier.cc b/utilities/persistent_cache/persistent_cache_tier.cc index fde3c4a70..949ac1ab9 100644 --- a/utilities/persistent_cache/persistent_cache_tier.cc +++ b/utilities/persistent_cache/persistent_cache_tier.cc @@ -5,13 +5,59 @@ // #ifndef ROCKSDB_LITE +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif + #include "utilities/persistent_cache/persistent_cache_tier.h" +#include "inttypes.h" + #include #include namespace rocksdb { +std::string PersistentCacheConfig::ToString() const { + std::string ret; + ret.reserve(20000); + const int kBufferSize = 200; + char buffer[kBufferSize]; + + snprintf(buffer, kBufferSize, " path: %s\n", path.c_str()); + ret.append(buffer); + snprintf(buffer, kBufferSize, " enable_direct_reads: %d\n", + enable_direct_reads); + ret.append(buffer); + snprintf(buffer, kBufferSize, " enable_direct_writes: %d\n", + enable_direct_writes); + ret.append(buffer); + snprintf(buffer, kBufferSize, " cache_size: %" PRIu64 "\n", cache_size); + ret.append(buffer); + snprintf(buffer, kBufferSize, " cache_file_size: %" PRIu32 "\n", + cache_file_size); + ret.append(buffer); + snprintf(buffer, kBufferSize, " writer_qdepth: %" PRIu32 "\n", + writer_qdepth); + ret.append(buffer); + snprintf(buffer, kBufferSize, " pipeline_writes: %d\n", pipeline_writes); + ret.append(buffer); + snprintf(buffer, kBufferSize, + " max_write_pipeline_backlog_size: %" PRIu64 "\n", + max_write_pipeline_backlog_size); + ret.append(buffer); + snprintf(buffer, kBufferSize, " write_buffer_size: %" PRIu32 "\n", + write_buffer_size); + ret.append(buffer); + snprintf(buffer, kBufferSize, " writer_dispatch_size: %" PRIu64 "\n", + writer_dispatch_size); + ret.append(buffer); + snprintf(buffer, kBufferSize, " is_compressed: %d\n", is_compressed); + ret.append(buffer); + + return ret; +} + // // PersistentCacheTier implementation // diff --git a/utilities/persistent_cache/persistent_cache_tier.h b/utilities/persistent_cache/persistent_cache_tier.h index af0395f27..0adfcf123 100644 --- a/utilities/persistent_cache/persistent_cache_tier.h +++ b/utilities/persistent_cache/persistent_cache_tier.h @@ -220,6 +220,8 @@ struct PersistentCacheConfig { PersistentCacheConfig MakePersistentCacheConfig( const std::string& path, const uint64_t size, const std::shared_ptr& log); + + std::string ToString() const; }; // Persistent Cache Tier @@ -262,6 +264,8 @@ class PersistentCacheTier : public PersistentCache { // Does it store compressed data ? virtual bool IsCompressed() = 0; + virtual std::string GetPrintableOptions() const = 0; + // Return a reference to next tier virtual Tier& next_tier() { return next_tier_; } @@ -301,6 +305,10 @@ class PersistentTieredCache : public PersistentCacheTier { size_t* size) override; bool IsCompressed() override; + std::string GetPrintableOptions() const override { + return "PersistentTieredCache"; + } + void AddTier(const Tier& tier); Tier& next_tier() override { diff --git a/utilities/persistent_cache/volatile_tier_impl.h b/utilities/persistent_cache/volatile_tier_impl.h index 3f914dd79..480787c07 100644 --- a/utilities/persistent_cache/volatile_tier_impl.h +++ b/utilities/persistent_cache/volatile_tier_impl.h @@ -62,6 +62,10 @@ class VolatileCacheTier : public PersistentCacheTier { // erase key from cache bool Erase(const Slice& key) override; + std::string GetPrintableOptions() const override { + return "VolatileCacheTier"; + } + // Expose stats as map PersistentCache::StatsType Stats() override;