Print cache options to info log
Summary: Improve cache options logging to info log. Also print the value of cache_index_and_filter_blocks_with_high_priority. Closes https://github.com/facebook/rocksdb/pull/1709 Differential Revision: D4358776 Pulled By: yiwu-arbug fbshipit-source-id: 8f030a0
This commit is contained in:
parent
972f96b3fb
commit
ab48c165a9
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include "rocksdb/slice.h"
|
#include "rocksdb/slice.h"
|
||||||
#include "rocksdb/statistics.h"
|
#include "rocksdb/statistics.h"
|
||||||
#include "rocksdb/status.h"
|
#include "rocksdb/status.h"
|
||||||
@ -167,6 +168,8 @@ class Cache {
|
|||||||
// Prerequisit: no entry is referenced.
|
// Prerequisit: no entry is referenced.
|
||||||
virtual void EraseUnRefEntries() = 0;
|
virtual void EraseUnRefEntries() = 0;
|
||||||
|
|
||||||
|
virtual std::string GetPrintableOptions() const { return ""; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// No copying allowed
|
// No copying allowed
|
||||||
Cache(const Cache&);
|
Cache(const Cache&);
|
||||||
|
@ -115,6 +115,10 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
|
|||||||
snprintf(buffer, kBufferSize, " cache_index_and_filter_blocks: %d\n",
|
snprintf(buffer, kBufferSize, " cache_index_and_filter_blocks: %d\n",
|
||||||
table_options_.cache_index_and_filter_blocks);
|
table_options_.cache_index_and_filter_blocks);
|
||||||
ret.append(buffer);
|
ret.append(buffer);
|
||||||
|
snprintf(buffer, kBufferSize,
|
||||||
|
" cache_index_and_filter_blocks_with_high_priority: %d\n",
|
||||||
|
table_options_.cache_index_and_filter_blocks_with_high_priority);
|
||||||
|
ret.append(buffer);
|
||||||
snprintf(buffer, kBufferSize,
|
snprintf(buffer, kBufferSize,
|
||||||
" pin_l0_filter_and_index_blocks_in_cache: %d\n",
|
" pin_l0_filter_and_index_blocks_in_cache: %d\n",
|
||||||
table_options_.pin_l0_filter_and_index_blocks_in_cache);
|
table_options_.pin_l0_filter_and_index_blocks_in_cache);
|
||||||
@ -135,9 +139,28 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
|
|||||||
static_cast<void*>(table_options_.block_cache.get()));
|
static_cast<void*>(table_options_.block_cache.get()));
|
||||||
ret.append(buffer);
|
ret.append(buffer);
|
||||||
if (table_options_.block_cache) {
|
if (table_options_.block_cache) {
|
||||||
snprintf(buffer, kBufferSize, " block_cache_size: %" ROCKSDB_PRIszt "\n",
|
const char* block_cache_name = table_options_.block_cache->Name();
|
||||||
table_options_.block_cache->GetCapacity());
|
if (block_cache_name != nullptr) {
|
||||||
ret.append(buffer);
|
snprintf(buffer, kBufferSize, " block_cache_name: %s\n",
|
||||||
|
block_cache_name);
|
||||||
|
ret.append(buffer);
|
||||||
|
}
|
||||||
|
ret.append(" block_cache_options:\n");
|
||||||
|
ret.append(table_options_.block_cache->GetPrintableOptions());
|
||||||
|
}
|
||||||
|
snprintf(buffer, kBufferSize, " block_cache_compressed: %p\n",
|
||||||
|
static_cast<void*>(table_options_.block_cache_compressed.get()));
|
||||||
|
ret.append(buffer);
|
||||||
|
if (table_options_.block_cache_compressed) {
|
||||||
|
const char* block_cache_compressed_name =
|
||||||
|
table_options_.block_cache_compressed->Name();
|
||||||
|
if (block_cache_compressed_name != nullptr) {
|
||||||
|
snprintf(buffer, kBufferSize, " block_cache_name: %s\n",
|
||||||
|
block_cache_compressed_name);
|
||||||
|
ret.append(buffer);
|
||||||
|
}
|
||||||
|
ret.append(" block_cache_compressed_options:\n");
|
||||||
|
ret.append(table_options_.block_cache_compressed->GetPrintableOptions());
|
||||||
}
|
}
|
||||||
snprintf(buffer, kBufferSize, " persistent_cache: %p\n",
|
snprintf(buffer, kBufferSize, " persistent_cache: %p\n",
|
||||||
static_cast<void*>(table_options_.persistent_cache.get()));
|
static_cast<void*>(table_options_.persistent_cache.get()));
|
||||||
@ -147,15 +170,6 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
|
|||||||
ret.append(buffer);
|
ret.append(buffer);
|
||||||
ret.append(table_options_.persistent_cache->GetPrintableOptions());
|
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);
|
|
||||||
if (table_options_.block_cache_compressed) {
|
|
||||||
snprintf(buffer, kBufferSize,
|
|
||||||
" block_cache_compressed_size: %" ROCKSDB_PRIszt "\n",
|
|
||||||
table_options_.block_cache_compressed->GetCapacity());
|
|
||||||
ret.append(buffer);
|
|
||||||
}
|
|
||||||
snprintf(buffer, kBufferSize, " block_size: %" ROCKSDB_PRIszt "\n",
|
snprintf(buffer, kBufferSize, " block_size: %" ROCKSDB_PRIszt "\n",
|
||||||
table_options_.block_size);
|
table_options_.block_size);
|
||||||
ret.append(buffer);
|
ret.append(buffer);
|
||||||
|
@ -7,11 +7,16 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||||
|
|
||||||
|
#ifndef __STDC_FORMAT_MACROS
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "util/lru_cache.h"
|
#include "util/lru_cache.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "util/mutexlock.h"
|
#include "util/mutexlock.h"
|
||||||
|
|
||||||
@ -408,6 +413,17 @@ size_t LRUCacheShard::GetPinnedUsage() const {
|
|||||||
return usage_ - lru_usage_;
|
return usage_ - lru_usage_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string LRUCacheShard::GetPrintableOptions() const {
|
||||||
|
const int kBufferSize = 200;
|
||||||
|
char buffer[kBufferSize];
|
||||||
|
{
|
||||||
|
MutexLock l(&mutex_);
|
||||||
|
snprintf(buffer, kBufferSize, " high_pri_pool_ratio: %.3lf\n",
|
||||||
|
high_pri_pool_ratio_);
|
||||||
|
}
|
||||||
|
return std::string(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
LRUCache::LRUCache(size_t capacity, int num_shard_bits,
|
LRUCache::LRUCache(size_t capacity, int num_shard_bits,
|
||||||
bool strict_capacity_limit, double high_pri_pool_ratio)
|
bool strict_capacity_limit, double high_pri_pool_ratio)
|
||||||
: ShardedCache(capacity, num_shard_bits, strict_capacity_limit) {
|
: ShardedCache(capacity, num_shard_bits, strict_capacity_limit) {
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "util/sharded_cache.h"
|
#include "util/sharded_cache.h"
|
||||||
|
|
||||||
#include "port/port.h"
|
#include "port/port.h"
|
||||||
@ -190,6 +192,8 @@ class LRUCacheShard : public CacheShard {
|
|||||||
|
|
||||||
virtual void EraseUnRefEntries() override;
|
virtual void EraseUnRefEntries() override;
|
||||||
|
|
||||||
|
virtual std::string GetPrintableOptions() const override;
|
||||||
|
|
||||||
void TEST_GetLRUList(LRUHandle** lru, LRUHandle** lru_low_pri);
|
void TEST_GetLRUList(LRUHandle** lru, LRUHandle** lru_low_pri);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -7,7 +7,14 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||||
|
|
||||||
|
#ifndef __STDC_FORMAT_MACROS
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "util/sharded_cache.h"
|
#include "util/sharded_cache.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "util/mutexlock.h"
|
#include "util/mutexlock.h"
|
||||||
|
|
||||||
namespace rocksdb {
|
namespace rocksdb {
|
||||||
@ -114,4 +121,24 @@ void ShardedCache::EraseUnRefEntries() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ShardedCache::GetPrintableOptions() const {
|
||||||
|
std::string ret;
|
||||||
|
ret.reserve(20000);
|
||||||
|
const int kBufferSize = 200;
|
||||||
|
char buffer[kBufferSize];
|
||||||
|
{
|
||||||
|
MutexLock l(&capacity_mutex_);
|
||||||
|
snprintf(buffer, kBufferSize, " capacity : %" ROCKSDB_PRIszt "\n",
|
||||||
|
capacity_);
|
||||||
|
ret.append(buffer);
|
||||||
|
snprintf(buffer, kBufferSize, " num_shard_bits : %d\n", num_shard_bits_);
|
||||||
|
ret.append(buffer);
|
||||||
|
snprintf(buffer, kBufferSize, " strict_capacity_limit : %d\n",
|
||||||
|
strict_capacity_limit_);
|
||||||
|
ret.append(buffer);
|
||||||
|
}
|
||||||
|
ret.append(GetShard(0)->GetPrintableOptions());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "port/port.h"
|
#include "port/port.h"
|
||||||
#include "rocksdb/cache.h"
|
#include "rocksdb/cache.h"
|
||||||
@ -37,6 +38,7 @@ class CacheShard {
|
|||||||
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
|
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
|
||||||
bool thread_safe) = 0;
|
bool thread_safe) = 0;
|
||||||
virtual void EraseUnRefEntries() = 0;
|
virtual void EraseUnRefEntries() = 0;
|
||||||
|
virtual std::string GetPrintableOptions() const { return ""; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic cache interface which shards cache by hash of keys. 2^num_shard_bits
|
// Generic cache interface which shards cache by hash of keys. 2^num_shard_bits
|
||||||
@ -72,6 +74,7 @@ class ShardedCache : public Cache {
|
|||||||
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
|
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
|
||||||
bool thread_safe) override;
|
bool thread_safe) override;
|
||||||
virtual void EraseUnRefEntries() override;
|
virtual void EraseUnRefEntries() override;
|
||||||
|
virtual std::string GetPrintableOptions() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline uint32_t HashSlice(const Slice& s) {
|
static inline uint32_t HashSlice(const Slice& s) {
|
||||||
|
@ -144,6 +144,16 @@ class SimCacheImpl : public SimCache {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual std::string GetPrintableOptions() const override {
|
||||||
|
std::string ret;
|
||||||
|
ret.reserve(20000);
|
||||||
|
ret.append(" cache_options:\n");
|
||||||
|
ret.append(cache_->GetPrintableOptions());
|
||||||
|
ret.append(" sim_cache_options:\n");
|
||||||
|
ret.append(key_only_cache_->GetPrintableOptions());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Cache> cache_;
|
std::shared_ptr<Cache> cache_;
|
||||||
std::shared_ptr<Cache> key_only_cache_;
|
std::shared_ptr<Cache> key_only_cache_;
|
||||||
|
Loading…
Reference in New Issue
Block a user