Skip to content

perf annotate: Improve memory usage for symbol histogram

Namhyung Kim linux-perf-users lkml 2 versions – Applied

Status from this message: Applied to perf-tools-next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 5 repliesApplied
  2. v14 patches 7 repliesSuperseded

Changes in v2 from the cover letter

* fix a bug when offset is bigger than 16 bits

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4perf annotate: Add a hashmap for symbol histogramtools/perf/util/annotate.c tools/perf/util/annotate.h+42 -20 replies
2/4perf annotate: Calculate instruction overhead using hashmaptools/perf/ui/gtk/annotate.c tools/perf/util/annotate.c tools/perf/util/annotate.h+52 -170 replies
3/4perf annotate: Remove sym_hist.addr[] arraytools/perf/util/annotate.c tools/perf/util/annotate.h+6 -340 replies
4/4perf annotate: Add comments in the data structurestools/perf/util/annotate.h+62 -70 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchIan RogersArnaldo Carvalho de Melo
SeriesR-b T-b
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] perf annotate: Improve memory usage for symbol histogram

Hello,

This is another series of memory optimization in perf annotate.

v2 changes:
* fix a bug when offset is bigger than 16 bits

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 a 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

 tools/perf/ui/gtk/annotate.c |  14 ++++-
 tools/perf/util/annotate.c   | 116 ++++++++++++++++++++++-------------
 tools/perf/util/annotate.h   |  86 +++++++++++++++++++++++---
 3 files changed, 159 insertions(+), 57 deletions(-)
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog