DDlog has support for memory and CPU profiling. This commit adds commands for enabling CPU profiling (memory profiling is always enabled) and dumping out the profile.
Signed-off-by: Ben Pfaff <[email protected]> --- northd/ovn-northd-ddlog.c | 40 ++++++++++++++++++++++++++++++++++++++- northd/ovn-northd.8.xml | 36 ++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/northd/ovn-northd-ddlog.c b/northd/ovn-northd-ddlog.c index aa0ea73e401d..41e7decba76b 100644 --- a/northd/ovn-northd-ddlog.c +++ b/northd/ovn-northd-ddlog.c @@ -61,6 +61,10 @@ static unixctl_cb_func ovn_northd_resume; static unixctl_cb_func ovn_northd_is_paused; static unixctl_cb_func ovn_northd_status; +static unixctl_cb_func ovn_northd_enable_cpu_profiling; +static unixctl_cb_func ovn_northd_disable_cpu_profiling; +static unixctl_cb_func ovn_northd_profile; + /* --ddlog-record: The name of a file to which to record DDlog commands for * later replay. Useful for debugging. If null (by default), DDlog commands * are not recorded. */ @@ -391,7 +395,6 @@ northd_parse_updates(struct northd_ctx *ctx, struct ovs_list *updates) return; } - /* Whenever a new 'nb_cfg' value comes in, we take the current time and * push it into the NbCfgTimestamp relation for the DDlog program to put * into nb::NB_Global.nb_cfg_timestamp. @@ -1164,6 +1167,12 @@ main(int argc, char *argv[]) ovs_fatal(0, "DDlog instance could not be created"); } + unixctl_command_register("enable-cpu-profiling", "", 0, 0, + ovn_northd_enable_cpu_profiling, ddlog); + unixctl_command_register("disable-cpu-profiling", "", 0, 0, + ovn_northd_disable_cpu_profiling, ddlog); + unixctl_command_register("profile", "", 0, 0, ovn_northd_profile, ddlog); + int replay_fd = -1; if (record_file) { replay_fd = open(record_file, O_CREAT | O_WRONLY | O_TRUNC, 0666); @@ -1313,3 +1322,32 @@ ovn_northd_status(struct unixctl_conn *conn, int argc OVS_UNUSED, unixctl_command_reply(conn, s); free(s); } + +static void +ovn_northd_enable_cpu_profiling(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *prog_) +{ + ddlog_prog prog = prog_; + ddlog_enable_cpu_profiling(prog, true); + unixctl_command_reply(conn, NULL); +} + +static void +ovn_northd_disable_cpu_profiling(struct unixctl_conn *conn, + int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *prog_) +{ + ddlog_prog prog = prog_; + ddlog_enable_cpu_profiling(prog, false); + unixctl_command_reply(conn, NULL); +} + +static void +ovn_northd_profile(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *prog_) +{ + ddlog_prog prog = prog_; + char *profile = ddlog_profile(prog); + unixctl_command_reply(conn, profile); + free(profile); +} diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index a16937a2147c..97ef049ad9da 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <manpage program="ovn-northd" section="8" title="ovn-northd"> <h1>Name</h1> - <p>ovn-northd -- Open Virtual Network central control daemon</p> + <p>ovn-northd and ovn-northd-ddlog -- Open Virtual Network central control daemon</p> <h1>Synopsis</h1> <p><code>ovn-northd</code> [<var>options</var>]</p> @@ -18,6 +18,14 @@ <code>ovn-sb</code>(5)) below it. </p> + <p> + <code>ovn-northd</code> is implemented in C. + <code>ovn-northd-ddlog</code> is a compatible implementation written in + DDlog, a language for incremental database processing. This + documentation applies to both implementations, with differences indicated + where relevant. + </p> + <h1>Options</h1> <dl> <dt><code>--ovnnb-db=<var>database</var></code></dt> @@ -127,6 +135,32 @@ </dl> </p> + <p> + Only <code>ovn-northd-ddlog</code> supports the following commands: + </p> + + <dl> + <dt><code>enable-cpu-profiling</code></dt> + <dt><code>disable-cpu-profiling</code></dt> + <dd> + Enables or disables profiling of CPU time used by the DDlog engine. + When CPU profiling is enabled, the <code>profile</code> command (see + below) will include DDlog CPU usage statistics in its output. Enabling + CPU profiling will slow <code>ovn-northd-ddlog</code>. Disabling CPU + profiling does not clear any previously recorded statistics. + </dd> + + <dt><code>profile</code></dt> + <dd> + Outputs a profile of the current and peak sizes of arrangements inside + DDlog. This profiling data can be useful for optimizing DDlog code. + If CPU profiling was previously enabled (even if it was later + disabled), the output also includes a CPU time profile. See + <code>Profiling</code> inside the tutorial in the DDlog repository for + an introduction to profiling DDlog. + </dd> + </dl> + <h1>Active-Standby for High Availability</h1> <p> You may run <code>ovn-northd</code> more than once in an OVN deployment. -- 2.29.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
