From 6459eb9c30286a27416678a78920bca3d2e9dd77 Mon Sep 17 00:00:00 2001 From: Nichamon Naksinehaboon Date: Thu, 21 Dec 2023 14:05:03 -0600 Subject: [PATCH] Move the results of the skipped and oversampled counters The patch makes the update_time_stats command reports the skipped and oversampled counters. Previously, updtr_status reports the counters. --- ldms/python/ldmsd/ldmsd_controller | 22 +++++++----- ldms/src/ldmsd/ldmsd_request.c | 54 ++++-------------------------- 2 files changed, 21 insertions(+), 55 deletions(-) diff --git a/ldms/python/ldmsd/ldmsd_controller b/ldms/python/ldmsd/ldmsd_controller index d5466ec05..4cb41f6ce 100755 --- a/ldms/python/ldmsd/ldmsd_controller +++ b/ldms/python/ldmsd/ldmsd_controller @@ -1114,8 +1114,8 @@ class LdmsdCmdParser(cmd.Cmd): rc, msg = self.comm.updtr_status(**arg) if rc == 0: updaters = fmt_status(msg) - print("Name Interval:Offset Auto Mode State Skipped counter Oversampled counter") - print(f"---------------- ---------------- ------ --------------- ------------ {'-'*15} {'-'*19}") + print("Name Interval:Offset Auto Mode State") + print(f"---------------- ---------------- ------ --------------- ---------------") for updtr in updaters: if 'auto' in updtr: auto = updtr['auto'] @@ -1124,8 +1124,7 @@ class LdmsdCmdParser(cmd.Cmd): auto = updtr['????'] interval_s = cvt_intrvl_off_to_str(updtr['interval'], updtr['offset']) print(f"{updtr['name']:16} {interval_s:16} {auto:6} {updtr['mode']:15} " \ - f"{updtr['state']:10} {updtr['outstanding count']:15} " \ - f"{updtr['oversampled count']:19}") + f"{updtr['state']:10}") if arg['summary'] is None: for prdcr in updtr['producers']: print(" {0:16} {1:16} {2:12} {3:12} {4:12}".format( @@ -1143,7 +1142,9 @@ class LdmsdCmdParser(cmd.Cmd): 'cnt' : 0, 'min_prdcr' : None, 'max_prdcr' : None, - 'producers' : {} + 'producers' : {}, + 'skipped_cnt': 0, + 'oversampled_cnt': 0 } for p, prdcr in updtr.items(): @@ -1173,6 +1174,9 @@ class LdmsdCmdParser(cmd.Cmd): pstats['avg'] = pstats['avg'] * (pstats['cnt']/(pstats['cnt'] + prdset['cnt'])) pstats['avg'] += prdset['avg'] * (prdset['cnt']/(pstats['cnt'] + prdset['cnt'])) pstats['cnt'] += prdset['cnt'] + + stats['skipped_cnt'] += prdset['skipped_cnt'] + stats['oversampled_cnt'] += prdset['oversampled_cnt'] stats['producers'][p] = pstats if stats['min'] > pstats['min']: @@ -1209,13 +1213,15 @@ class LdmsdCmdParser(cmd.Cmd): return j = fmt_status(msg) - print("Updater Min(usec) Max(usec) Average(usec) Count ") - print(f"{'-'*15} {'-'*15} {'-'*15} {'-'*15} {'-'*10}") + print(f"{'Updater':15} {'Min(usec)':15} {'Max(usec)':15} {'Average(usec)':15} {'Count':10} {'Skipped Count':15} {'Oversampled Count':15}") + print(f"{'-'*15} {'-'*15} {'-'*15} {'-'*15} {'-'*10} {'-'*15} {'-'*15}") if rc !=0: return for n, updtr in j.items(): stats = self.__update_time_stats(updtr) - print(f"{n:15} {stats['min']:15.4f} {stats['max']:15.4f} {stats['avg']:15.4f} {stats['cnt']:10}") + print(f"{n:15} {stats['min']:15.4f} {stats['max']:15.4f} " \ + f"{stats['avg']:15.4f} {stats['cnt']:10} " \ + f"{stats['skipped_cnt']:15} {stats['oversampled_cnt']:15}") def complete_update_time_stats(self, text, line, begidx, endidx): return self.__complete_attr_list('update_time_stats', text) diff --git a/ldms/src/ldmsd/ldmsd_request.c b/ldms/src/ldmsd/ldmsd_request.c index 1869d15d4..05bbf1b4d 100644 --- a/ldms/src/ldmsd/ldmsd_request.c +++ b/ldms/src/ldmsd/ldmsd_request.c @@ -4079,12 +4079,7 @@ int __updtr_status_json_obj(ldmsd_req_ctxt_t reqc, ldmsd_updtr_t updtr, ldmsd_prdcr_ref_t ref; ldmsd_prdcr_t prdcr; int prdcr_count; - ldmsd_prdcr_set_t prdset; - ldmsd_name_match_t match = NULL; long default_offset = 0; - int skipped_cnt = 0; - int oversampled_cnt = 0; - const char *str; if (updtr_cnt) { rc = linebuf_printf(reqc, ",\n"); @@ -4137,47 +4132,8 @@ int __updtr_status_json_obj(ldmsd_req_ctxt_t reqc, ldmsd_updtr_t updtr, prdcr_state_str(prdcr->conn_state)); if (rc) goto out; - - if (LIST_EMPTY(&updtr->match_list)) { - prdset = ldmsd_prdcr_set_first(prdcr); - while (prdset) { - __updtr_stats(prdset, &skipped_cnt, - &oversampled_cnt); - if (reset) { - prdset->oversampled_cnt = 0; - prdset->skipped_upd_cnt = 0; - } - prdset = ldmsd_prdcr_set_next(prdset); - } - } else { - LIST_FOREACH(match, &updtr->match_list, entry) { - prdset = ldmsd_prdcr_set_first(prdcr); - while (prdset) { - if (match) { - if (match->selector == LDMSD_NAME_MATCH_INST_NAME) - str = prdset->inst_name; - else - str = prdset->schema_name; - rc = regexec(&match->regex, str, 0, NULL, 0); - if (rc) - goto next; - } - __updtr_stats(prdset, &skipped_cnt, - &oversampled_cnt); - if (reset) { - prdset->oversampled_cnt = 0; - prdset->skipped_upd_cnt = 0; - } - next: - prdset = ldmsd_prdcr_set_next(prdset); - } - } - } } - rc = linebuf_printf(reqc, "]," - "\"outstanding count\":%d," - "\"oversampled count\":%d}", - skipped_cnt, oversampled_cnt); + rc = linebuf_printf(reqc, "]}"); out: ldmsd_updtr_unlock(updtr); return rc; @@ -8429,14 +8385,18 @@ __prdset_upd_time_stats_json_obj(ldmsd_req_ctxt_t reqc, ldmsd_updtr_t updtr, "\"min\":%lf," "\"max\":%lf," "\"avg\":%lf," - "\"cnt\":%d" + "\"cnt\":%d," + "\"skipped_cnt\":%d," + "\"oversampled_cnt\":%d" "}", (cnt?",":""), prdset->inst_name, prdset->updt_stat.min, prdset->updt_stat.max, prdset->updt_stat.avg, - prdset->updt_stat.count); + prdset->updt_stat.count, + prdset->skipped_upd_cnt, + prdset->oversampled_cnt); if (reset) memset(&prdset->updt_stat, 0, sizeof(prdset->updt_stat)); pthread_mutex_unlock(&prdset->lock);