From 87786342a525ddef1cee37fb156a328d6b2b28ec Mon Sep 17 00:00:00 2001 From: Chen Tianjie Date: Fri, 12 Jan 2024 11:58:53 +0800 Subject: [PATCH] Correct bytes_per_key computing. (#12897) 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; --- src/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object.c b/src/object.c index bf85c7cc1..48f4820b1 100644 --- a/src/object.c +++ b/src/object.c @@ -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; }