From b9fb93047756c5e4129dfda7591612de61b0e877 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 2 Apr 2010 09:50:42 -0300 Subject: [PATCH] perf hist: Only allocate callchain_node if processing callchains MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The struct callchain_node size is 120 bytes, that are never used when there are no callchains or '-g none' is specified, so conditionally allocate it, reducing sizeof(struct hist_entry) from 210 bytes to only 96, greatly speeding the non-callchain processing. LKML-Reference: Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Paul Mackerras Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-report.c | 4 ++-- tools/perf/util/hist.c | 5 +++-- tools/perf/util/sort.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 381918515a5c..1fb13e5fd1f9 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -110,8 +110,8 @@ static int perf_session__add_hist_entry(struct perf_session *self, if (symbol_conf.use_callchain) { if (!hit) - callchain_init(&he->callchain); - err = append_chain(&he->callchain, data->callchain, syms); + callchain_init(he->callchain); + err = append_chain(he->callchain, data->callchain, syms); free(syms); if (err) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f0794913d575..18cf8b321608 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -50,7 +50,8 @@ struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists, p = &(*p)->rb_right; } - he = malloc(sizeof(*he)); + he = malloc(sizeof(*he) + (symbol_conf.use_callchain ? + sizeof(struct callchain_node) : 0)); if (!he) return NULL; *he = entry; @@ -168,7 +169,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root, struct hist_entry *iter; if (symbol_conf.use_callchain) - callchain_param.sort(&he->sorted_chain, &he->callchain, + callchain_param.sort(&he->sorted_chain, he->callchain, min_callchain_hits, &callchain_param); while (*p != NULL) { diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 439ec5fa0f5f..5bf2b744e7b2 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -49,12 +49,12 @@ struct hist_entry { u64 ip; char level; struct symbol *parent; - struct callchain_node callchain; union { unsigned long position; struct hist_entry *pair; struct rb_root sorted_chain; }; + struct callchain_node callchain[0]; }; enum sort_type { -- 2.39.5