diff --git a/doc/management.txt b/doc/management.txt index bba88c0fd6..a16a86de72 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1917,12 +1917,15 @@ set maxconn global 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 Change the process-wide connection rate limit, which is set by the global diff --git a/include/haproxy/activity-t.h b/include/haproxy/activity-t.h index c1c16aaf87..02fd2f34e6 100644 --- a/include/haproxy/activity-t.h +++ b/include/haproxy/activity-t.h @@ -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 diff --git a/src/activity.c b/src/activity.c index 8ccff234bf..18dd6ae5ba 100644 --- a/src/activity.c +++ b/src/activity.c @@ -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 }, {{},} }};