Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Statistics ticker count #2769

Merged
merged 13 commits into from
Aug 9, 2024
6 changes: 6 additions & 0 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ level0-slowdown-writes-trigger : 20
# rocksdb level0_file_num_compaction_trigger
level0-file-num-compaction-trigger : 4

# rocksdb level0_file_num_compaction_trigger
level0-file-num-compaction-trigger : 4

#rocksdb statistics tickers
open_rocksdb_statistics_tickers : no

# The maximum size of the response package to client to prevent memory
# exhaustion caused by commands like 'keys *' and 'Scan' which can generate huge response.
# Supported Units [K|M|G]. The default unit is in [bytes].
Expand Down
4 changes: 4 additions & 0 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class PikaConf : public pstd::BaseConf {
std::shared_lock l(rwlock_);
return max_total_wal_size_;
}
bool open_rocksdb_statistics_tickers() {
return open_rocksdb_statistics_tickers_;
}
int64_t max_client_response_size() {
std::shared_lock l(rwlock_);
return max_client_response_size_;
Expand Down Expand Up @@ -887,6 +890,7 @@ class PikaConf : public pstd::BaseConf {
int64_t thread_migrate_keys_num_ = 0;
int64_t max_write_buffer_size_ = 0;
int64_t max_total_wal_size_ = 0;
bool open_rocksdb_statistics_tickers_ = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个命令最好是支持可以动态修改不用重启进程,线上用来定位问题的时候更方便。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rocksdb statics统计 不支持动态

int max_write_buffer_num_ = 0;
int min_write_buffer_number_to_merge_ = 1;
int level0_stop_writes_trigger_ = 36;
Expand Down
7 changes: 6 additions & 1 deletion src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,12 @@ void InfoCmd::InfoRocksDB(std::string& info) {
}
std::string rocksdb_info;
db_item.second->DBLockShared();
db_item.second->storage()->GetRocksDBInfo(rocksdb_info);
if (g_pika_conf->open_rocksdb_statistics_tickers()) {
db_item.second->storage()->GetRocksDBInfo(rocksdb_info, true);
} else {
db_item.second->storage()->GetRocksDBInfo(rocksdb_info, false);
}

db_item.second->DBUnlockShared();
tmp_stream << rocksdb_info;
}
Expand Down
2 changes: 1 addition & 1 deletion src/storage/include/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ class Storage {
const std::string& db_type, const std::unordered_map<std::string, std::string>& options);
Status EnableAutoCompaction(const OptionType& option_type,
const std::string& db_type, const std::unordered_map<std::string, std::string>& options);
void GetRocksDBInfo(std::string& info);
void GetRocksDBInfo(std::string& info, bool open_ticker);

private:
std::vector<std::unique_ptr<Redis>> insts_;
Expand Down
184 changes: 152 additions & 32 deletions src/storage/src/redis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,36 @@ Status Redis::SetOptions(const OptionType& option_type, const std::unordered_map
return s;
}

void Redis::GetRocksDBInfo(std::string& info, const char* prefix) {
void Redis::GetRocksDBInfo(std::string& info, const char* prefix, bool open_ticker) {
std::ostringstream string_stream;
string_stream << "#" << prefix << "RocksDB" << "\r\n";

auto write_stream_key_value=[&](const Slice& property, const char *metric) {
uint64_t value;
db_->GetAggregatedIntProperty(property, &value);
string_stream << prefix << metric << ':' << value << "\r\n";
auto write_aggregated_int_property=[&](const Slice& property, const char *metric) {
uint64_t value = 0;
db_->GetAggregatedIntProperty(property, &value);
string_stream << prefix << metric << ':' << value << "\r\n";
};
Comment on lines +277 to +281
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling for GetAggregatedIntProperty.

The lambda function write_aggregated_int_property does not handle potential errors from db_->GetAggregatedIntProperty. Consider adding error handling to ensure robustness.

-  db_->GetAggregatedIntProperty(property, &value);
+  if (!db_->GetAggregatedIntProperty(property, &value)) {
+    // Handle error appropriately, e.g., log the error or set a default value
+  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto write_aggregated_int_property=[&](const Slice& property, const char *metric) {
uint64_t value = 0;
db_->GetAggregatedIntProperty(property, &value);
string_stream << prefix << metric << ':' << value << "\r\n";
};
auto write_aggregated_int_property=[&](const Slice& property, const char *metric) {
uint64_t value = 0;
if (!db_->GetAggregatedIntProperty(property, &value)) {
// Handle error appropriately, e.g., log the error or set a default value
}
string_stream << prefix << metric << ':' << value << "\r\n";
};


auto write_property=[&](const Slice& property, const char *metric) {
if (handles_.size() == 0) {
std::string value;
db_->GetProperty(db_->DefaultColumnFamily(), property, &value);
string_stream << prefix << metric << "_" << db_->DefaultColumnFamily()->GetName() << ':' << value << "\r\n";
} else {
for (auto handle : handles_) {
std::string value;
db_->GetProperty(handle, property, &value);
string_stream << prefix << metric << "_" << handle->GetName() << ':' << value << "\r\n";
}
}
};
Comment on lines +283 to +295
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling for GetProperty.

The lambda function write_property does not handle potential errors from db_->GetProperty. Consider adding error handling to ensure robustness.

-  db_->GetProperty(handle, property, &value);
+  if (!db_->GetProperty(handle, property, &value).ok()) {
+    // Handle error appropriately, e.g., log the error or set a default value
+  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto write_property=[&](const Slice& property, const char *metric) {
if (handles_.size() == 0) {
std::string value;
db_->GetProperty(db_->DefaultColumnFamily(), property, &value);
string_stream << prefix << metric << "_" << db_->DefaultColumnFamily()->GetName() << ':' << value << "\r\n";
} else {
for (auto handle : handles_) {
std::string value;
db_->GetProperty(handle, property, &value);
string_stream << prefix << metric << "_" << handle->GetName() << ':' << value << "\r\n";
}
}
};
auto write_property=[&](const Slice& property, const char *metric) {
if (handles_.size() == 0) {
std::string value;
if (!db_->GetProperty(db_->DefaultColumnFamily(), property, &value).ok()) {
// Handle error appropriately, e.g., log the error or set a default value
} else {
string_stream << prefix << metric << "_" << db_->DefaultColumnFamily()->GetName() << ':' << value << "\r\n";
}
} else {
for (auto handle : handles_) {
std::string value;
if (!db_->GetProperty(handle, property, &value).ok()) {
// Handle error appropriately, e.g., log the error or set a default value
} else {
string_stream << prefix << metric << "_" << handle->GetName() << ':' << value << "\r\n";
}
}
}
};


auto write_ticker_count = [&](uint32_t tick_type, const char *metric) {
if (db_statistics_ == nullptr) {
return;
}
uint64_t count = db_statistics_->getTickerCount(tick_type);
string_stream << prefix << metric << ':' << count << "\r\n";
Comment on lines +297 to +302
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling for getTickerCount.

The lambda function write_ticker_count does not handle potential errors from db_statistics_->getTickerCount. Consider adding error handling to ensure robustness.

-  uint64_t count = db_statistics_->getTickerCount(tick_type);
+  uint64_t count = 0;
+  if (db_statistics_) {
+    count = db_statistics_->getTickerCount(tick_type);
+  } else {
+    // Handle error appropriately, e.g., log the error or set a default value
+  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto write_ticker_count = [&](uint32_t tick_type, const char *metric) {
if (db_statistics_ == nullptr) {
return;
}
uint64_t count = db_statistics_->getTickerCount(tick_type);
string_stream << prefix << metric << ':' << count << "\r\n";
auto write_ticker_count = [&](uint32_t tick_type, const char *metric) {
if (db_statistics_ == nullptr) {
return;
}
uint64_t count = 0;
if (db_statistics_) {
count = db_statistics_->getTickerCount(tick_type);
} else {
// Handle error appropriately, e.g., log the error or set a default value
}
string_stream << prefix << metric << ':' << count << "\r\n";

};

auto mapToString=[&](const std::map<std::string, std::string>& map_data, const char *prefix) {
Expand All @@ -285,57 +307,155 @@ void Redis::GetRocksDBInfo(std::string& info, const char* prefix) {
};

// memtables num
write_stream_key_value(rocksdb::DB::Properties::kNumImmutableMemTable, "num_immutable_mem_table");
write_stream_key_value(rocksdb::DB::Properties::kNumImmutableMemTableFlushed, "num_immutable_mem_table_flushed");
write_stream_key_value(rocksdb::DB::Properties::kMemTableFlushPending, "mem_table_flush_pending");
write_stream_key_value(rocksdb::DB::Properties::kNumRunningFlushes, "num_running_flushes");
write_aggregated_int_property(rocksdb::DB::Properties::kNumImmutableMemTable, "num_immutable_mem_table");
write_aggregated_int_property(rocksdb::DB::Properties::kNumImmutableMemTableFlushed, "num_immutable_mem_table_flushed");
write_aggregated_int_property(rocksdb::DB::Properties::kMemTableFlushPending, "mem_table_flush_pending");
write_aggregated_int_property(rocksdb::DB::Properties::kNumRunningFlushes, "num_running_flushes");

// compaction
write_stream_key_value(rocksdb::DB::Properties::kCompactionPending, "compaction_pending");
write_stream_key_value(rocksdb::DB::Properties::kNumRunningCompactions, "num_running_compactions");
write_aggregated_int_property(rocksdb::DB::Properties::kCompactionPending, "compaction_pending");
write_aggregated_int_property(rocksdb::DB::Properties::kNumRunningCompactions, "num_running_compactions");

// background errors
write_stream_key_value(rocksdb::DB::Properties::kBackgroundErrors, "background_errors");
write_aggregated_int_property(rocksdb::DB::Properties::kBackgroundErrors, "background_errors");
write_ticker_count(rocksdb::Tickers::STALL_MICROS, "stall_micros");

// memtables size
write_stream_key_value(rocksdb::DB::Properties::kCurSizeActiveMemTable, "cur_size_active_mem_table");
write_stream_key_value(rocksdb::DB::Properties::kCurSizeAllMemTables, "cur_size_all_mem_tables");
write_stream_key_value(rocksdb::DB::Properties::kSizeAllMemTables, "size_all_mem_tables");
write_aggregated_int_property(rocksdb::DB::Properties::kCurSizeActiveMemTable, "cur_size_active_mem_table");
write_aggregated_int_property(rocksdb::DB::Properties::kCurSizeAllMemTables, "cur_size_all_mem_tables");
write_aggregated_int_property(rocksdb::DB::Properties::kSizeAllMemTables, "size_all_mem_tables");

// keys
write_stream_key_value(rocksdb::DB::Properties::kEstimateNumKeys, "estimate_num_keys");
write_aggregated_int_property(rocksdb::DB::Properties::kEstimateNumKeys, "estimate_num_keys");

// table readers mem
write_stream_key_value(rocksdb::DB::Properties::kEstimateTableReadersMem, "estimate_table_readers_mem");
write_aggregated_int_property(rocksdb::DB::Properties::kEstimateTableReadersMem, "estimate_table_readers_mem");

// snapshot
write_stream_key_value(rocksdb::DB::Properties::kNumSnapshots, "num_snapshots");
write_aggregated_int_property(rocksdb::DB::Properties::kNumSnapshots, "num_snapshots");

// version
write_stream_key_value(rocksdb::DB::Properties::kNumLiveVersions, "num_live_versions");
write_stream_key_value(rocksdb::DB::Properties::kCurrentSuperVersionNumber, "current_super_version_number");
write_aggregated_int_property(rocksdb::DB::Properties::kNumLiveVersions, "num_live_versions");
write_aggregated_int_property(rocksdb::DB::Properties::kCurrentSuperVersionNumber, "current_super_version_number");

// live data size
write_stream_key_value(rocksdb::DB::Properties::kEstimateLiveDataSize, "estimate_live_data_size");
write_aggregated_int_property(rocksdb::DB::Properties::kEstimateLiveDataSize, "estimate_live_data_size");

// sst files
write_stream_key_value(rocksdb::DB::Properties::kTotalSstFilesSize, "total_sst_files_size");
write_stream_key_value(rocksdb::DB::Properties::kLiveSstFilesSize, "live_sst_files_size");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"0", "num_files_at_level0");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"1", "num_files_at_level1");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"2", "num_files_at_level2");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"3", "num_files_at_level3");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"4", "num_files_at_level4");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"5", "num_files_at_level5");
write_property(rocksdb::DB::Properties::kNumFilesAtLevelPrefix+"6", "num_files_at_level6");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"0", "compression_ratio_at_level0");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"1", "compression_ratio_at_level1");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"2", "compression_ratio_at_level2");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"3", "compression_ratio_at_level3");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"4", "compression_ratio_at_level4");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"5", "compression_ratio_at_level5");
write_property(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix+"6", "compression_ratio_at_level6");
write_aggregated_int_property(rocksdb::DB::Properties::kTotalSstFilesSize, "total_sst_files_size");
write_aggregated_int_property(rocksdb::DB::Properties::kLiveSstFilesSize, "live_sst_files_size");

// pending compaction bytes
write_stream_key_value(rocksdb::DB::Properties::kEstimatePendingCompactionBytes, "estimate_pending_compaction_bytes");
write_aggregated_int_property(rocksdb::DB::Properties::kEstimatePendingCompactionBytes, "estimate_pending_compaction_bytes");

// block cache
write_stream_key_value(rocksdb::DB::Properties::kBlockCacheCapacity, "block_cache_capacity");
write_stream_key_value(rocksdb::DB::Properties::kBlockCacheUsage, "block_cache_usage");
write_stream_key_value(rocksdb::DB::Properties::kBlockCachePinnedUsage, "block_cache_pinned_usage");
write_aggregated_int_property(rocksdb::DB::Properties::kBlockCacheCapacity, "block_cache_capacity");
write_aggregated_int_property(rocksdb::DB::Properties::kBlockCacheUsage, "block_cache_usage");
write_aggregated_int_property(rocksdb::DB::Properties::kBlockCachePinnedUsage, "block_cache_pinned_usage");

// blob files
write_stream_key_value(rocksdb::DB::Properties::kNumBlobFiles, "num_blob_files");
write_stream_key_value(rocksdb::DB::Properties::kBlobStats, "blob_stats");
write_stream_key_value(rocksdb::DB::Properties::kTotalBlobFileSize, "total_blob_file_size");
write_stream_key_value(rocksdb::DB::Properties::kLiveBlobFileSize, "live_blob_file_size");

write_aggregated_int_property(rocksdb::DB::Properties::kNumBlobFiles, "num_blob_files");
write_aggregated_int_property(rocksdb::DB::Properties::kBlobStats, "blob_stats");
write_aggregated_int_property(rocksdb::DB::Properties::kTotalBlobFileSize, "total_blob_file_size");
write_aggregated_int_property(rocksdb::DB::Properties::kLiveBlobFileSize, "live_blob_file_size");

write_aggregated_int_property(rocksdb::DB::Properties::kBlobCacheCapacity, "blob_cache_capacity");
write_aggregated_int_property(rocksdb::DB::Properties::kBlobCacheUsage, "blob_cache_usage");
write_aggregated_int_property(rocksdb::DB::Properties::kBlobCachePinnedUsage, "blob_cache_pinned_usage");

if (open_ticker) {
// memtables num
write_ticker_count(rocksdb::Tickers::MEMTABLE_HIT, "memtable_hit");
write_ticker_count(rocksdb::Tickers::MEMTABLE_MISS, "memtable_miss");

write_ticker_count(rocksdb::Tickers::BYTES_WRITTEN, "bytes_written");
write_ticker_count(rocksdb::Tickers::BYTES_READ, "bytes_read");
write_ticker_count(rocksdb::Tickers::ITER_BYTES_READ, "iter_bytes_read");
write_ticker_count(rocksdb::Tickers::GET_HIT_L0, "get_hit_l0");
write_ticker_count(rocksdb::Tickers::GET_HIT_L1, "get_hit_l1");
write_ticker_count(rocksdb::Tickers::GET_HIT_L2_AND_UP, "get_hit_l2_and_up");

write_ticker_count(rocksdb::Tickers::BLOOM_FILTER_USEFUL, "bloom_filter_useful");
write_ticker_count(rocksdb::Tickers::BLOOM_FILTER_FULL_POSITIVE, "bloom_filter_full_positive");
write_ticker_count(rocksdb::Tickers::BLOOM_FILTER_FULL_TRUE_POSITIVE, "bloom_filter_full_true_positive");
write_ticker_count(rocksdb::Tickers::BLOOM_FILTER_PREFIX_CHECKED, "bloom_filter_prefix_checked");
write_ticker_count(rocksdb::Tickers::BLOOM_FILTER_PREFIX_USEFUL, "bloom_filter_prefix_useful");

// compaction
write_ticker_count(rocksdb::Tickers::COMPACTION_KEY_DROP_NEWER_ENTRY, "compaction_key_drop_newer_entry");
write_ticker_count(rocksdb::Tickers::COMPACTION_KEY_DROP_OBSOLETE, "compaction_key_drop_obsolete");
write_ticker_count(rocksdb::Tickers::COMPACTION_KEY_DROP_USER, "compaction_key_drop_user");
write_ticker_count(rocksdb::Tickers::COMPACTION_OPTIMIZED_DEL_DROP_OBSOLETE, "compaction_optimized_del_drop_obsolete");
write_ticker_count(rocksdb::Tickers::COMPACT_READ_BYTES, "compact_read_bytes");
write_ticker_count(rocksdb::Tickers::COMPACT_WRITE_BYTES, "compact_write_bytes");
write_ticker_count(rocksdb::Tickers::FLUSH_WRITE_BYTES, "flush_write_bytes");

// keys
write_ticker_count(rocksdb::Tickers::NUMBER_KEYS_READ, "number_keys_read");
write_ticker_count(rocksdb::Tickers::NUMBER_KEYS_WRITTEN, "number_keys_written");
write_ticker_count(rocksdb::Tickers::NUMBER_KEYS_UPDATED, "number_keys_updated");
write_ticker_count(rocksdb::Tickers::NUMBER_OF_RESEEKS_IN_ITERATION, "number_of_reseeks_in_iteration");

write_ticker_count(rocksdb::Tickers::NUMBER_DB_SEEK, "number_db_seek");
write_ticker_count(rocksdb::Tickers::NUMBER_DB_NEXT, "number_db_next");
write_ticker_count(rocksdb::Tickers::NUMBER_DB_PREV, "number_db_prev");
write_ticker_count(rocksdb::Tickers::NUMBER_DB_SEEK_FOUND, "number_db_seek_found");
write_ticker_count(rocksdb::Tickers::NUMBER_DB_NEXT_FOUND, "number_db_next_found");
write_ticker_count(rocksdb::Tickers::NUMBER_DB_PREV_FOUND, "number_db_prev_found");
write_ticker_count(rocksdb::Tickers::LAST_LEVEL_READ_BYTES, "last_level_read_bytes");
write_ticker_count(rocksdb::Tickers::LAST_LEVEL_READ_COUNT, "last_level_read_count");
write_ticker_count(rocksdb::Tickers::NON_LAST_LEVEL_READ_BYTES, "non_last_level_read_bytes");
write_ticker_count(rocksdb::Tickers::NON_LAST_LEVEL_READ_COUNT, "non_last_level_read_count");

// sst files
write_ticker_count(rocksdb::Tickers::NO_FILE_OPENS, "no_file_opens");
write_ticker_count(rocksdb::Tickers::NO_FILE_ERRORS, "no_file_errors");

// block cache
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_INDEX_HIT, "block_cache_index_hit");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_INDEX_MISS, "block_cache_index_miss");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_FILTER_HIT, "block_cache_filter_hit");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_FILTER_MISS, "block_cache_filter_miss");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_DATA_HIT, "block_cache_data_hit");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_DATA_MISS, "block_cache_data_miss");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_BYTES_READ, "block_cache_bytes_read");
write_ticker_count(rocksdb::Tickers::BLOCK_CACHE_BYTES_WRITE, "block_cache_bytes_write");

// blob files
write_ticker_count(rocksdb::Tickers::BLOB_DB_NUM_KEYS_WRITTEN, "blob_db_num_keys_written");
write_ticker_count(rocksdb::Tickers::BLOB_DB_NUM_KEYS_READ, "blob_db_num_keys_read");
write_ticker_count(rocksdb::Tickers::BLOB_DB_BYTES_WRITTEN, "blob_db_bytes_written");
write_ticker_count(rocksdb::Tickers::BLOB_DB_BYTES_READ, "blob_db_bytes_read");
write_ticker_count(rocksdb::Tickers::BLOB_DB_NUM_SEEK, "blob_db_num_seek");
write_ticker_count(rocksdb::Tickers::BLOB_DB_NUM_NEXT, "blob_db_num_next");
write_ticker_count(rocksdb::Tickers::BLOB_DB_NUM_PREV, "blob_db_num_prev");
write_ticker_count(rocksdb::Tickers::BLOB_DB_BLOB_FILE_BYTES_WRITTEN, "blob_db_blob_file_bytes_written");
write_ticker_count(rocksdb::Tickers::BLOB_DB_BLOB_FILE_BYTES_READ, "blob_db_blob_file_bytes_read");

write_ticker_count(rocksdb::Tickers::BLOB_DB_GC_NUM_FILES, "blob_db_gc_num_files");
write_ticker_count(rocksdb::Tickers::BLOB_DB_GC_NUM_NEW_FILES, "blob_db_gc_num_new_files");
write_ticker_count(rocksdb::Tickers::BLOB_DB_GC_NUM_KEYS_RELOCATED, "blob_db_gc_num_keys_relocated");
write_ticker_count(rocksdb::Tickers::BLOB_DB_GC_BYTES_RELOCATED, "blob_db_gc_bytes_relocated");

write_ticker_count(rocksdb::Tickers::BLOB_DB_CACHE_MISS, "blob_db_cache_miss");
write_ticker_count(rocksdb::Tickers::BLOB_DB_CACHE_HIT, "blob_db_cache_hit");
write_ticker_count(rocksdb::Tickers::BLOB_DB_CACHE_BYTES_READ, "blob_db_cache_bytes_read");
write_ticker_count(rocksdb::Tickers::BLOB_DB_CACHE_BYTES_WRITE, "blob_db_cache_bytes_write");
}
// column family stats
std::map<std::string, std::string> mapvalues;
db_->rocksdb::DB::GetMapProperty(rocksdb::DB::Properties::kCFStats,&mapvalues);
Expand Down
3 changes: 2 additions & 1 deletion src/storage/src/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class Redis {
std::vector<rocksdb::ColumnFamilyHandle*> GetStreamCFHandles() {
return {handles_.begin() + kMetaCF, handles_.end()};
}
void GetRocksDBInfo(std::string &info, const char *prefix);
void GetRocksDBInfo(std::string &info, const char *prefix, bool open_ticker);

// Sets Commands
Status SAdd(const Slice& key, const std::vector<std::string>& members, int32_t* ret);
Expand Down Expand Up @@ -470,6 +470,7 @@ class Redis {
Storage* const storage_;
std::shared_ptr<LockMgr> lock_mgr_;
rocksdb::DB* db_ = nullptr;
std::shared_ptr<rocksdb::Statistics> db_statistics_ = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没找到初始化成员变量初始化的地方。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码题错了 done

//TODO(wangshaoyi): seperate env for each rocksdb instance
// rocksdb::Env* env_ = nullptr;

Expand Down
4 changes: 2 additions & 2 deletions src/storage/src/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1921,11 +1921,11 @@ Status Storage::EnableAutoCompaction(const OptionType& option_type,
return s;
}

void Storage::GetRocksDBInfo(std::string& info) {
void Storage::GetRocksDBInfo(std::string& info, bool open_ticker) {
char temp[12] = {0};
for (const auto& inst : insts_) {
snprintf(temp, sizeof(temp), "instance%d_", inst->GetIndex());
inst->GetRocksDBInfo(info, temp);
inst->GetRocksDBInfo(info, temp, open_ticker);
}
}

Expand Down
Loading