Skip to content

Commit

Permalink
Fixed calculation of operations per second in server metrics (#312)
Browse files Browse the repository at this point in the history
This commit corrects the calculation of the instantaneous operations per second in the server metrics. The previous calculation was incorrectly using the `byteUnit` for conversion, which is not appropriate for operations per second. The corrected calculation now accurately reflects the number of operations processed per second.

Co-authored-by: Tal Zaccai <talzacc@microsoft.com>
  • Loading branch information
deepakverma and TalZaccai authored Apr 23, 2024
1 parent 06eb6f8 commit 6e1ba04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/server/Metrics/GarnetServerMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ private void UpdateInstantaneousMetrics()
var elapsedSec = TimeSpan.FromTicks(currTimestamp - startTimestamp).TotalSeconds;
globalMetrics.instantaneous_net_input_tpt = (globalMetrics.globalSessionMetrics.get_total_net_input_bytes() - instant_input_net_bytes) / (elapsedSec * GarnetServerMetrics.byteUnit);
globalMetrics.instantaneous_net_output_tpt = (globalMetrics.globalSessionMetrics.get_total_net_output_bytes() - instant_output_net_bytes) / (elapsedSec * GarnetServerMetrics.byteUnit);
globalMetrics.instantaneous_cmd_per_sec = (globalMetrics.globalSessionMetrics.get_total_commands_processed() - instant_commands_processed) / (elapsedSec * GarnetServerMetrics.byteUnit);
globalMetrics.instantaneous_cmd_per_sec = (globalMetrics.globalSessionMetrics.get_total_commands_processed() - instant_commands_processed) / elapsedSec;

globalMetrics.instantaneous_net_input_tpt = Math.Round(globalMetrics.instantaneous_net_input_tpt, 2);
globalMetrics.instantaneous_net_output_tpt = Math.Round(globalMetrics.instantaneous_net_output_tpt, 2);
globalMetrics.instantaneous_cmd_per_sec = Math.Round(globalMetrics.instantaneous_cmd_per_sec, 2);
globalMetrics.instantaneous_cmd_per_sec = Math.Round(globalMetrics.instantaneous_cmd_per_sec);

startTimestamp = currTimestamp;
instant_input_net_bytes = globalMetrics.globalSessionMetrics.get_total_net_input_bytes();
Expand Down

0 comments on commit 6e1ba04

Please sign in to comment.