diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2024-10-06 23:43:56 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2024-10-08 01:31:31 -0700 |
commit | e80f69b923b1a34c755c9ead0dfbfdbaf2fa3f35 (patch) | |
tree | 5ea0b5c349592412f935739dd79dd31cd5974630 /src | |
parent | 8cd80cf9481f2a384a239b9fc1d02874aa7c64a7 (diff) |
charts: compute an "adherence" value
This is an attempt to add a schedule adherence metric which a
subsequent commit will plot in a row below the top IOWait/%Idle %
row.
Ideally the adherence metric's value would always be 0, because
we're always exactly on-time with our samples.
But what tends to happen is falling behind, or rarely being
slightly ahead of schedule (particularly with the epsilon
introduction).
This metric can serve as a sort of proxy for userspace's ability
to get scheduled on time, which is a useful thing to see.
Diffstat (limited to 'src')
-rw-r--r-- | src/charts.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/charts.c b/src/charts.c index ae01c75..4f217bf 100644 --- a/src/charts.c +++ b/src/charts.c @@ -55,6 +55,7 @@ typedef struct _vwm_charts_t { /* libvmon */ struct timeval maybe_sample, last_sample, this_sample; unsigned this_sample_duration; + float this_sample_adherence; /* 0 = on time, (+) behind schedule, (-) ahead of schedule(TODO), units is fraction of .sampling_interval_secs */ typeof(((vmon_sys_stat_t *)0)->user) last_user_cpu; typeof(((vmon_sys_stat_t *)0)->system) last_system_cpu; unsigned long long last_total, this_total, total_delta; @@ -1342,7 +1343,13 @@ int vwm_charts_update(vwm_charts_t *charts, int *desired_delay_us) charts->this_sample_duration = 1; /* ideally always 1, but > 1 when sample deadline missed (repeat sample) */ } - VWM_TRACE("sample_duration=%u", charts->this_sample_duration); + charts->this_sample_adherence = -(charts->sampling_interval_secs - this_delta); + if (charts->this_sample_adherence < CHART_DELTA_SECONDS_EPSILON && charts->this_sample_adherence > -CHART_DELTA_SECONDS_EPSILON) + charts->this_sample_adherence = 0; + charts->this_sample_adherence /= charts->sampling_interval_secs; /* turn adherence into a fraction of the current interval */ + + VWM_TRACE("sample_duration=%u sample_adherence=%f", + charts->this_sample_duration, charts->this_sample_adherence); /* age the sys-wide sample data into "last" variables, before the new sample overwrites them. */ charts->last_sample = charts->this_sample; |