diff options
| author | Namhyung Kim <namhyung@kernel.org> | 2025-08-15 20:16:35 -0700 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2025-09-02 17:14:00 -0300 |
| commit | 1086237f0a91c7e70eede1bc83ce54f521db64b0 (patch) | |
| tree | 8333fe95570f9a70424808cb2a8836991034bfb8 /tools/perf/util/annotate.c | |
| parent | 53a61a6ca279165dd51f4e3bb5f8b11544915138 (diff) | |
perf annotate: Use a hashmap to save type data
It can slowdown annotation browser if objdump is processing large DWARF
data. Let's add a hashmap to save the data type info for each line.
Note that this is needed for TUI only because stdio only processes each
line once. TUI will display the same line whenever it refreshes the
screen.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250816031635.25318-13-namhyung@kernel.org
[ Add lines around an if block and use zfree() in one case, acked by Namhyung ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
| -rw-r--r-- | tools/perf/util/annotate.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index bea3457a0063..c9b220d9f924 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1954,11 +1954,17 @@ err: return -ENOMEM; } +struct type_hash_entry { + struct annotated_data_type *type; + int offset; +}; + static int disasm_line__snprint_type_info(struct disasm_line *dl, char *buf, int len, struct annotation_print_data *apd) { - struct annotated_data_type *data_type; + struct annotated_data_type *data_type = NULL; + struct type_hash_entry *entry = NULL; char member[256]; int offset = 0; int printed; @@ -1968,7 +1974,26 @@ static int disasm_line__snprint_type_info(struct disasm_line *dl, if (!annotate_opts.code_with_type || apd->dbg == NULL) return 1; - data_type = __hist_entry__get_data_type(apd->he, apd->arch, apd->dbg, dl, &offset); + if (apd->type_hash) { + hashmap__find(apd->type_hash, dl->al.offset, &entry); + if (entry != NULL) { + data_type = entry->type; + offset = entry->offset; + } + } + + if (data_type == NULL) + data_type = __hist_entry__get_data_type(apd->he, apd->arch, apd->dbg, dl, &offset); + + if (apd->type_hash && entry == NULL) { + entry = malloc(sizeof(*entry)); + if (entry != NULL) { + entry->type = data_type; + entry->offset = offset; + hashmap__add(apd->type_hash, dl->al.offset, entry); + } + } + if (!needs_type_info(data_type)) return 1; |
