[ovs-dev,RFC,v3,09/10] ovn-controller: Avoid forced recompute when not needed

Message ID 1523909665-27961-10-git-send-email-hzhou8@ebay.com
State Superseded
Headers show
Series
  • ovn-controller Incremental Processing
Related show

Commit Message

Han Zhou April 16, 2018, 8:14 p.m.
Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
 ovn/controller/ovn-controller.c | 11 ++++++++---
 ovn/lib/inc-proc-eng.c          | 19 +++++++++++++++++++
 ovn/lib/inc-proc-eng.h          |  4 ++++
 3 files changed, 31 insertions(+), 3 deletions(-)

Patch

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index c9598f3..1b0bfda 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -1123,9 +1123,14 @@  main(int argc, char *argv[])
         }
         if (old_engine_run_id == engine_run_id ||
                 !ctx.ovnsb_idl_txn || !ctx.ovs_idl_txn) {
-            VLOG_DBG("engine did not run, force recompute next time: "
-                     "br_int %p, chassis %p", br_int, chassis);
-            engine_set_force_recompute(true);
+            if (engine_need_run(&en_flow_output)) {
+                VLOG_DBG("engine did not run, force recompute next time: "
+                         "br_int %p, chassis %p", br_int, chassis);
+                engine_set_force_recompute(true);
+            } else {
+                VLOG_DBG("engine did not run, and it was not needed either: "
+                         "br_int %p, chassis %p", br_int, chassis);
+            }
         } else {
             engine_set_force_recompute(false);
         }
diff --git a/ovn/lib/inc-proc-eng.c b/ovn/lib/inc-proc-eng.c
index 54c7fd6..2e5e907 100644
--- a/ovn/lib/inc-proc-eng.c
+++ b/ovn/lib/inc-proc-eng.c
@@ -123,3 +123,22 @@  engine_run(struct engine_node *node, uint64_t run_id)
 
 }
 
+bool
+engine_need_run(struct engine_node *node)
+{
+    size_t i;
+
+    if (!node->n_inputs) {
+        node->run(node);
+        VLOG_DBG("input node: %s, changed: %d", node->name, node->changed);
+        return node->changed;
+    }
+
+    for (i = 0; i < node->n_inputs; i++) {
+        if (engine_need_run(node->inputs[i].node)) {
+            return true;
+        }
+    }
+
+    return false;
+}
diff --git a/ovn/lib/inc-proc-eng.h b/ovn/lib/inc-proc-eng.h
index 3e0ec16..c5deaa5 100644
--- a/ovn/lib/inc-proc-eng.h
+++ b/ovn/lib/inc-proc-eng.h
@@ -131,6 +131,10 @@  engine_run(struct engine_node *node, uint64_t run_id);
 void
 engine_cleanup(struct engine_node *node);
 
+/* Check if engine needs to run, i.e. any change to be processed */
+bool
+engine_need_run(struct engine_node *node);
+
 /* Get the input node with <name> for <node> */
 static inline struct engine_node *
 engine_get_input(const char *input_name, struct engine_node *node)