diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2025-04-12 11:27:38 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2025-04-12 11:27:38 -0700 |
commit | 08bebefed6fbc7f04f07ddae6aaab0c513c8061f (patch) | |
tree | ae2bc0dc27a27bc5b354a8b8754104226cd58186 /src/charts.c | |
parent | b0eba82135bae9a28d7a916c4f54fd43a86f7159 (diff) |
charts: include threads count in tree/argv column
This adds a [$n_current_threads] prefix to the argv/~threadname
part of the tree column, for non-stale processes.
It's suppressed for stale processes because we don't actually
have a meaningful count to render at that point; it'd always be
zero. This would be visible as an oddity in the snowflakes.
The count is also suppressed for non-threaded processes, leaving
a bare "[]", which may change again in the future. It seems like
noise in the chart, but it also serves to prevent an argv somehow
starting with "[N]" being ambiguous - perhaps not something worth
caring about *shrug*.
Diffstat (limited to 'src/charts.c')
-rw-r--r-- | src/charts.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/charts.c b/src/charts.c index 0126b59..33ba014 100644 --- a/src/charts.c +++ b/src/charts.c @@ -302,7 +302,8 @@ static void allocate_row(vwm_charts_t *charts, vwm_chart_t *chart, int row) /* simple helper to map the vmon per-proc argv array into an XTextItem array, deals with threads vs. processes and the possibility of the comm field not getting read in before the process exited... */ static void proc_argv2strs(const vmon_proc_t *proc, vcr_str_t *strs, int max_strs, int *res_n_strs) { - int nr = 0; + static char n_threads_str[sizeof(STRINGIFY(UINT_MAX)) + sizeof("[]")]; + int nr = 0; assert(proc); assert(strs); @@ -313,6 +314,13 @@ static void proc_argv2strs(const vmon_proc_t *proc, vcr_str_t *strs, int max_str strs[0].str = CHART_ISTHREAD_ARGV; strs[0].len = sizeof(CHART_ISTHREAD_ARGV) - 1; nr++; + } else if (!proc->is_stale) { + strs[0].str = n_threads_str; + if (proc->is_threaded) + strs[0].len = snprintf(n_threads_str, sizeof(n_threads_str), "[%u]", proc->n_current_threads); + else + strs[0].len = snprintf(n_threads_str, sizeof(n_threads_str), "[]"); + nr++; } if (((vmon_proc_stat_t *)proc->stores[VMON_STORE_PROC_STAT])->comm.len) { @@ -682,7 +690,7 @@ static void draw_columns(vwm_charts_t *charts, vwm_chart_t *chart, vwm_column_t case VWM_COLUMN_PROC_ARGV: { /* print the process' argv */ if (heading) { - str_len = snpf(str, sizeof(str), "ArgV/~ThreadName"); + str_len = snpf(str, sizeof(str), "[NThreads] ArgV/~ThreadName"); str_justify = VWM_JUSTIFY_LEFT; } else { int width; |