This RFC patch enables batch processing of OVS and southbound database
updates using the _until variant of the ovsdb_idl_loop_run() function
proposed in the patch set at [1] and using a timeout of 500ms.  It also
adds new stopwatches to allow operators to observe how much time is
actually spent in the idl loop.

[1] https://mail.openvswitch.org/pipermail/ovs-dev/2025-May/423275.html

Signed-off-by: Martin Morgenstern <martin.morgenst...@cloudandheat.com>
---
As it stands now, this patch unfortunately breaks some tests of the OVN
test suite. Most often they appear in tests that restart the
ovn-controller and in the AT_CLEANUP stage of tests (e.g., "restart
should not delete patch ports").  It seems the debug/dump-related-ports
command is received too early after the ovn-controller restarts (but
unsure why), before the first I-P loop runs, and the dumped variable is
still empty.

Although sometimes it seems to help to insert additional sleeps or
additional unixctl commands, the actual root cause of this behavior is
unclear to me.  Enabling more verbose logging in the tests makes the
tests passing again, and I see different test results locally vs. on
Github Actions.  Any ideas on how to approach this or debug this further
are highly appreciated.

Thanks a lot,
Martin
---
 controller/ovn-controller.c | 17 +++++++++++++++--
 controller/ovn-controller.h |  2 ++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 13a566d26..eddbb16a1 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -128,6 +128,8 @@ static unixctl_cb_func debug_ignore_startup_delay;
 #define OFCTRL_SEQNO_RUN_STOPWATCH_NAME "ofctrl-seqno-run"
 #define BFD_RUN_STOPWATCH_NAME "bfd-run"
 #define VIF_PLUG_RUN_STOPWATCH_NAME "vif-plug-run"
+#define SB_IDL_LOOP_RUN_STOPWATCH_NAME "sb-idl-loop-run"
+#define OVS_IDL_LOOP_RUN_STOPWATCH_NAME "ovs-idl-loop-run"
 
 #define OVS_NB_CFG_NAME "ovn-nb-cfg"
 #define OVS_NB_CFG_TS_NAME "ovn-nb-cfg-ts"
@@ -5629,6 +5631,8 @@ main(int argc, char *argv[])
     stopwatch_create(OFCTRL_SEQNO_RUN_STOPWATCH_NAME, SW_MS);
     stopwatch_create(BFD_RUN_STOPWATCH_NAME, SW_MS);
     stopwatch_create(VIF_PLUG_RUN_STOPWATCH_NAME, SW_MS);
+    stopwatch_create(SB_IDL_LOOP_RUN_STOPWATCH_NAME, SW_MS);
+    stopwatch_create(OVS_IDL_LOOP_RUN_STOPWATCH_NAME, SW_MS);
 
     /* Define inc-proc-engine nodes. */
     ENGINE_NODE(sb_ro, "sb_ro");
@@ -6075,7 +6079,13 @@ main(int argc, char *argv[])
 
         engine_init_run();
 
-        struct ovsdb_idl_txn *ovs_idl_txn = ovsdb_idl_loop_run(&ovs_idl_loop);
+
+        stopwatch_start(OVS_IDL_LOOP_RUN_STOPWATCH_NAME, time_msec());
+        struct ovsdb_idl_txn *ovs_idl_txn
+            = ovsdb_idl_loop_run_until(&ovs_idl_loop,
+                                       IDL_LOOP_MAX_DURATION_MS + time_msec());
+        stopwatch_stop(OVS_IDL_LOOP_RUN_STOPWATCH_NAME, time_msec());
+
         unsigned int new_ovs_cond_seqno
             = ovsdb_idl_get_condition_seqno(ovs_idl_loop.idl);
         if (new_ovs_cond_seqno != ovs_cond_seqno) {
@@ -6091,8 +6101,11 @@ main(int argc, char *argv[])
                      &ctrl_engine_ctx, &ovnsb_expected_cond_seqno);
         update_ssl_config(ovsrec_ssl_table_get(ovs_idl_loop.idl));
 
+        stopwatch_start(SB_IDL_LOOP_RUN_STOPWATCH_NAME, time_msec());
         struct ovsdb_idl_txn *ovnsb_idl_txn
-            = ovsdb_idl_loop_run(&ovnsb_idl_loop);
+            = ovsdb_idl_loop_run_until(&ovnsb_idl_loop,
+                                       IDL_LOOP_MAX_DURATION_MS + time_msec());
+        stopwatch_stop(SB_IDL_LOOP_RUN_STOPWATCH_NAME, time_msec());
         unsigned int new_ovnsb_cond_seqno
             = ovsdb_idl_get_condition_seqno(ovnsb_idl_loop.idl);
         if (new_ovnsb_cond_seqno != ovnsb_cond_seqno) {
diff --git a/controller/ovn-controller.h b/controller/ovn-controller.h
index fafd704df..b8492d550 100644
--- a/controller/ovn-controller.h
+++ b/controller/ovn-controller.h
@@ -19,6 +19,8 @@
 
 #include <stdint.h>
 
+#define IDL_LOOP_MAX_DURATION_MS 500
+
 struct ovsrec_bridge_table;
 
 const struct ovsrec_bridge *get_bridge(const struct ovsrec_bridge_table *,
-- 
2.45.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to