perf symbols: Add front end cache for DSO symbol lookup
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 22 Jul 2015 15:52:17 +0000 (12:52 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 23 Jul 2015 14:28:35 +0000 (11:28 -0300)
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-voo94tow8wpkcc76mlkny6sc@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dso.h
tools/perf/util/symbol.c

index 2fe98bb0e95b0d4b88fb58f2fc28daee875a13bb..c73276db6d6f2de3fff7abe40c99ee0c6560d520 100644 (file)
@@ -137,6 +137,10 @@ struct dso {
        struct rb_node   rb_node;       /* rbtree node sorted by long name */
        struct rb_root   symbols[MAP__NR_TYPES];
        struct rb_root   symbol_names[MAP__NR_TYPES];
+       struct {
+               u64             addr;
+               struct symbol   *symbol;
+       } last_find_result[MAP__NR_TYPES];
        void             *a2l;
        char             *symsrc_filename;
        unsigned int     a2l_fails;
index 45c2e3a8316b2599bb0330afa349e0a5b52ae9a0..725640fd7cd80b88c6f2b17ae46fc77585cc1d33 100644 (file)
@@ -444,7 +444,12 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
 struct symbol *dso__find_symbol(struct dso *dso,
                                enum map_type type, u64 addr)
 {
-       return symbols__find(&dso->symbols[type], addr);
+       if (dso->last_find_result[type].addr != addr) {
+               dso->last_find_result[type].addr   = addr;
+               dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr);
+       }
+
+       return dso->last_find_result[type].symbol;
 }
 
 struct symbol *dso__first_symbol(struct dso *dso, enum map_type type)