For performance measurement, it is useful to understand the length of time required to complete a number of key code paths in ovn-northd.c. Add stopwatches to measure these timings.
Signed-off-by: Mark Gray <mark.d.g...@redhat.com> Acked-by: Dumitru Ceara <dce...@redhat.com> --- Notes: v4: Add common header file for stopwatch names lib/automake.mk | 3 ++- northd/ovn-northd-ddlog.c | 12 ++++++++++++ northd/ovn-northd.c | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/automake.mk b/lib/automake.mk index 917b28e1edf7..59345cbf84e6 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -39,7 +39,8 @@ nodist_lib_libovn_la_SOURCES = \ lib/ovn-ic-nb-idl.c \ lib/ovn-ic-nb-idl.h \ lib/ovn-ic-sb-idl.c \ - lib/ovn-ic-sb-idl.h + lib/ovn-ic-sb-idl.h \ + lib/stopwatch-names.h CLEANFILES += $(nodist_lib_libovn_la_SOURCES) diff --git a/northd/ovn-northd-ddlog.c b/northd/ovn-northd-ddlog.c index bc2c75f51bb0..a02949b2d1b7 100644 --- a/northd/ovn-northd-ddlog.c +++ b/northd/ovn-northd-ddlog.c @@ -38,6 +38,8 @@ #include "ovsdb-parser.h" #include "ovsdb-types.h" #include "simap.h" +#include "stopwatch.h" +#include "lib/stopwatch-names.h" #include "stream-ssl.h" #include "stream.h" #include "unixctl.h" @@ -1267,6 +1269,10 @@ main(int argc, char *argv[]) daemonize_complete(); + stopwatch_create(NORTHD_LOOP_STOPWATCH_NAME, SW_MS); + stopwatch_create(OVNNB_DB_RUN_STOPWATCH_NAME, SW_MS); + stopwatch_create(OVNSB_DB_RUN_STOPWATCH_NAME, SW_MS); + /* Main loop. */ exiting = false; while (!exiting) { @@ -1293,8 +1299,12 @@ main(int argc, char *argv[]) status.locked = has_lock; status.pause = sb_ctx->paused; + stopwatch_start(OVNNB_DB_RUN_STOPWATCH_NAME, time_msec()); northd_run(nb_ctx); + stopwatch_stop(OVNNB_DB_RUN_STOPWATCH_NAME, time_msec()); + stopwatch_start(OVNSB_DB_RUN_STOPWATCH_NAME, time_msec()); northd_run(sb_ctx); + stopwatch_stop(OVNSB_DB_RUN_STOPWATCH_NAME, time_msec()); northd_update_probe_interval(nb_ctx, sb_ctx); if (ovsdb_cs_has_lock(sb_ctx->cs) && sb_ctx->state == S_UPDATE && @@ -1305,6 +1315,8 @@ main(int argc, char *argv[]) northd_send_deltas(sb_ctx); } + stopwatch_stop(NORTHD_LOOP_STOPWATCH_NAME, time_msec()); + stopwatch_start(NORTHD_LOOP_STOPWATCH_NAME, time_msec()); unixctl_server_run(unixctl); northd_wait(nb_ctx); diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index e96494ba3c7a..2149c8f60459 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -50,6 +50,8 @@ #include "smap.h" #include "sset.h" #include "svec.h" +#include "stopwatch.h" +#include "lib/stopwatch-names.h" #include "stream.h" #include "stream-ssl.h" #include "timeval.h" @@ -13261,6 +13263,9 @@ ovnnb_db_run(struct northd_context *ctx, if (!ctx->ovnsb_txn || !ctx->ovnnb_txn) { return; } + + stopwatch_start(OVNNB_DB_RUN_STOPWATCH_NAME, time_msec()); + struct hmap port_groups; struct hmap mcast_groups; struct hmap igmp_groups; @@ -13404,6 +13409,8 @@ ovnnb_db_run(struct northd_context *ctx, * as well. */ cleanup_macam(); + + stopwatch_stop(OVNNB_DB_RUN_STOPWATCH_NAME, time_msec()); } /* Stores the list of chassis which references an ha_chassis_group. @@ -13996,6 +14003,8 @@ ovnsb_db_run(struct northd_context *ctx, return; } + stopwatch_start(OVNSB_DB_RUN_STOPWATCH_NAME, time_msec()); + struct shash ha_ref_chassis_map = SHASH_INITIALIZER(&ha_ref_chassis_map); handle_port_binding_changes(ctx, ports, &ha_ref_chassis_map); update_northbound_cfg(ctx, sb_loop, loop_start_time); @@ -14003,6 +14012,8 @@ ovnsb_db_run(struct northd_context *ctx, update_sb_ha_group_ref_chassis(&ha_ref_chassis_map); } shash_destroy(&ha_ref_chassis_map); + + stopwatch_stop(OVNSB_DB_RUN_STOPWATCH_NAME, time_msec()); } static void @@ -14457,6 +14468,10 @@ main(int argc, char *argv[]) char *ovn_internal_version = ovn_get_internal_version(); VLOG_INFO("OVN internal version is : [%s]", ovn_internal_version); + stopwatch_create(NORTHD_LOOP_STOPWATCH_NAME, SW_MS); + stopwatch_create(OVNNB_DB_RUN_STOPWATCH_NAME, SW_MS); + stopwatch_create(OVNSB_DB_RUN_STOPWATCH_NAME, SW_MS); + /* Main loop. */ exiting = false; @@ -14540,6 +14555,8 @@ main(int argc, char *argv[]) ovsdb_idl_wait(ovnsb_idl_loop.idl); } + stopwatch_stop(NORTHD_LOOP_STOPWATCH_NAME, time_msec()); + stopwatch_start(NORTHD_LOOP_STOPWATCH_NAME, time_msec()); unixctl_server_run(unixctl); unixctl_server_wait(unixctl); memory_wait(); -- 2.27.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev