library: lower addr resolution cost for TICS_ALL_DELTA

Rather than run risks of more expensive and repetitive
address resolution, we will establish this local index
for a one time cost and avoid any potential gcc bloat.

[ this commit was made in pursuit of a bug involving ]
[ the distortion of elapsed task tics. but, it turns ]
[ out these changes had nothing to do with that bug. ]
[ however, the patch is being retained as desirable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2021-04-21 00:00:00 -05:00 committed by Craig Small
parent 8e0e3aff64
commit 0f691226ec

View File

@ -626,23 +626,23 @@ static inline int pids_make_hist (
struct pids_info *info, struct pids_info *info,
proc_t *p) proc_t *p)
{ {
#define nSLOT info->hist->num_tasks
TIC_t tics; TIC_t tics;
HST_t *h; HST_t *h;
int slot = info->hist->num_tasks;
if (nSLOT + 1 >= Hr(HHist_siz)) { if (slot + 1 >= Hr(HHist_siz)) {
Hr(HHist_siz) += NEWOLD_GROW; Hr(HHist_siz) += NEWOLD_GROW;
Hr(PHist_sav) = realloc(Hr(PHist_sav), sizeof(HST_t) * Hr(HHist_siz)); Hr(PHist_sav) = realloc(Hr(PHist_sav), sizeof(HST_t) * Hr(HHist_siz));
Hr(PHist_new) = realloc(Hr(PHist_new), sizeof(HST_t) * Hr(HHist_siz)); Hr(PHist_new) = realloc(Hr(PHist_new), sizeof(HST_t) * Hr(HHist_siz));
if (!Hr(PHist_sav) || !Hr(PHist_new)) if (!Hr(PHist_sav) || !Hr(PHist_new))
return 0; return 0;
} }
Hr(PHist_new[nSLOT].pid) = p->tid; Hr(PHist_new[slot].pid) = p->tid;
Hr(PHist_new[nSLOT].maj) = p->maj_flt; Hr(PHist_new[slot].maj) = p->maj_flt;
Hr(PHist_new[nSLOT].min) = p->min_flt; Hr(PHist_new[slot].min) = p->min_flt;
Hr(PHist_new[nSLOT].tics) = tics = (p->utime + p->stime); Hr(PHist_new[slot].tics) = tics = (p->utime + p->stime);
pids_histput(info, nSLOT); pids_histput(info, slot);
if ((h = pids_histget(info, p->tid))) { if ((h = pids_histget(info, p->tid))) {
p->pcpu = tics - h->tics; p->pcpu = tics - h->tics;
@ -650,9 +650,8 @@ static inline int pids_make_hist (
p->min_delta = p->min_flt - h->min; p->min_delta = p->min_flt - h->min;
} }
nSLOT++; info->hist->num_tasks++;
return 1; return 1;
#undef nSLOT
} // end: pids_make_hist } // end: pids_make_hist