From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v2 0/4] perf annotate: Improve memory usage for symbol histogram
Date: Mon, 4 Mar 2024 15:08:11 -0800 [thread overview]
Message-ID: <20240304230815.1440583-1-namhyung@kernel.org> (raw)
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(-)
--
2.44.0.rc1.240.g4c46232300-goog
next reply other threads:[~2024-03-04 23:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 23:08 Namhyung Kim [this message]
2024-03-04 23:08 ` [PATCH v2 1/4] perf annotate: Add a hashmap for symbol histogram Namhyung Kim
2024-03-04 23:08 ` [PATCH v2 2/4] perf annotate: Calculate instruction overhead using hashmap Namhyung Kim
2024-03-04 23:08 ` [PATCH v2 3/4] perf annotate: Remove sym_hist.addr[] array Namhyung Kim
2024-03-04 23:08 ` [PATCH v2 4/4] perf annotate: Add comments in the data structures Namhyung Kim
2024-03-06 18:26 ` [PATCH v2 0/4] perf annotate: Improve memory usage for symbol histogram Namhyung Kim
2024-03-06 20:19 ` Arnaldo Carvalho de Melo
2024-03-06 22:21 ` Arnaldo Carvalho de Melo
2024-03-07 4:20 ` Namhyung Kim
2024-03-07 21:48 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240304230815.1440583-1-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).