Print the block cache size in the LOG.

Summary: Print the block cache size in the LOG.

Test Plan: run db_bench and look at LOG. This is helpful while I was debugging one use-case.

Reviewers: heyongqiang, MarkCallaghan

Reviewed By: heyongqiang

Differential Revision: https://reviews.facebook.net/D5739
main
Dhruba Borthakur 12 years ago
parent c1bb32e1ba
commit 72c45c66c6
  1. 3
      include/leveldb/cache.h
  2. 5
      util/cache.cc
  3. 2
      util/options.cc

@ -82,6 +82,9 @@ class Cache {
// its cache keys.
virtual uint64_t NewId() = 0;
// returns the maximum configured capacity of the cache
virtual size_t GetCapacity() = 0;
private:
void LRU_Remove(Handle* e);
void LRU_Append(Handle* e);

@ -276,6 +276,7 @@ class ShardedLRUCache : public Cache {
port::Mutex id_mutex_;
uint64_t last_id_;
int numShardBits;
size_t capacity_;
static inline uint32_t HashSlice(const Slice& s) {
return Hash(s.data(), s.size(), 0);
@ -287,6 +288,7 @@ class ShardedLRUCache : public Cache {
void init(size_t capacity, int numbits) {
numShardBits = numbits;
capacity_ = capacity;
int numShards = 1 << numShardBits;
shard_ = new LRUCache[numShards];
const size_t per_shard = (capacity + (numShards - 1)) / numShards;
@ -329,6 +331,9 @@ class ShardedLRUCache : public Cache {
MutexLock l(&id_mutex_);
return ++(last_id_);
}
virtual uint64_t GetCapacity() {
return capacity_;
}
};
} // end anonymous namespace

@ -7,6 +7,7 @@
#include "leveldb/comparator.h"
#include "leveldb/env.h"
#include "leveldb/filter_policy.h"
#include "leveldb/cache.h"
namespace leveldb {
@ -56,6 +57,7 @@ Options::Dump(
Log(log," Options.write_buffer_size: %zd", write_buffer_size);
Log(log," Options.max_open_files: %d", max_open_files);
Log(log," Options.block_cache: %p", block_cache);
Log(log," Options.block_cache_size: %zd", block_cache->GetCapacity());
Log(log," Options.block_size: %zd", block_size);
Log(log,"Options.block_restart_interval: %d", block_restart_interval);
Log(log," Options.compression: %d", compression);

Loading…
Cancel
Save