]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
perf hist: Only allocate callchain_node if processing callchains
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 2 Apr 2010 12:50:42 +0000 (09:50 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 2 Apr 2010 19:28:28 +0000 (16:28 -0300)
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>
tools/perf/builtin-report.c
tools/perf/util/hist.c
tools/perf/util/sort.h

index 381918515a5c555dee83131ebb26040d77e6a5f4..1fb13e5fd1f9119b1242c74a2895ecfd2cc47c90 100644 (file)
@@ -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)
index f0794913d575347ceb39b1fd80ccf1b8cd2e4476..18cf8b3216088bd01c8debdc82241f66f47c56f4 100644 (file)
@@ -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) {
index 439ec5fa0f5f94fa542f5d0f0dcb4343554c59ba..5bf2b744e7b26d923c0568f319f33def3fe75f48 100644 (file)
@@ -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 {