summaryrefslogtreecommitdiffstats
path: root/src/vlib/main.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-10-01 13:34:23 -0400
committerOle Trøan <otroan@employees.org>2019-10-04 12:49:16 +0000
commitcefa74829acab2426a0d984f754d2efd6d4a65a4 (patch)
tree163b8fe2353263d1c74d6bceb3d761ff147ea1ee /src/vlib/main.h
parentb7c4a5c76f5a823dce29a1f654e0acb3dce8876d (diff)
vlib: improve summary vector-rate statistics
Type: refactor Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I4b77879b0a84fdec3c1518a972cf003d5135222d Signed-off-by: Ole Troan <ot@cisco.com> (cherry picked from commit a8df85ce1fe957efa8301bd5b5ac3c03737d31f1)
Diffstat (limited to 'src/vlib/main.h')
-rw-r--r--src/vlib/main.h90
1 files changed, 32 insertions, 58 deletions
diff --git a/src/vlib/main.h b/src/vlib/main.h
index 2b50b4e4712..e230ddf8419 100644
--- a/src/vlib/main.h
+++ b/src/vlib/main.h
@@ -95,11 +95,14 @@ typedef struct vlib_main_t
u32 main_loop_vectors_processed;
u32 main_loop_nodes_processed;
- /* Circular buffer of input node vector counts.
- Indexed by low bits of
- (main_loop_count >> VLIB_LOG2_INPUT_VECTORS_PER_MAIN_LOOP). */
- u32 vector_counts_per_main_loop[2];
- u32 node_counts_per_main_loop[2];
+ /* Internal node vectors, calls */
+ u64 internal_node_vectors;
+ u64 internal_node_calls;
+ u64 internal_node_vectors_last_clear;
+ u64 internal_node_calls_last_clear;
+
+ /* Instantaneous vector rate */
+ u32 internal_node_last_vectors_per_main_loop;
/* Main loop hw / sw performance counters */
void (**vlib_node_runtime_perf_counter_cbs) (struct vlib_main_t *,
@@ -323,75 +326,46 @@ vlib_panic (vlib_main_t * vm)
vlib_panic_with_error (vm, 0);
}
-always_inline u32
-vlib_vector_input_stats_index (vlib_main_t * vm, word delta)
-{
- u32 i;
- i = vm->main_loop_count >> VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE;
- ASSERT (is_pow2 (ARRAY_LEN (vm->vector_counts_per_main_loop)));
- return (i + delta) & (ARRAY_LEN (vm->vector_counts_per_main_loop) - 1);
-}
-
-/* Estimate input rate based on previous
- 2^VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE
- samples. */
-always_inline u32
-vlib_last_vectors_per_main_loop (vlib_main_t * vm)
-{
- u32 i = vlib_vector_input_stats_index (vm, -1);
- u32 n = vm->vector_counts_per_main_loop[i];
- return n >> VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE;
-}
-/* Total ave vector count per iteration of main loop. */
always_inline f64
-vlib_last_vectors_per_main_loop_as_f64 (vlib_main_t * vm)
+vlib_internal_node_vector_rate (vlib_main_t * vm)
{
- u32 i = vlib_vector_input_stats_index (vm, -1);
- u32 v = vm->vector_counts_per_main_loop[i];
- return (f64) v / (f64) (1 << VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE);
+ u64 vectors;
+ u64 calls;
+
+ calls = vm->internal_node_calls - vm->internal_node_calls_last_clear;
+
+ if (PREDICT_FALSE (calls == 0))
+ return 0.0;
+
+ vectors = vm->internal_node_vectors - vm->internal_node_vectors_last_clear;
+
+ return (f64) vectors / (f64) calls;
}
-/* Total ave vectors/node count per iteration of main loop. */
-always_inline f64
-vlib_last_vector_length_per_node (vlib_main_t * vm)
+always_inline void
+vlib_clear_internal_node_vector_rate (vlib_main_t * vm)
{
- u32 i = vlib_vector_input_stats_index (vm, -1);
- u32 v = vm->vector_counts_per_main_loop[i];
- u32 n = vm->node_counts_per_main_loop[i];
- return n == 0 ? 0 : (f64) v / (f64) n;
+ vm->internal_node_calls_last_clear = vm->internal_node_calls;
+ vm->internal_node_vectors_last_clear = vm->internal_node_vectors;
}
-extern u32 wraps;
-
always_inline void
vlib_increment_main_loop_counter (vlib_main_t * vm)
{
- u32 i, c, n, v, is_wrap;
-
- c = vm->main_loop_count++;
-
- is_wrap = (c & pow2_mask (VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE)) == 0;
-
- if (is_wrap)
- wraps++;
-
- i = vlib_vector_input_stats_index (vm, /* delta */ is_wrap);
-
- v = is_wrap ? 0 : vm->vector_counts_per_main_loop[i];
- n = is_wrap ? 0 : vm->node_counts_per_main_loop[i];
-
- v += vm->main_loop_vectors_processed;
- n += vm->main_loop_nodes_processed;
- vm->main_loop_vectors_processed = 0;
- vm->main_loop_nodes_processed = 0;
- vm->vector_counts_per_main_loop[i] = v;
- vm->node_counts_per_main_loop[i] = n;
+ vm->main_loop_count++;
+ vm->internal_node_last_vectors_per_main_loop = 0;
if (PREDICT_FALSE (vm->main_loop_exit_now))
clib_longjmp (&vm->main_loop_exit, VLIB_MAIN_LOOP_EXIT_CLI);
}
+always_inline u32
+vlib_last_vectors_per_main_loop (vlib_main_t * vm)
+{
+ return vm->internal_node_last_vectors_per_main_loop;
+}
+
always_inline void vlib_set_queue_signal_callback
(vlib_main_t * vm, void (*fp) (vlib_main_t *))
{