mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
[RocksDB] dump leveldb.stats periodically in LOG file.
Summary: Added an option stats_dump_period_sec to dump leveldb.stats to LOG periodically for diagnosis. By defauly, it's set to a very big number 3600 (1 hour). Test Plan: make check; Reviewers: dhruba Reviewed By: dhruba CC: leveldb, zshao Differential Revision: https://reviews.facebook.net/D10761
This commit is contained in:
parent
26541860d3
commit
0e879c93de
|
@ -162,6 +162,7 @@ DBImpl::DBImpl(const Options& options, const std::string& dbname)
|
||||||
disable_delete_obsolete_files_(false),
|
disable_delete_obsolete_files_(false),
|
||||||
delete_obsolete_files_last_run_(0),
|
delete_obsolete_files_last_run_(0),
|
||||||
purge_wal_files_last_run_(0),
|
purge_wal_files_last_run_(0),
|
||||||
|
last_stats_dump_time_microsec_(0),
|
||||||
stall_level0_slowdown_(0),
|
stall_level0_slowdown_(0),
|
||||||
stall_memtable_compaction_(0),
|
stall_memtable_compaction_(0),
|
||||||
stall_level0_num_files_(0),
|
stall_level0_num_files_(0),
|
||||||
|
@ -303,6 +304,24 @@ const Status DBImpl::CreateArchivalDirectory() {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBImpl::MaybeDumpStats() {
|
||||||
|
mutex_.AssertHeld();
|
||||||
|
|
||||||
|
if (options_.stats_dump_period_sec != 0) {
|
||||||
|
const uint64_t now_micros = env_->NowMicros();
|
||||||
|
if (last_stats_dump_time_microsec_ +
|
||||||
|
options_.stats_dump_period_sec * 1000000
|
||||||
|
<= now_micros) {
|
||||||
|
last_stats_dump_time_microsec_ = now_micros;
|
||||||
|
mutex_.Unlock();
|
||||||
|
std::string stats;
|
||||||
|
GetProperty("leveldb.stats", &stats);
|
||||||
|
Log(options_.info_log, "%s", stats.c_str());
|
||||||
|
mutex_.Lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the list of live files in 'live' and the list
|
// Returns the list of live files in 'live' and the list
|
||||||
// of all files in the filesystem in 'allfiles'.
|
// of all files in the filesystem in 'allfiles'.
|
||||||
void DBImpl::FindObsoleteFiles(DeletionState& deletion_state) {
|
void DBImpl::FindObsoleteFiles(DeletionState& deletion_state) {
|
||||||
|
@ -1253,6 +1272,8 @@ void DBImpl::BackgroundCall() {
|
||||||
MaybeScheduleCompaction();
|
MaybeScheduleCompaction();
|
||||||
}
|
}
|
||||||
bg_cv_.SignalAll();
|
bg_cv_.SignalAll();
|
||||||
|
|
||||||
|
MaybeDumpStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBImpl::BackgroundCompaction(bool* madeProgress,
|
Status DBImpl::BackgroundCompaction(bool* madeProgress,
|
||||||
|
|
|
@ -208,6 +208,10 @@ class DBImpl : public DB {
|
||||||
|
|
||||||
|
|
||||||
Status ReadFirstLine(const std::string& fname, WriteBatch* const batch);
|
Status ReadFirstLine(const std::string& fname, WriteBatch* const batch);
|
||||||
|
|
||||||
|
// dump leveldb.stats to LOG
|
||||||
|
void MaybeDumpStats();
|
||||||
|
|
||||||
// Constant after construction
|
// Constant after construction
|
||||||
const InternalFilterPolicy internal_filter_policy_;
|
const InternalFilterPolicy internal_filter_policy_;
|
||||||
bool owns_info_log_;
|
bool owns_info_log_;
|
||||||
|
@ -272,6 +276,9 @@ class DBImpl : public DB {
|
||||||
// last time when PurgeObsoleteWALFiles ran.
|
// last time when PurgeObsoleteWALFiles ran.
|
||||||
uint64_t purge_wal_files_last_run_;
|
uint64_t purge_wal_files_last_run_;
|
||||||
|
|
||||||
|
// last time stats were dumped to LOG
|
||||||
|
uint64_t last_stats_dump_time_microsec_;
|
||||||
|
|
||||||
// These count the number of microseconds for which MakeRoomForWrite stalls.
|
// These count the number of microseconds for which MakeRoomForWrite stalls.
|
||||||
uint64_t stall_level0_slowdown_;
|
uint64_t stall_level0_slowdown_;
|
||||||
uint64_t stall_memtable_compaction_;
|
uint64_t stall_memtable_compaction_;
|
||||||
|
|
|
@ -430,6 +430,9 @@ struct Options {
|
||||||
// Default: false
|
// Default: false
|
||||||
bool skip_log_error_on_recovery;
|
bool skip_log_error_on_recovery;
|
||||||
|
|
||||||
|
// if not zero, dump leveldb.stats to LOG every stats_dump_period_sec
|
||||||
|
// Default: 3600 (1 hour)
|
||||||
|
unsigned int stats_dump_period_sec;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options that control read operations
|
// Options that control read operations
|
||||||
|
|
|
@ -69,7 +69,8 @@ Options::Options()
|
||||||
allow_mmap_reads(false),
|
allow_mmap_reads(false),
|
||||||
allow_mmap_writes(true),
|
allow_mmap_writes(true),
|
||||||
is_fd_close_on_exec(true),
|
is_fd_close_on_exec(true),
|
||||||
skip_log_error_on_recovery(false) {
|
skip_log_error_on_recovery(false),
|
||||||
|
stats_dump_period_sec(3600) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -161,7 +162,7 @@ Options::Dump(Logger* log) const
|
||||||
Log(log," Options.no_block_cache: %d",
|
Log(log," Options.no_block_cache: %d",
|
||||||
no_block_cache);
|
no_block_cache);
|
||||||
Log(log," Options.table_cache_numshardbits: %d",
|
Log(log," Options.table_cache_numshardbits: %d",
|
||||||
table_cache_numshardbits);
|
table_cache_numshardbits);
|
||||||
Log(log," Options.delete_obsolete_files_period_micros: %ld",
|
Log(log," Options.delete_obsolete_files_period_micros: %ld",
|
||||||
delete_obsolete_files_period_micros);
|
delete_obsolete_files_period_micros);
|
||||||
Log(log," Options.max_background_compactions: %d",
|
Log(log," Options.max_background_compactions: %d",
|
||||||
|
@ -192,6 +193,8 @@ Options::Dump(Logger* log) const
|
||||||
is_fd_close_on_exec);
|
is_fd_close_on_exec);
|
||||||
Log(log," Options.skip_log_error_on_recovery: %d",
|
Log(log," Options.skip_log_error_on_recovery: %d",
|
||||||
skip_log_error_on_recovery);
|
skip_log_error_on_recovery);
|
||||||
|
Log(log," Options.stats_dump_period_sec: %d",
|
||||||
|
stats_dump_period_sec);
|
||||||
} // Options::Dump
|
} // Options::Dump
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue