lkml.org 
[lkml]   [2024]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 0/4] perf annotate: Improve memory usage for symbol histogram
On Tue, Feb 27, 2024 at 4:52 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> This is another series of memory optimization in perf annotate.
>
> When perf annotate (or perf report/top with TUI) processes samples, it
> needs to save the sample period (overhead) at instruction level. For
> now, it allocates an array to do that for the whole symbol when it
> hits any new symbol. This comes with a lot of waste since samples can
> be very few and instructions span to multiple bytes.
>
> For example, when a sample hits symbol 'foo' that has size of 100 and
> that's the only sample falls into the symbol. Then it needs to
> allocate a symbol histogram (sym_hist) and the its size would be
>
> 16 (header) + 16 (sym_hist_entry) * 100 (symbol_size) = 1616
>
> But actually it just needs 32 (header + sym_hist_entry) bytes. Things
> get worse if the symbol size is bigger (and it doesn't have many
> samples in different places). Also note that it needs separate
> histogram for each event.
>
> Let's split the sym_hist_entry and have it in a hash table so that it
> can allocate only necessary entries.
>
> No functional change intended.
>
> Thanks,
> Namhyung
>
>
> Namhyung Kim (4):
> perf annotate: Add a hashmap for symbol histogram
> perf annotate: Calculate instruction overhead using hashmap
> perf annotate: Remove sym_hist.addr[] array
> perf annotate: Add comments in the data structures

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> tools/perf/ui/gtk/annotate.c | 14 ++++-
> tools/perf/util/annotate.c | 114 ++++++++++++++++++++++-------------
> tools/perf/util/annotate.h | 86 +++++++++++++++++++++++---
> 3 files changed, 158 insertions(+), 56 deletions(-)
>
> --
> 2.44.0.rc1.240.g4c46232300-goog
>

\
 
 \ /
  Last update: 2024-05-27 15:25    [W:1.108 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site