MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getMemoryDoctorReport

Function getMemoryDoctorReport

app/redis-6.2.6/src/object.c:1094–1204  ·  view source on GitHub ↗

This implements MEMORY DOCTOR. An human readable analysis of the Redis * memory condition. */

Source from the content-addressed store, hash-verified

1092/* This implements MEMORY DOCTOR. An human readable analysis of the Redis
1093 * memory condition. */
1094sds getMemoryDoctorReport(void) {
1095 int empty = 0; /* Instance is empty or almost empty. */
1096 int big_peak = 0; /* Memory peak is much larger than used mem. */
1097 int high_frag = 0; /* High fragmentation. */
1098 int high_alloc_frag = 0;/* High allocator fragmentation. */
1099 int high_proc_rss = 0; /* High process rss overhead. */
1100 int high_alloc_rss = 0; /* High rss overhead. */
1101 int big_slave_buf = 0; /* Slave buffers are too big. */
1102 int big_client_buf = 0; /* Client buffers are too big. */
1103 int many_scripts = 0; /* Script cache has too many scripts. */
1104 int num_reports = 0;
1105 struct redisMemOverhead *mh = getMemoryOverheadData();
1106
1107 if (mh->total_allocated < (1024*1024*5)) {
1108 empty = 1;
1109 num_reports++;
1110 } else {
1111 /* Peak is > 150% of current used memory? */
1112 if (((float)mh->peak_allocated / mh->total_allocated) > 1.5) {
1113 big_peak = 1;
1114 num_reports++;
1115 }
1116
1117 /* Fragmentation is higher than 1.4 and 10MB ?*/
1118 if (mh->total_frag > 1.4 && mh->total_frag_bytes > 10<<20) {
1119 high_frag = 1;
1120 num_reports++;
1121 }
1122
1123 /* External fragmentation is higher than 1.1 and 10MB? */
1124 if (mh->allocator_frag > 1.1 && mh->allocator_frag_bytes > 10<<20) {
1125 high_alloc_frag = 1;
1126 num_reports++;
1127 }
1128
1129 /* Allocator rss is higher than 1.1 and 10MB ? */
1130 if (mh->allocator_rss > 1.1 && mh->allocator_rss_bytes > 10<<20) {
1131 high_alloc_rss = 1;
1132 num_reports++;
1133 }
1134
1135 /* Non-Allocator rss is higher than 1.1 and 10MB ? */
1136 if (mh->rss_extra > 1.1 && mh->rss_extra_bytes > 10<<20) {
1137 high_proc_rss = 1;
1138 num_reports++;
1139 }
1140
1141 /* Clients using more than 200k each average? */
1142 long numslaves = listLength(server.slaves);
1143 long numclients = listLength(server.clients)-numslaves;
1144 if (mh->clients_normal / numclients > (1024*200)) {
1145 big_client_buf = 1;
1146 num_reports++;
1147 }
1148
1149 /* Slaves using more than 10 MB each? */
1150 if (numslaves > 0 && mh->clients_slaves / numslaves > (1024*1024*10)) {
1151 big_slave_buf = 1;

Callers 1

memoryCommandFunction · 0.85

Calls 5

getMemoryOverheadDataFunction · 0.85
sdsnewFunction · 0.85
sdscatFunction · 0.85
sdscatprintfFunction · 0.85
freeMemoryOverheadDataFunction · 0.85

Tested by

no test coverage detected