From e5a7c8e58080cc2189bf52e11e6980e85328511c Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Wed, 22 Aug 2012 11:43:53 -0700 Subject: [PATCH] Log the open-options to the LOG. Summary: Log the open-options to the LOG. Use options_ instead of options because SanitizeOptions could modify the max_file_open limit. Test Plan: num db_bench Reviewers: heyongqiang Reviewed By: heyongqiang Differential Revision: https://reviews.facebook.net/D4833 --- db/db_impl.cc | 4 +++- include/leveldb/options.h | 2 ++ util/options.cc | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index a133281ff..0c709255e 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -141,12 +141,14 @@ DBImpl::DBImpl(const Options& options, const std::string& dbname) stats_ = new CompactionStats[options.num_levels]; // Reserve ten files or so for other uses and give the rest to TableCache. - const int table_cache_size = options.max_open_files - 10; + const int table_cache_size = options_.max_open_files - 10; table_cache_ = new TableCache(dbname_, &options_, table_cache_size); versions_ = new VersionSet(dbname_, &options_, table_cache_, &internal_comparator_); + options_.Dump(options_.info_log); + #ifdef USE_SCRIBE logger_ = new ScribeLogger("localhost", 1456); #endif diff --git a/include/leveldb/options.h b/include/leveldb/options.h index f8aa52ed9..a271905fc 100644 --- a/include/leveldb/options.h +++ b/include/leveldb/options.h @@ -206,6 +206,8 @@ struct Options { // Create an Options object with default values for all fields. Options(); + + void Dump(Logger * log) const; }; // Options that control read operations diff --git a/util/options.cc b/util/options.cc index 43f93a9cd..c9306387d 100644 --- a/util/options.cc +++ b/util/options.cc @@ -6,6 +6,7 @@ #include "leveldb/comparator.h" #include "leveldb/env.h" +#include "leveldb/filter_policy.h" namespace leveldb { @@ -39,4 +40,25 @@ Options::Options() db_stats_log_interval(1800) { } +void +Options::Dump( + Logger * log) const +{ + Log(log," Options.comparator: %s", comparator->Name()); + Log(log," Options.create_if_missing: %d", create_if_missing); + Log(log," Options.error_if_exists: %d", error_if_exists); + Log(log," Options.paranoid_checks: %d", paranoid_checks); + Log(log," Options.env: %p", env); + Log(log," Options.info_log: %p", info_log); + 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_size: %zd", block_size); + Log(log,"Options.block_restart_interval: %d", block_restart_interval); + Log(log," Options.compression: %d", compression); + Log(log," Options.filter_policy: %s", filter_policy == NULL ? "NULL" : filter_policy->Name()); + +} // Options::Dump + + } // namespace leveldb