]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: flush scheduler stats on "set profiling tasks on"
authorWilly Tarreau <w@1wt.eu>
Fri, 29 Jan 2021 10:56:21 +0000 (11:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 29 Jan 2021 11:10:33 +0000 (12:10 +0100)
If a user enables profiling by hand, it makes sense to reset the stats
counters to provide fresh new measurements. Therefore it's worth using
this as the standard method to reset counters.

doc/management.txt
src/activity.c

index 99b3e5936cef17977e087003dd4216bc5d1a48c1..e71849a525b0541522ad1e6c9b7d1533e606e0ba 100644 (file)
@@ -1788,7 +1788,9 @@ set maxconn global <maxconn>
 set profiling { tasks } { auto | on | off }
   Enables or disables CPU profiling for the indicated subsystem. This is
   equivalent to setting or clearing the "profiling" settings in the "global"
-  section of the configuration file. Please also see "show profiling".
+  section of the configuration file. Please also see "show profiling". Note
+  that manually setting the tasks profiling to "on" automatically resets the
+  scheduler statistics, thus allows to check activity over a given interval.
 
 set rate-limit connections global <value>
   Change the process-wide connection rate limit, which is set by the global
index e0e6693b7bdfe1bcc1ae1fba9af5625972285d0b..ffad3701d6b7c778e56bc122fba7eab819dbaf98 100644 (file)
@@ -72,8 +72,17 @@ static int cli_parse_set_profiling(char **args, char *payload, struct appctx *ap
 
        if (strcmp(args[3], "on") == 0) {
                unsigned int old = profiling;
+               int i;
+
                while (!_HA_ATOMIC_CAS(&profiling, &old, (old & ~HA_PROF_TASKS_MASK) | HA_PROF_TASKS_ON))
                        ;
+               /* also flush current profiling stats */
+               for (i = 0; i < 256; i++) {
+                       HA_ATOMIC_STORE(&sched_activity[i].calls, 0);
+                       HA_ATOMIC_STORE(&sched_activity[i].cpu_time, 0);
+                       HA_ATOMIC_STORE(&sched_activity[i].lat_time, 0);
+                       HA_ATOMIC_STORE(&sched_activity[i].func, NULL);
+               }
        }
        else if (strcmp(args[3], "auto") == 0) {
                unsigned int old = profiling;