]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: Allow disabling of `getrusage` calls
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 16 Oct 2019 17:19:09 +0000 (13:19 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 16 Oct 2019 17:34:59 +0000 (13:34 -0400)
getrusage, in a heavily stressed system, can account for
signficant running time due to process switching to the kernel.
Allow the end-operator to specify `--disable-cpu-time` to
avoid this call.  Additionally we cause `show thread cpu` to
not show up if this is selected.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
configure.ac
doc/user/basic.rst
doc/user/installation.rst
lib/thread.c
vtysh/vtysh.c

index 730e2ae6f06d16759204924d86340131e3fa993e..6147ebf0d8db79d4609572f40f5925c2047a31e4 100755 (executable)
@@ -536,6 +536,8 @@ AC_ARG_ENABLE([backtrace],
   AS_HELP_STRING([--disable-backtrace,], [disable crash backtraces (default autodetect)]))
 AC_ARG_ENABLE([time-check],
   AS_HELP_STRING([--disable-time-check], [disable slow thread warning messages]))
+AC_ARG_ENABLE([cpu-time],
+  AS_HELP_STRING([--disable-cpu-time], [disable cpu usage data gathering]))
 AC_ARG_ENABLE([pcreposix],
   AS_HELP_STRING([--enable-pcreposix], [enable using PCRE Posix libs for regex functions]))
 AC_ARG_ENABLE([fpm],
@@ -614,6 +616,14 @@ if test x"${enable_time_check}" != x"no" ; then
   fi
 fi
 
+case "${enable_cpu_time}" in
+  "no")
+  AC_DEFINE([EXCLUDE_CPU_TIME], [1], [Exclude getrusage data gathering])
+  ;;
+  "*")
+  ;;
+esac
+
 case "${enable_systemd}" in
   "no") ;;
   "yes")
index 5509fd5f0d448a323645b113841e5ec78f7a9efd..c7d722164ac8ac7402329413e975836e1f8a60df 100644 (file)
@@ -451,7 +451,8 @@ Terminal Mode Commands
    This command displays system run statistics for all the different event
    types. If no options is specified all different run types are displayed
    together.  Additionally you can ask to look at (r)ead, (w)rite, (t)imer,
-   (e)vent and e(x)ecute thread event types.
+   (e)vent and e(x)ecute thread event types.  If you have compiled with
+   disable-cpu-time then this command will not show up.
 
 .. index:: show thread poll
 .. clicmd:: show thread poll
index 45549dccad153ee3cbf385e73d0bd8835e3a4795..392a2dd7846e6f60a93b2a42295b96b8f7ff2a47 100644 (file)
@@ -302,6 +302,23 @@ options from the list below.
 
    Build the Sysrepo northbound plugin.
 
+.. option:: --enable-time-check XXX
+
+   When this is enabled with a XXX value in microseconds, any thread that
+   runs for over this value will cause a warning to be issued to the log.
+   If you do not specify any value or don't include this option then
+   the default time is 5 seconds.  If --disable-time-check is specified
+   then no warning is issued for any thread run length.
+
+.. option:: --disable-cpu-time
+
+   Disable cpu process accounting, this command also disables the `show thread cpu`
+   command.  If this option is disabled, --enable-time-check is ignored.  This
+   disabling of cpu time effectively means that the getrusage call is skipped.
+   Since this is a process switch into the kernel, systems with high FRR
+   load might see improvement in behavior.  Be aware that `show thread cpu`
+   is considered a good data gathering tool from the perspective of developers.
+
 You may specify any combination of the above options to the configure
 script. By default, the executables are placed in :file:`/usr/local/sbin`
 and the configuration files in :file:`/usr/local/etc`. The :file:`/usr/local/`
index 6669952ff43a5b5a5f5c2f298ef416cf697728e6..649fe500cd213ed53b2bd13be701010a03d394b9 100644 (file)
@@ -109,6 +109,7 @@ static void cpu_record_hash_free(void *a)
        XFREE(MTYPE_THREAD_STATS, hist);
 }
 
+#ifndef EXCLUDE_CPU_TIME
 static void vty_out_cpu_thread_history(struct vty *vty,
                                       struct cpu_thread_history *a)
 {
@@ -219,6 +220,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)
        if (tmp.total_calls > 0)
                vty_out_cpu_thread_history(vty, &tmp);
 }
+#endif
 
 static void cpu_record_hash_clear(struct hash_bucket *bucket, void *args[])
 {
@@ -288,6 +290,7 @@ static uint8_t parse_filter(const char *filterstr)
        return filter;
 }
 
+#ifndef EXCLUDE_CPU_TIME
 DEFUN (show_thread_cpu,
        show_thread_cpu_cmd,
        "show thread cpu [FILTER]",
@@ -313,6 +316,7 @@ DEFUN (show_thread_cpu,
        cpu_record_print(vty, filter);
        return CMD_SUCCESS;
 }
+#endif
 
 static void show_thread_poll_helper(struct vty *vty, struct thread_master *m)
 {
@@ -403,7 +407,9 @@ DEFUN (clear_thread_cpu,
 
 void thread_cmd_init(void)
 {
+#ifndef EXCLUDE_CPU_TIME
        install_element(VIEW_NODE, &show_thread_cpu_cmd);
+#endif
        install_element(VIEW_NODE, &show_thread_poll_cmd);
        install_element(ENABLE_NODE, &clear_thread_cpu_cmd);
 }
@@ -1511,7 +1517,9 @@ void thread_getrusage(RUSAGE_T *r)
 #define FRR_RUSAGE RUSAGE_SELF
 #endif
        monotime(&r->real);
+#ifndef EXCLUDE_CPU_TIME
        getrusage(FRR_RUSAGE, &(r->cpu));
+#endif
 }
 
 /*
@@ -1527,9 +1535,11 @@ void thread_getrusage(RUSAGE_T *r)
  */
 void thread_call(struct thread *thread)
 {
+#ifndef EXCLUDE_CPU_TIME
        _Atomic unsigned long realtime, cputime;
        unsigned long exp;
        unsigned long helper;
+#endif
        RUSAGE_T before, after;
 
        GETRUSAGE(&before);
@@ -1541,6 +1551,7 @@ void thread_call(struct thread *thread)
 
        GETRUSAGE(&after);
 
+#ifndef EXCLUDE_CPU_TIME
        realtime = thread_consumed_time(&after, &before, &helper);
        cputime = helper;
 
@@ -1585,6 +1596,7 @@ void thread_call(struct thread *thread)
                        realtime / 1000, cputime / 1000);
        }
 #endif /* CONSUMED_TIME_CHECK */
+#endif /* Exclude CPU Time */
 }
 
 /* Execute thread */
index 0c7a7471b1ecb95641698571a5f121068435a05d..8ca992e35f0832f101d6ebb0181eddc0fb1e4aea 100644 (file)
@@ -2255,6 +2255,7 @@ DEFUN (vtysh_show_poll,
        return ret;
 }
 
+#ifndef EXCLUDE_CPU_TIME
 DEFUN (vtysh_show_thread,
        vtysh_show_thread_cmd,
        "show thread cpu [FILTER]",
@@ -2281,6 +2282,7 @@ DEFUN (vtysh_show_thread,
                }
        return ret;
 }
+#endif
 
 DEFUN (vtysh_show_work_queues,
        vtysh_show_work_queues_cmd,
@@ -4077,7 +4079,9 @@ void vtysh_init_vty(void)
        install_element(VIEW_NODE, &vtysh_show_modules_cmd);
        install_element(VIEW_NODE, &vtysh_show_work_queues_cmd);
        install_element(VIEW_NODE, &vtysh_show_work_queues_daemon_cmd);
+#ifndef EXCLUDE_CPU_TIME
        install_element(VIEW_NODE, &vtysh_show_thread_cmd);
+#endif
        install_element(VIEW_NODE, &vtysh_show_poll_cmd);
 
        /* Logging */