MINOR: activity: add a "memory" entry to "profiling"

This adds the necessary flags to permit run-time enabling/disabling of
memory profiling. For now this is disabled.

A few words were added to the management doc about it and recalling that
this is limited to certain OSes.
This commit is contained in:
Willy Tarreau 2021-05-05 16:44:23 +02:00
parent ef7380f916
commit 00dd44f67f
3 changed files with 17 additions and 7 deletions

View File

@ -1917,12 +1917,15 @@ set maxconn global <maxconn>
delayed until the threshold is reached. A value of zero restores the initial
setting.
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"
set profiling { tasks | memory } { auto | on | off }
Enables or disables CPU or memory 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". Note
that manually setting the tasks profiling to "on" automatically resets the
scheduler statistics, thus allows to check activity over a given interval.
The memory profiling is limited to certain operating systems (known to work
on the linux-glibc target), and requires USE_MEMORY_PROFILING to be set at
compile time.
set rate-limit connections global <value>
Change the process-wide connection rate limit, which is set by the global

View File

@ -32,6 +32,8 @@
#define HA_PROF_TASKS_ON 0x00000003 /* per-task CPU profiling forced enabled */
#define HA_PROF_TASKS_MASK 0x00000003 /* per-task CPU profiling mask */
#define HA_PROF_MEMORY 0x00000004 /* memory profiling */
/* per-thread activity reports. It's important that it's aligned on cache lines
* because some elements will be updated very often. Most counters are OK on
* 32-bit since this will be used during debugging sessions for troubleshooting

View File

@ -67,8 +67,12 @@ static int cli_parse_set_profiling(char **args, char *payload, struct appctx *ap
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
return 1;
if (strcmp(args[2], "memory") == 0) {
return cli_err(appctx, "Memory profiling not compiled in.\n");
}
if (strcmp(args[2], "tasks") != 0)
return cli_err(appctx, "Expects 'tasks'.\n");
return cli_err(appctx, "Expects etiher 'tasks' or 'memory'.\n");
if (strcmp(args[3], "on") == 0) {
unsigned int old = profiling;
@ -146,8 +150,9 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
qsort(tmp_activity, 256, sizeof(tmp_activity[0]), cmp_sched_activity);
chunk_printf(&trash,
"Per-task CPU profiling : %s # set profiling tasks {on|auto|off}\n",
str);
"Per-task CPU profiling : %-8s # set profiling tasks {on|auto|off}\n"
"Memory usage profiling : %-8s # set profiling memory {on|off}\n",
str, (profiling & HA_PROF_MEMORY) ? "on" : "off");
chunk_appendf(&trash, "Tasks activity:\n"
" function calls cpu_tot cpu_avg lat_tot lat_avg\n");
@ -336,7 +341,7 @@ INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
static struct cli_kw_list cli_kws = {{ },{
{ { "show", "profiling", NULL }, "show profiling : show CPU profiling options", NULL, cli_io_handler_show_profiling, NULL },
{ { "show", "tasks", NULL }, "show tasks : show running tasks", NULL, cli_io_handler_show_tasks, NULL },
{ { "set", "profiling", NULL }, "set profiling : enable/disable CPU profiling", cli_parse_set_profiling, NULL },
{ { "set", "profiling", NULL }, "set profiling : enable/disable resource profiling", cli_parse_set_profiling, NULL },
{{},}
}};