vlib: calculate per-worker loops/second metric

Use exponential smoothing. Each sample has a half-life of 1
second. reported_rate(t) = reported_rate(t-1) * K + rate(t)*(1-K)

Sample every 20ms, i.e. 50 samples per second
  K = exp (-1.0/20.0);
  K = 0.95;

Type: feature

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I9aea5dd5fecfaefffb78245316adb4bf62eb2bd4
This commit is contained in:
Dave Barach
2020-02-17 17:07:12 -05:00
committed by Florin Coras
parent ff19e3bf4f
commit 000a029e4a
3 changed files with 48 additions and 1 deletions

View File

@ -442,11 +442,12 @@ show_node_runtime (vlib_main_t * vm,
dt = time_now - nm->time_last_runtime_stats_clear;
vlib_cli_output
(vm,
"Time %.1f, %f sec internal node vector rate %.2f \n"
"Time %.1f, %f sec internal node vector rate %.2f loops/sec %.2f\n"
" vector rates in %.4e, out %.4e, drop %.4e, punt %.4e",
dt,
vlib_get_stat_segment_update_rate (),
internal_node_vector_rates[j],
stat_vm->loops_per_second,
(f64) n_input / dt,
(f64) n_output / dt, (f64) n_drop / dt, (f64) n_punt / dt);