summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dbarach@cisco.com>2019-05-10 08:38:25 -0400
committerOle Trøan <otroan@employees.org>2019-05-10 20:35:07 +0000
commitf89a6de8f032536080c4a11b267bf921093d3740 (patch)
tree8232aae59c18c773de4aada76b67384dac01b67b
parentbff9f2f2e7a288886cd843bc90446ef1d26615dd (diff)
Fix stat seg average vector rate computation
Add the number of worker threads and per worker thread vector rates to the stats segment. Change-Id: I3040108ec9fcdf5fdb6b9a950060dea9b3c88fd1 Signed-off-by: Dave Barach <dbarach@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--src/vpp/stats/stat_segment.c42
-rw-r--r--src/vpp/stats/stat_segment.h25
2 files changed, 53 insertions, 14 deletions
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index 2338a2564bf..300cfe785e1 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -506,29 +506,63 @@ update_node_counters (stat_segment_main_t * sm)
static void
do_stat_segment_updates (stat_segment_main_t * sm)
{
+ stat_segment_shared_header_t *shared_header = sm->shared_header;
vlib_main_t *vm = vlib_mains[0];
f64 vector_rate;
u64 input_packets, last_input_packets;
f64 dt, now;
vlib_main_t *this_vlib_main;
int i, start;
+ counter_t **counters;
+ static int num_worker_threads_set;
+
+ /*
+ * Set once at the beginning of time.
+ * Can't do this from the init routine, which happens before
+ * start_workers sets up vlib_mains...
+ */
+ if (PREDICT_FALSE (num_worker_threads_set == 0))
+ {
+ sm->directory_vector[STAT_COUNTER_NUM_WORKER_THREADS].value =
+ vec_len (vlib_mains) > 1 ? vec_len (vlib_mains) - 1 : 1;
+
+ stat_validate_counter_vector (&sm->directory_vector
+ [STAT_COUNTER_VECTOR_RATE_PER_WORKER],
+ vec_len (vlib_mains));
+ num_worker_threads_set = 1;
+ }
/*
- * Compute the average vector rate across all workers
+ * Compute per-worker vector rates, and the average vector rate
+ * across all workers
*/
vector_rate = 0.0;
+ counters =
+ stat_segment_pointer (shared_header,
+ sm->directory_vector
+ [STAT_COUNTER_VECTOR_RATE_PER_WORKER].offset);
+
start = vec_len (vlib_mains) > 1 ? 1 : 0;
for (i = start; i < vec_len (vlib_mains); i++)
{
+
+ f64 this_vector_rate;
+
this_vlib_main = vlib_mains[i];
- vector_rate += vlib_last_vector_length_per_node (this_vlib_main);
+
+ this_vector_rate = vlib_last_vector_length_per_node (this_vlib_main);
+ vector_rate += this_vector_rate;
+
+ /* Set the per-worker rate */
+ counters[i - start][0] = this_vector_rate;
}
+
+ /* And set the system average rate */
vector_rate /= (f64) (i - start);
- sm->directory_vector[STAT_COUNTER_VECTOR_RATE].value =
- vector_rate / ((f64) (vec_len (vlib_mains) - start));
+ sm->directory_vector[STAT_COUNTER_VECTOR_RATE].value = vector_rate;
/*
* Compute the aggregate input rate
diff --git a/src/vpp/stats/stat_segment.h b/src/vpp/stats/stat_segment.h
index 4167695a94c..fd7ce79cabe 100644
--- a/src/vpp/stats/stat_segment.h
+++ b/src/vpp/stats/stat_segment.h
@@ -24,6 +24,8 @@
typedef enum
{
STAT_COUNTER_VECTOR_RATE = 0,
+ STAT_COUNTER_NUM_WORKER_THREADS,
+ STAT_COUNTER_VECTOR_RATE_PER_WORKER,
STAT_COUNTER_INPUT_RATE,
STAT_COUNTER_LAST_UPDATE,
STAT_COUNTER_LAST_STATS_CLEAR,
@@ -37,16 +39,19 @@ typedef enum
STAT_COUNTERS
} stat_segment_counter_t;
-#define foreach_stat_segment_counter_name \
- _(VECTOR_RATE, SCALAR_INDEX, vector_rate, /sys) \
- _(INPUT_RATE, SCALAR_INDEX, input_rate, /sys) \
- _(LAST_UPDATE, SCALAR_INDEX, last_update, /sys) \
- _(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear, /sys) \
- _(HEARTBEAT, SCALAR_INDEX, heartbeat, /sys) \
- _(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
- _(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
- _(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
- _(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
+#define foreach_stat_segment_counter_name \
+ _(VECTOR_RATE, SCALAR_INDEX, vector_rate, /sys) \
+ _(VECTOR_RATE_PER_WORKER, COUNTER_VECTOR_SIMPLE, \
+ vector_rate_per_worker, /sys) \
+ _(NUM_WORKER_THREADS, SCALAR_INDEX, num_worker_threads, /sys) \
+ _(INPUT_RATE, SCALAR_INDEX, input_rate, /sys) \
+ _(LAST_UPDATE, SCALAR_INDEX, last_update, /sys) \
+ _(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear, /sys) \
+ _(HEARTBEAT, SCALAR_INDEX, heartbeat, /sys) \
+ _(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
+ _(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
+ _(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
+ _(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
_(INTERFACE_NAMES, NAME_VECTOR, names, /if) \
_(NODE_NAMES, NAME_VECTOR, names, /sys/node)