• Namhyung Kim's avatar
    perf callchain: Convert children list to rbtree · e369517c
    Namhyung Kim authored
    Current collapse stage has a scalability problem which can be reproduced
    easily with a parallel kernel build.
    
    This is because it needs to traverse every children of callchains
    linearly during the collapse/merge stage.
    
    Converting it to a rbtree reduced the overhead significantly.
    
    On my 400MB perf.data file which recorded with make -j32 kernel build:
    
      $ time perf --no-pager report --stdio > /dev/null
    
    before:
      real	6m22.073s
      user	6m18.683s
      sys	0m0.706s
    
    after:
      real	0m20.780s
      user	0m19.962s
      sys	0m0.689s
    
    During the perf report the overhead on append_chain_children went down
    from 96.69% to 18.16%:
    
      -  18.16%  perf  perf                [.] append_chain_children
         - append_chain_children
            - 77.48% append_chain_children
               + 69.79% merge_chain_branch
               - 22.96% append_chain_children
                  + 67.44% merge_chain_branch
                  + 30.15% append_chain_children
                  + 2.41% callchain_append
               + 7.25% callchain_append
            + 12.26% callchain_append
            + 10.22% merge_chain_branch
      +  11.58%  perf  perf                [.] dso__find_symbol
      +   8.02%  perf  perf                [.] sort__comm_cmp
      +   5.48%  perf  libc-2.17.so        [.] malloc_consolidate
    Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Link: http://lkml.kernel.org/r/1381468543-25334-2-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    e369517c
callchain.c 12.1 KB