Skip to content

Commit

Permalink
Minor code style enhancement for src/server (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Apr 22, 2024
1 parent 899216d commit 0e2273a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
11 changes: 6 additions & 5 deletions src/server/redis_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,26 +409,27 @@ Status Connection::ExecuteCommand(const std::string &cmd_name, const std::vector
}

void Connection::ExecuteCommands(std::deque<CommandTokens> *to_process_cmds) {
Config *config = srv_->GetConfig();
std::string reply, password = config->requirepass;
const Config *config = srv_->GetConfig();
std::string reply;
std::string password = config->requirepass;

while (!to_process_cmds->empty()) {
auto cmd_tokens = to_process_cmds->front();
CommandTokens cmd_tokens = std::move(to_process_cmds->front());
to_process_cmds->pop_front();
if (cmd_tokens.empty()) continue;

bool is_multi_exec = IsFlagEnabled(Connection::kMultiExec);
if (IsFlagEnabled(redis::Connection::kCloseAfterReply) && !is_multi_exec) break;

auto cmd_s = srv_->LookupAndCreateCommand(cmd_tokens.front());
auto cmd_s = Server::LookupAndCreateCommand(cmd_tokens.front());
if (!cmd_s.IsOK()) {
if (is_multi_exec) multi_error_ = true;
Reply(redis::Error("ERR unknown command " + cmd_tokens.front()));
continue;
}
auto current_cmd = std::move(*cmd_s);

const auto attributes = current_cmd->GetAttributes();
const auto &attributes = current_cmd->GetAttributes();
auto cmd_name = attributes->name;
auto cmd_flags = attributes->GenerateFlags(cmd_tokens);

Expand Down
23 changes: 13 additions & 10 deletions src/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -847,22 +847,25 @@ void Server::GetRocksDBInfo(std::string *info) {

string_stream << "# RocksDB\r\n";

uint64_t block_cache_usage = 0;
// All column families share the same block cache, so it's good to count a single one.
auto subkey_cf_handle = storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
db->GetIntProperty(subkey_cf_handle, "rocksdb.block-cache-usage", &block_cache_usage);
string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
{
// All column families share the same block cache, so it's good to count a single one.
uint64_t block_cache_usage = 0;
uint64_t block_cache_pinned_usage = 0;
auto subkey_cf_handle = storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
db->GetIntProperty(subkey_cf_handle, rocksdb::DB::Properties::kBlockCacheUsage, &block_cache_usage);
string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
db->GetIntProperty(subkey_cf_handle, rocksdb::DB::Properties::kBlockCachePinnedUsage, &block_cache_pinned_usage);
string_stream << "block_cache_pinned_usage[" << subkey_cf_handle->GetName() << "]:" << block_cache_pinned_usage
<< "\r\n";
}

for (const auto &cf_handle : *storage->GetCFHandles()) {
uint64_t estimate_keys = 0;
uint64_t block_cache_pinned_usage = 0;
uint64_t index_and_filter_cache_usage = 0;
std::map<std::string, std::string> cf_stats_map;
db->GetIntProperty(cf_handle, "rocksdb.estimate-num-keys", &estimate_keys);
db->GetIntProperty(cf_handle, rocksdb::DB::Properties::kEstimateNumKeys, &estimate_keys);
string_stream << "estimate_keys[" << cf_handle->GetName() << "]:" << estimate_keys << "\r\n";
db->GetIntProperty(cf_handle, "rocksdb.block-cache-pinned-usage", &block_cache_pinned_usage);
string_stream << "block_cache_pinned_usage[" << cf_handle->GetName() << "]:" << block_cache_pinned_usage << "\r\n";
db->GetIntProperty(cf_handle, "rocksdb.estimate-table-readers-mem", &index_and_filter_cache_usage);
db->GetIntProperty(cf_handle, rocksdb::DB::Properties::kEstimateTableReadersMem, &index_and_filter_cache_usage);
string_stream << "index_and_filter_cache_usage[" << cf_handle->GetName() << "]:" << index_and_filter_cache_usage
<< "\r\n";
db->GetMapProperty(cf_handle, rocksdb::DB::Properties::kCFStats, &cf_stats_map);
Expand Down

0 comments on commit 0e2273a

Please sign in to comment.