From 842d19c4e101ec3f9ae91d024b42e5161d633832 Mon Sep 17 00:00:00 2001
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date: Wed, 24 Feb 2021 16:38:13 +0100
Subject: [PATCH 04/16] controller: introduce stats counters for ovn-controller
incremental processing
Introduce inc-engine/show-stats ovs-appctl command in order to dump
ovn-controller incremental processing engine statistics. So far for each
node a counter for run, abort and engine_handler have been added.
Counters are incremented when the node move to "updated" state.
In order to dump I-P stats we can can use the following commands:
$ovs-appctl -t ovn-controller inc-engine/show-stats
Node: SB_address_set
- recompute: 38
- compute: 0
- abort: 0
Node: addr_sets
- recompute: 2
- compute: 0
- abort: 1
Node: SB_port_group
- recompute: 37
- compute: 0
- abort: 0
....
Node: flow_output
- recompute: 2
- compute: 20
- abort: 0
Moreover introduce the inc-engine/clear-stats command to reset engine
statistics
$ovs-appctl -t ovn-controller inc-engine/clear-stats
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Acked-by: Mark Gray <mark.d.gray@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
(cherry picked from commit 0ddb8b2c979c1102d206b4f855eb5fbe1566768e)
Change-Id: I4a83688dabc8fff2f9d34b885ad9ba0fc90d7e38
---
controller/ovn-controller.8.xml | 22 ++++++++++++++++
lib/inc-proc-eng.c | 46 +++++++++++++++++++++++++++++++++
lib/inc-proc-eng.h | 9 +++++++
3 files changed, 77 insertions(+)
diff --git a/controller/ovn-controller.8.xml b/controller/ovn-controller.8.xml
index 51c0c372c..8886df568 100644
--- a/controller/ovn-controller.8.xml
+++ b/controller/ovn-controller.8.xml
@@ -578,6 +578,28 @@
Displays logical flow cache statistics: enabled/disabled, per cache
type entry counts.
</dd>
+
+ <dt><code>inc-engine/show-stats</code></dt>
+ <dd>
+ Display <code>ovn-controller</code> engine counters. For each engine
+ node the following counters have been added:
+ <ul>
+ <li>
+ <code>recompute</code>
+ </li>
+ <li>
+ <code>compute</code>
+ </li>
+ <li>
+ <code>abort</code>
+ </li>
+ </ul>
+ </dd>
+
+ <dt><code>inc-engine/clear-stats</code></dt>
+ <dd>
+ Reset <code>ovn-controller</code> engine counters.
+ </dd>
</dl>
</p>
diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c
index 916dbbe39..a6337a1d9 100644
--- a/lib/inc-proc-eng.c
+++ b/lib/inc-proc-eng.c
@@ -27,6 +27,7 @@
#include "openvswitch/hmap.h"
#include "openvswitch/vlog.h"
#include "inc-proc-eng.h"
+#include "unixctl.h"
VLOG_DEFINE_THIS_MODULE(inc_proc_eng);
@@ -102,6 +103,40 @@ engine_get_nodes(struct engine_node *node, size_t *n_count)
return engine_topo_sort(node, NULL, n_count, &n_size);
}
+static void
+engine_clear_stats(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED)
+{
+ for (size_t i = 0; i < engine_n_nodes; i++) {
+ struct engine_node *node = engine_nodes[i];
+
+ memset(&node->stats, 0, sizeof node->stats);
+ }
+ unixctl_command_reply(conn, NULL);
+}
+
+static void
+engine_dump_stats(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED)
+{
+ struct ds dump = DS_EMPTY_INITIALIZER;
+
+ for (size_t i = 0; i < engine_n_nodes; i++) {
+ struct engine_node *node = engine_nodes[i];
+
+ ds_put_format(&dump,
+ "Node: %s\n"
+ "- recompute: %12"PRIu64"\n"
+ "- compute: %12"PRIu64"\n"
+ "- abort: %12"PRIu64"\n",
+ node->name, node->stats.recompute,
+ node->stats.compute, node->stats.abort);
+ }
+ unixctl_command_reply(conn, ds_cstr(&dump));
+
+ ds_destroy(&dump);
+}
+
void
engine_init(struct engine_node *node, struct engine_arg *arg)
{
@@ -115,6 +150,11 @@ engine_init(struct engine_node *node, struct engine_arg *arg)
engine_nodes[i]->data = NULL;
}
}
+
+ unixctl_command_register("inc-engine/show-stats", "", 0, 0,
+ engine_dump_stats, NULL);
+ unixctl_command_register("inc-engine/clear-stats", "", 0, 0,
+ engine_clear_stats, NULL);
}
void
@@ -288,6 +328,7 @@ engine_recompute(struct engine_node *node, bool forced, bool allowed)
/* Run the node handler which might change state. */
node->run(node, node->data);
+ node->stats.recompute++;
}
/* Return true if the node could be computed, false otherwise. */
@@ -312,6 +353,8 @@ engine_compute(struct engine_node *node, bool recompute_allowed)
}
}
}
+ node->stats.compute++;
+
return true;
}
@@ -321,6 +364,7 @@ engine_run_node(struct engine_node *node, bool recompute_allowed)
if (!node->n_inputs) {
/* Run the node handler which might change state. */
node->run(node, node->data);
+ node->stats.recompute++;
return;
}
@@ -377,6 +421,7 @@ engine_run(bool recompute_allowed)
engine_run_node(engine_nodes[i], recompute_allowed);
if (engine_nodes[i]->state == EN_ABORTED) {
+ engine_nodes[i]->stats.abort++;
engine_run_aborted = true;
return;
}
@@ -393,6 +438,7 @@ engine_need_run(void)
}
engine_nodes[i]->run(engine_nodes[i], engine_nodes[i]->data);
+ engine_nodes[i]->stats.recompute++;
VLOG_DBG("input node: %s, state: %s", engine_nodes[i]->name,
engine_node_state_name[engine_nodes[i]->state]);
if (engine_nodes[i]->state == EN_UPDATED) {
diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h
index 857234677..7e9f5bb70 100644
--- a/lib/inc-proc-eng.h
+++ b/lib/inc-proc-eng.h
@@ -107,6 +107,12 @@ enum engine_node_state {
EN_STATE_MAX,
};
+struct engine_stats {
+ uint64_t recompute;
+ uint64_t compute;
+ uint64_t abort;
+};
+
struct engine_node {
/* A unique name for each node. */
char *name;
@@ -154,6 +160,9 @@ struct engine_node {
/* Method to clear up tracked data maintained by the engine node in the
* engine 'data'. It may be NULL. */
void (*clear_tracked_data)(void *tracked_data);
+
+ /* Engine stats. */
+ struct engine_stats stats;
};
/* Initialize the data for the engine nodes. It calls each node's
--
2.29.2