Skip to content

Commit

Permalink
Correct bytes_per_key computing. (redis#12897)
Browse files Browse the repository at this point in the history
Change the calculation method of bytes_per_key to make it closer to
the true average key size. The calculation method is as follows:

mh->bytes_per_key = mh->total_keys ? (mh->dataset / mh->total_keys) : 0;
  • Loading branch information
CharlesChen888 authored Jan 12, 2024
1 parent 964f4a4 commit 8778634
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
if (zmalloc_used > mh->startup_allocated)
net_usage = zmalloc_used - mh->startup_allocated;
mh->dataset_perc = (float)mh->dataset*100/net_usage;
mh->bytes_per_key = mh->total_keys ? (net_usage / mh->total_keys) : 0;
mh->bytes_per_key = mh->total_keys ? (mh->dataset / mh->total_keys) : 0;

return mh;
}
Expand Down

0 comments on commit 8778634

Please sign in to comment.