diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-02 08:50:42 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-02 15:28:28 -0400 |
| commit | b9fb93047756c5e4129dfda7591612de61b0e877 (patch) | |
| tree | 76e66aed31494cdf9f287011bbe1025f21910dac | |
| parent | 71cf8b8ff7d6a79af086be9e4c72628da9d62d58 (diff) | |
perf hist: Only allocate callchain_node if processing callchains
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: <new-submission>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/builtin-report.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 5 | ||||
| -rw-r--r-- | 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, | |||
| 110 | 110 | ||
| 111 | if (symbol_conf.use_callchain) { | 111 | if (symbol_conf.use_callchain) { |
| 112 | if (!hit) | 112 | if (!hit) |
| 113 | callchain_init(&he->callchain); | 113 | callchain_init(he->callchain); |
| 114 | err = append_chain(&he->callchain, data->callchain, syms); | 114 | err = append_chain(he->callchain, data->callchain, syms); |
| 115 | free(syms); | 115 | free(syms); |
| 116 | 116 | ||
| 117 | if (err) | 117 | 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, | |||
| 50 | p = &(*p)->rb_right; | 50 | p = &(*p)->rb_right; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | he = malloc(sizeof(*he)); | 53 | he = malloc(sizeof(*he) + (symbol_conf.use_callchain ? |
| 54 | sizeof(struct callchain_node) : 0)); | ||
| 54 | if (!he) | 55 | if (!he) |
| 55 | return NULL; | 56 | return NULL; |
| 56 | *he = entry; | 57 | *he = entry; |
| @@ -168,7 +169,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root, | |||
| 168 | struct hist_entry *iter; | 169 | struct hist_entry *iter; |
| 169 | 170 | ||
| 170 | if (symbol_conf.use_callchain) | 171 | if (symbol_conf.use_callchain) |
| 171 | callchain_param.sort(&he->sorted_chain, &he->callchain, | 172 | callchain_param.sort(&he->sorted_chain, he->callchain, |
| 172 | min_callchain_hits, &callchain_param); | 173 | min_callchain_hits, &callchain_param); |
| 173 | 174 | ||
| 174 | while (*p != NULL) { | 175 | 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 { | |||
| 49 | u64 ip; | 49 | u64 ip; |
| 50 | char level; | 50 | char level; |
| 51 | struct symbol *parent; | 51 | struct symbol *parent; |
| 52 | struct callchain_node callchain; | ||
| 53 | union { | 52 | union { |
| 54 | unsigned long position; | 53 | unsigned long position; |
| 55 | struct hist_entry *pair; | 54 | struct hist_entry *pair; |
| 56 | struct rb_root sorted_chain; | 55 | struct rb_root sorted_chain; |
| 57 | }; | 56 | }; |
| 57 | struct callchain_node callchain[0]; | ||
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | enum sort_type { | 60 | enum sort_type { |
