linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Milian Wolff <milian.wolff@kdab.com>
To: linux-perf-users@vger.kernel.org
Subject: Improved backtraces with srcline in perf report
Date: Tue, 30 Aug 2016 15:02:24 +0200	[thread overview]
Message-ID: <5097362.aBWkQI5end@milian-kdab2> (raw)

[-- Attachment #1: Type: text/plain, Size: 4945 bytes --]

Hey all,

I would like to work on improving the usability of the way backtraces are 
reported by perf. See also my mail on that topic from a few weeks ago 
("usability issues with inlining and backtraces").

Status quo:

~~~~~~~~~~~~~~~~
perf report  --no-children -s dso,sym,srcline -g address --stdio
# Samples: 8K of event 'cycles:ppp'
# Event count (approx.): 8164367769
#
# Overhead  Shared Object               Symbol                                                              
Source:Line                                  
# ........  ..........................  
..................................................................  
.............................................
#
     7.82%  lab_mandelbrot              [.] main                                                            
mandelbrot.h:41
            |          
            |--2.84%--main mandelbrot.h:41
            |          __libc_start_main +241
            |          _start +4194346
            |          
            |--2.58%--main mandelbrot.h:41
            |          
             --2.01%--main mandelbrot.h:41
                       __libc_start_main +241
                       _start +4194346

     7.79%  libgcc_s.so.1               [.] __muldc3                                                        
libgcc2.c:1945
            |          
            |--3.93%--__muldc3 libgcc2.c:1945
            |          main mandelbrot.h:39
            |          __libc_start_main +241
            |          _start +4194346
            |          
             --3.72%--__muldc3 libgcc2.c:1945
                       main mandelbrot.h:39
                       __libc_start_main +241
                       _start +4194346
~~~~~~~~~~~~~~~~

Note: I have no idea why unwinding failed for the second main entry of 2.58% 
cost, but that is not topic of this email.

I would like to fix the following issues in descending priority. Please advise 
me whether these ideas are acceptable and, more importantly, where to 
implement them in the existing perf code base.

a) merge entries with equal labels

Most lines of code will contain multiple instructions. When translating them 
to srcline (-g address), the addresses will get mapped to the same labels. In 
the above case e.g. this distinction simply adds visual noise with no value at 
all. Instead, I'd like the report to show me:

~~~~~~~~~~~~~~~~
     7.82%  lab_mandelbrot              [.] main                                                            
mandelbrot.h:41
            |          
            |--4.85%--main mandelbrot.h:41
            |          __libc_start_main +241
            |          _start +4194346
            |          
            |--2.58%--main mandelbrot.h:41

     7.79%  libgcc_s.so.1               [.] __muldc3                                                        
libgcc2.c:1945
            |          
            |--7.79%--__muldc3 libgcc2.c:1945
            |          main mandelbrot.h:39
            |          __libc_start_main +241
            |          _start +4194346
~~~~~~~~~~~~~~~~

The merging of the entries must take backtraces into account, but must not 
merge based on the the ip/address of entries in the backtrace, but merge based 
on the symbol/label.

Especially for more complex applications, where the same code gets called from 
different functions (and we thus have different backtraces), this aggregation 
of costs will greatly simplify the analysis.

b) Add inliners

The above report is highly confusing, as a lot of code gets inlined and perf 
does not show the symbols of inlined functions. I.e. I'd like the report to 
show me:

~~~~~~~~~~~~~~~~
     7.82%  lab_mandelbrot              [.] drawMandelbrot                                                            
mandelbrot.h:41
            |          
            |--4.85%--drawMandelbrot mandelbrot.h:41
            |          main main.cpp:55
            |          __libc_start_main +241
            |          _start +4194346
            |          
            |--2.58%--drawMandelbrot mandelbrot.h:41
            |          main main.cpp:55

     7.79%  libgcc_s.so.1               [.] __muldc3                                                        
libgcc2.c:1945
            |          
            |--7.79%--__muldc3 libgcc2.c:1945
            |          std::complex<double>::operator*=<double> complex:1326
            |          main mandelbrot.h:39
            |          __libc_start_main +241
            |          _start +4194346
~~~~~~~~~~~~~~~~

The information for that exists in DWARF and can already be read out in perf 
using the `bfd_find_inliner_info` code in util/srcline.c:addr2line. 

Could someone please tell me what refactoring is required to make this work in 
perf? It seems to be non-trivial.

-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]

             reply	other threads:[~2016-08-30 13:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 13:02 Milian Wolff [this message]
2016-08-30 13:19 ` Improved backtraces with srcline in perf report Milian Wolff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5097362.aBWkQI5end@milian-kdab2 \
    --to=milian.wolff@kdab.com \
    --cc=linux-perf-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).