Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ admin-thread-pool-size : 2
slow-cmd-list :

# List of commands considered as administrative. These commands will be handled by the admin thread pool. Modify this list as needed.
# Default commands: info, ping, monitor
# Default commands: info, ping, monitor, auth
# This parameter is only supported by the CONFIG GET command and not by CONFIG SET.
admin-cmd-list : info, ping, monitor
admin-cmd-list : info, ping, monitor, auth

# The number of threads to write DB in slaveNode when replicating.
# It's preferable to set slave's sync-thread-num value close to master's thread-pool-size.
Expand Down
1 change: 0 additions & 1 deletion include/pika_cmd_table_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class PikaCmdTableManager {
*/
std::unordered_map<std::string, CommandStatistics> cmdstat_map_;
std::unordered_map<std::string, CommandStatistics> slow_command_count_;
std::thread reset_thread_;
std::mutex command_mutex_;
std::shared_mutex histograms_mutex_;
std::shared_mutex slow_command_mutex_;
Expand Down
1 change: 1 addition & 0 deletions include/pika_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class PikaServer : public pstd::noncopyable {
void ResetStat();
void incr_accumulative_connections();
void ResetLastSecQuerynum();
void ResetCommandCount();
void UpdateQueryNumAndExecCountDB(const std::string& db_name, const std::string& command, bool is_write);
std::unordered_map<std::string, uint64_t> ServerExecCountDB();
std::unordered_map<std::string, QpsStatistic> ServerAllDBStat();
Expand Down
12 changes: 3 additions & 9 deletions src/pika_cmd_table_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@
extern std::unique_ptr<PikaConf> g_pika_conf;

void PikaCmdTableManager::ResetCommandCount() {
while (true) {
std::this_thread::sleep_for(std::chrono::minutes(1));
{
std::lock_guard<std::mutex> lock(command_mutex_);
slow_command_count_.clear();
InitHistograms();
}
}
std::lock_guard<std::mutex> lock(command_mutex_);
slow_command_count_.clear();
InitHistograms();
}

void PikaCmdTableManager::InitHistograms() {
Expand All @@ -38,7 +33,6 @@ PikaCmdTableManager::PikaCmdTableManager() {
cmds_ = std::make_unique<CmdTable>();
cmds_->reserve(300);
InitHistograms();
reset_thread_ = std::thread(&PikaCmdTableManager::ResetCommandCount, this);
}

void PikaCmdTableManager::InitCmdTable(void) {
Expand Down
12 changes: 12 additions & 0 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,16 @@ void PikaServer::ResetLastSecQuerynum() {
statistic_.ResetDBLastSecQuerynum();
}

void PikaServer::ResetCommandCount() {
thread_local uint64_t last_reset_time = 0;
auto current_time = pstd::NowMicros();
if (current_time - last_reset_time < 60 * 1000 * 1000) {
return;
}
last_reset_time = current_time;
g_pika_cmd_table_manager->ResetCommandCount();
}

void PikaServer::UpdateQueryNumAndExecCountDB(const std::string& db_name, const std::string& command, bool is_write) {
std::string cmd(command);
statistic_.server_stat.qps.querynum++;
Expand Down Expand Up @@ -1139,6 +1149,8 @@ void PikaServer::DoTimingTask() {
ResetLastSecQuerynum();
// Auto update network instantaneous metric
AutoUpdateNetworkMetric();
// Reset command statistics
ResetCommandCount();
ProcessCronTask();
UpdateCacheInfo();
// Print the queue status periodically
Expand Down
Loading