Create a human readable report of latency events for this KeyDB instance. */
| 232 | |
| 233 | /* Create a human readable report of latency events for this KeyDB instance. */ |
| 234 | sds createLatencyReport(void) { |
| 235 | sds report = sdsempty(); |
| 236 | int advise_better_vm = 0; /* Better virtual machines. */ |
| 237 | int advise_slowlog_enabled = 0; /* Enable slowlog. */ |
| 238 | int advise_slowlog_tuning = 0; /* Reconfigure slowlog. */ |
| 239 | int advise_slowlog_inspect = 0; /* Check your slowlog. */ |
| 240 | int advise_disk_contention = 0; /* Try to lower disk contention. */ |
| 241 | int advise_scheduler = 0; /* Intrinsic latency. */ |
| 242 | int advise_data_writeback = 0; /* data=writeback. */ |
| 243 | int advise_no_appendfsync = 0; /* don't fsync during rewrites. */ |
| 244 | int advise_local_disk = 0; /* Avoid remote disks. */ |
| 245 | int advise_ssd = 0; /* Use an SSD drive. */ |
| 246 | int advise_write_load_info = 0; /* Print info about AOF and write load. */ |
| 247 | int advise_hz = 0; /* Use higher HZ. */ |
| 248 | int advise_large_objects = 0; /* Deletion of large objects. */ |
| 249 | int advise_mass_eviction = 0; /* Avoid mass eviction of keys. */ |
| 250 | int advise_relax_fsync_policy = 0; /* appendfsync always is slow. */ |
| 251 | int advise_disable_thp = 0; /* AnonHugePages detected. */ |
| 252 | int advices = 0; |
| 253 | |
| 254 | /* Return ASAP if the latency engine is disabled and it looks like it |
| 255 | * was never enabled so far. */ |
| 256 | if (dictSize(g_pserver->latency_events) == 0 && |
| 257 | g_pserver->latency_monitor_threshold == 0) |
| 258 | { |
| 259 | report = sdscat(report,"I'm sorry, Dave, I can't do that. Latency monitoring is disabled in this KeyDB instance. You may use \"CONFIG SET latency-monitor-threshold <milliseconds>.\" in order to enable it.\n"); |
| 260 | return report; |
| 261 | } |
| 262 | |
| 263 | /* Show all the events stats and add for each event some event-related |
| 264 | * comment depending on the values. */ |
| 265 | dictIterator *di; |
| 266 | dictEntry *de; |
| 267 | int eventnum = 0; |
| 268 | |
| 269 | di = dictGetSafeIterator(g_pserver->latency_events); |
| 270 | while((de = dictNext(di)) != NULL) { |
| 271 | char *event = (char*)dictGetKey(de); |
| 272 | struct latencyTimeSeries *ts = (latencyTimeSeries*)dictGetVal(de); |
| 273 | struct latencyStats ls; |
| 274 | |
| 275 | if (ts == NULL) continue; |
| 276 | eventnum++; |
| 277 | if (eventnum == 1) { |
| 278 | report = sdscat(report,"Dave, I have observed latency spikes in this KeyDB instance. You don't mind talking about it, do you Dave?\n\n"); |
| 279 | } |
| 280 | analyzeLatencyForEvent(event,&ls); |
| 281 | |
| 282 | report = sdscatprintf(report, |
| 283 | "%d. %s: %d latency spikes (average %lums, mean deviation %lums, period %.2f sec). Worst all time event %lums.", |
| 284 | eventnum, event, |
| 285 | ls.samples, |
| 286 | (unsigned long) ls.avg, |
| 287 | (unsigned long) ls.mad, |
| 288 | (double) ls.period/ls.samples, |
| 289 | (unsigned long) ts->max); |
| 290 | |
| 291 | /* Fork */ |
no test coverage detected