Skip to content

Commit

Permalink
Move the results of the skipped and oversampled counters
Browse files Browse the repository at this point in the history
The patch makes the update_time_stats command reports the skipped and
oversampled counters. Previously, updtr_status reports the counters.
  • Loading branch information
nichamon authored and tom95858 committed Dec 27, 2023
1 parent 0f18dee commit 6459eb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 55 deletions.
22 changes: 14 additions & 8 deletions ldms/python/ldmsd/ldmsd_controller
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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(
Expand All @@ -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():
Expand Down Expand Up @@ -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']:
Expand Down Expand Up @@ -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)
Expand Down
54 changes: 7 additions & 47 deletions ldms/src/ldmsd/ldmsd_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6459eb9

Please sign in to comment.