From: Milian Wolff <milian.wolff@kdab.com>
To: Nan Xiao <xiaonan830818@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: Why the stack frame in perf.data isn't displayed in FlameGraph?
Date: Thu, 18 May 2017 09:32:54 +0200 [thread overview]
Message-ID: <9775568.X03CyG2sn6@agathebauer> (raw)
In-Reply-To: <CA+MhoaM8o2yap8mMVvJsbB2iwXtn05uh+0am5aACbFV50Oud_g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2696 bytes --]
On Donnerstag, 18. Mai 2017 06:09:55 CEST Nan Xiao wrote:
> Hi all,
>
> I am a newbie of using perf tools and FlameGraph. I write a simple
> test program which is rafacimentoed from this
> NTL(http://www.shoup.net/ntl/doc/tour-ex3.html) program:
>
> #include <NTL/ZZX.h>
>
> using namespace std;
> using namespace NTL;
>
> void inner(int i, ZZX& t, Vec<ZZX>& phi)
> {
> for (long j = 1; j <= i-1; j++)
> if (i % j == 0)
> t *= phi(j);
> }
>
> void outer(int i, Vec<ZZX>& phi)
> {
> ZZX t;
> t = 1;
> inner(i, t, phi);
> phi(i) = (ZZX(INIT_MONO, i) - 1)/t;
> cout << phi(i) << "\n";
> }
>
> int main()
> {
> Vec<ZZX> phi(INIT_SIZE, 100);
>
> for (long i = 1; i <= phi.length(); i++) {
> outer(i, phi);
> }
> }
>
> And compile it using following command:
>
> g++ -pthread test.cpp -lntl -lgmp
Frame pointers are missing, you probably want to use either
a) `g++ -fno-omit-frame-pointers` which may work if NTL is header-only
b) `g++ -g` to rely on dwarf debug information and then use `perf record --
call-graph dwarf`
In general, I suggest to always compile with `-O2 -g` when you want to
profile, otherwise you are missing a lot of compiler optimizations, and/or
cripple tools like perf that want to use debug information.
> I use "perf record -g ./a.out" to profile the program, but "perf
> report" can only show "main" and "outer", no "inner" function
> (https://github.com/NanXiao/images/blob/master/perf/perf.data):
>
> ......
> + 7.10% 0.00% a.out a.out [.] outer
> + 7.10% 0.00% a.out a.out [.] main
> ......
I bet that's because the "inner" function got inlined and frame pointers are
disabled (see above). Recompile with the command above, and then use `perf
record --call-graph dwarf`.
Also, to see inline frames, try to build perf from git (acme's perf/core) and
use `perf report --inline`.
> From the
> perf.svg(https://github.com/NanXiao/images/blob/master/perf/perf.svg),
> there is neither "outer" nor "inner" stack frames.
>
> Since there is "outer" in perf.data, why it can't display in
> FlameGraph? Another doubt is why perf.data doesn't contain "inner"
> stack frame?
If the above fixes it for report, try to apply "[PATCH] perf script: Add --
inline option" by Namhyung Kim. Then you can generate the flamegraph via
perf script --inline | stackcollapse-perf.pl | flamegraph.pl > out.svg
Which should also show the inline frames.
Cheers, hope that helps
--
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 --]
next prev parent reply other threads:[~2017-05-18 7:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 4:09 Why the stack frame in perf.data isn't displayed in FlameGraph? Nan Xiao
2017-05-18 7:32 ` Milian Wolff [this message]
2017-05-18 13:24 ` Nan Xiao
2017-05-18 19:01 ` Milian Wolff
2017-05-19 1:50 ` Nan Xiao
2017-05-23 9:32 ` Milian Wolff
2017-05-23 10:14 ` Nan Xiao
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=9775568.X03CyG2sn6@agathebauer \
--to=milian.wolff@kdab.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=xiaonan830818@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.