aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dbarach@cisco.com>2019-05-10 08:38:25 -0400
committerDave Barach <openvpp@barachs.net>2019-06-06 18:13:32 +0000
commit6c36ca545bbd6f65937a4ec0de55614cf7223690 (patch)
tree876c35fd05a0e4ec6617b604f04c3674f87fae6a
parente4a0f9fdc0fcf76d34c8c0d53a2de5b1111c15a9 (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> (cherry picked from commit f89a6de8f032536080c4a11b267bf921093d3740)
-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 05b8cdcb34d..b9d5b23e33e 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -505,29 +505,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)