diff --git a/src/server/rdb_save.cc b/src/server/rdb_save.cc index fce38dd52..d1fd03c68 100644 --- a/src/server/rdb_save.cc +++ b/src/server/rdb_save.cc @@ -1196,7 +1196,11 @@ error_code RdbSaver::Impl::ConsumeChannel(const Cancellation* cll) { continue; DVLOG(2) << "Pulled " << record->id; + auto before = absl::GetCurrentTimeNanos(); io_error = sink_->Write(io::Buffer(record->value)); + auto& stats = ServerState::tlocal()->stats; + stats.rdb_save_usec += (absl::GetCurrentTimeNanos() - before) / 1'000; + stats.rdb_save_count++; if (io_error) { break; } diff --git a/src/server/server_family.cc b/src/server/server_family.cc index 49c56b901..4bfa44ef2 100644 --- a/src/server/server_family.cc +++ b/src/server/server_family.cc @@ -1970,6 +1970,8 @@ void ServerFamily::Info(CmdArgList args, ConnectionContext* cntx) { append("total_net_input_bytes", conn_stats.io_read_bytes); append("connection_migrations", conn_stats.num_migrations); append("total_net_output_bytes", reply_stats.io_write_bytes); + append("rdb_save_usec", m.coordinator_stats.rdb_save_usec); + append("rdb_save_count", m.coordinator_stats.rdb_save_count); append("instantaneous_input_kbps", -1); append("instantaneous_output_kbps", -1); append("rejected_connections", -1); diff --git a/src/server/server_state.cc b/src/server/server_state.cc index 1bf55a10d..6fd71629d 100644 --- a/src/server/server_state.cc +++ b/src/server/server_state.cc @@ -28,7 +28,7 @@ ServerState::Stats::Stats(unsigned num_shards) : tx_width_freq_arr(num_shards) { } ServerState::Stats& ServerState::Stats::Add(const ServerState::Stats& other) { - static_assert(sizeof(Stats) == 15 * 8, "Stats size mismatch"); + static_assert(sizeof(Stats) == 17 * 8, "Stats size mismatch"); for (int i = 0; i < NUM_TX_TYPES; ++i) { this->tx_type_cnt[i] += other.tx_type_cnt[i]; @@ -44,6 +44,8 @@ ServerState::Stats& ServerState::Stats::Add(const ServerState::Stats& other) { this->multi_squash_exec_reply_usec += other.multi_squash_exec_reply_usec; this->blocked_on_interpreter += other.blocked_on_interpreter; + this->rdb_save_usec += other.rdb_save_usec; + this->rdb_save_count += other.rdb_save_count; this->oom_error_cmd_cnt += other.oom_error_cmd_cnt; if (this->tx_width_freq_arr.size() > 0) { diff --git a/src/server/server_state.h b/src/server/server_state.h index 85408b028..c28a808c4 100644 --- a/src/server/server_state.h +++ b/src/server/server_state.h @@ -118,6 +118,9 @@ class ServerState { // public struct - to allow initialization. uint64_t blocked_on_interpreter = 0; + uint64_t rdb_save_usec = 0; + uint64_t rdb_save_count = 0; + // Number of times we rejected command dispatch due to OOM condition. uint64_t oom_error_cmd_cnt = 0;