Dump persistent cache options

Summary:
Dump persistent cache options
Closes https://github.com/facebook/rocksdb/pull/1679

Differential Revision: D4337019

Pulled By: yiwu-arbug

fbshipit-source-id: 3812f8a
main
Yi Wu 8 years ago committed by Facebook Github Bot
parent 7bd725e962
commit 5d1457dbbf
  1. 4
      db/db_test2.cc
  2. 2
      include/rocksdb/persistent_cache.h
  3. 8
      table/block_based_table_factory.cc
  4. 2
      utilities/persistent_cache/block_cache_tier.h
  5. 46
      utilities/persistent_cache/persistent_cache_tier.cc
  6. 8
      utilities/persistent_cache/persistent_cache_tier.h
  7. 4
      utilities/persistent_cache/volatile_tier_impl.h

@ -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<std::string, std::string> data_;
const bool is_compressed_ = true;

@ -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

@ -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<void*>(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<void*>(table_options_.block_cache_compressed.get()));
ret.append(buffer);

@ -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 {

@ -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 <string>
#include <sstream>
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
//

@ -220,6 +220,8 @@ struct PersistentCacheConfig {
PersistentCacheConfig MakePersistentCacheConfig(
const std::string& path, const uint64_t size,
const std::shared_ptr<Logger>& 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 {

@ -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;

Loading…
Cancel
Save