vppinfra: display only the 1st 50 memory traces by default 96/38196/2
authorBenoît Ganne <bganne@cisco.com>
Wed, 8 Feb 2023 17:54:30 +0000 (18:54 +0100)
committerDamjan Marion <dmarion@0xa5.net>
Mon, 6 Mar 2023 14:11:07 +0000 (14:11 +0000)
When using memory traces it can take a long time to display all traces
bigger than 1k if there are lots of them, especially as we need to
resolve symbols.
It is better to display only the 1st 50 by default, unless verbose is
used.
Also fix the help string.

Type: improvement

Change-Id: I1e5e30209f10d2b05c561dbf856cb126e0cf513d
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vlib/cli.c
src/vppinfra/mem_dlmalloc.c

index 9c53200..5dd2598 100644 (file)
@@ -981,7 +981,7 @@ show_memory_usage (vlib_main_t * vm,
 VLIB_CLI_COMMAND (show_memory_usage_command, static) = {
   .path = "show memory",
   .short_help = "show memory [api-segment][stats-segment][verbose]\n"
-  "            [numa-heaps][map]",
+               "            [numa-heaps][map][main-heap]",
   .function = show_memory_usage,
 };
 /* *INDENT-ON* */
index 25014c8..59c7b7c 100644 (file)
@@ -355,6 +355,7 @@ format_mheap_trace (u8 * s, va_list * va)
   int verbose = va_arg (*va, int);
   int have_traces = 0;
   int i;
+  int n = 0;
 
   clib_spinlock_lock (&tm->lock);
   if (vec_len (tm->traces) > 0 &&
@@ -381,9 +382,10 @@ format_mheap_trace (u8 * s, va_list * va)
 
        total_objects_traced += t->n_allocations;
 
-       /* When not verbose only report allocations of more than 1k. */
-       if (!verbose && t->n_bytes < 1024)
+       /* When not verbose only report the 50 biggest allocations */
+       if (!verbose && n >= 50)
          continue;
+       n++;
 
        if (t == traces_copy)
          s = format (s, "%=9s%=9s %=10s Traceback\n", "Bytes", "Count",