From: Willy Tarreau Date: Thu, 21 Nov 2024 11:02:35 +0000 (+0100) Subject: MINOR: activity: interrupt the show profile dump more often X-Git-Tag: v3.1-dev14~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a8b834435863762ba4002e560b872ddb9056d58;p=thirdparty%2Fhaproxy.git MINOR: activity: interrupt the show profile dump more often The calls to resolv_sym_name() can be a bit expensive. Forcing to yield more often is better for the latency and will avoid the watchdog reporting warnings. Note that it's still called in the sort at the end, but that one cannot be avoided. At best we could try to rely on the list of libs but that's not trivial and not always present. --- diff --git a/src/activity.c b/src/activity.c index 67a43fa59e..72e58a0226 100644 --- a/src/activity.c +++ b/src/activity.c @@ -934,6 +934,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) const char *str; int max_lines; int i, j, max; + int dumped; chunk_reset(&trash); @@ -997,11 +998,17 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) if (!max_lines) max_lines = SCHED_ACT_HASH_BUCKETS; + dumped = 0; for (i = ctx->linenum; i < max_lines; i++) { if (!tmp_activity[i].calls) continue; // skip aggregated or empty entries ctx->linenum = i; + + /* resolve_sym_name() may be slow, better dump a few entries at a time */ + if (dumped >= 10) + return 0; + chunk_reset(name_buffer); caller = HA_ATOMIC_LOAD(&tmp_activity[i].caller); @@ -1034,6 +1041,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) /* failed, try again */ return 0; } + dumped++; } if (applet_putchk(appctx, &trash) == -1) { @@ -1069,12 +1077,18 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) if (!max_lines) max_lines = MEMPROF_HASH_BUCKETS + 1; + dumped = 0; for (i = ctx->linenum; i < max_lines; i++) { struct memprof_stats *entry = &tmp_memstats[i]; ctx->linenum = i; if (!entry->alloc_calls && !entry->free_calls) continue; + + /* resolve_sym_name() may be slow, better dump a few entries at a time */ + if (dumped >= 10) + return 0; + chunk_appendf(&trash, "%11llu %11llu %14llu %14llu| %16p ", entry->alloc_calls, entry->free_calls, entry->alloc_tot, entry->free_tot, @@ -1107,6 +1121,8 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) if (applet_putchk(appctx, &trash) == -1) return 0; + + dumped++; } if (applet_putchk(appctx, &trash) == -1)