From: Milian Wolff <milian.wolff@kdab.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
David Ahern <dsahern@gmail.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Yao Jin <yao.jin@linux.intel.com>
Subject: Re: [PATCH v2] perf report: distinguish between inliners in the same function
Date: Mon, 08 May 2017 10:45:18 +0200 [thread overview]
Message-ID: <11256670.HWKrRQARBr@agathebauer> (raw)
In-Reply-To: <20170503213536.13905-1-milian.wolff@kdab.com>
[-- Attachment #1: Type: text/plain, Size: 7764 bytes --]
On Mittwoch, 3. Mai 2017 23:35:36 CEST Milian Wolff wrote:
> When different functions get inlined into the same function, we
> want to show them individually in the reports. But when we group by
> function, we would aggregate all IPs and would only keep the first
> one in that function. E.g. for C++ code like the following:
>
> ~~~~~
> #include <cmath>
> #include <random>
> #include <iostream>
>
> using namespace std;
>
> int main()
> {
> uniform_real_distribution<double> uniform(-1E5, 1E5);
> default_random_engine engine;
> double s = 0;
> for (int i = 0; i < 10000000; ++i) {
> s += uniform(engine);
> }
> cout << "random sum: " << s << '\n';
> return 0;
> }
> ~~~~~
>
> Building it with `g++ -O2 -g` and recording some samples with
> `perf record --call-graph dwarf` yields for me:
>
> ~~~~~
> $ perf report --stdio --inline
> # Overhead Command Shared Object Symbol
> # ........ ......... ................. ................................
> #
> 99.40% 99.11% a.out a.out [.] main
>
> --99.11%--_start
> __libc_start_main
> main
> ...
> ~~~~~
>
> Note how no inlined frames are actually shown, because the first
> sample in main points to an IP that does not correspond to any
> inlined frames.
>
> With this patch applied, we instead get the following, much more
> meaningful, reports.
>
> ~~~~~
> $ perf report --stdio --inline --no-children
> # Overhead Command Shared Object Symbol
> # ........ ......... ................. ................................
> #
> 99.11% a.out a.out [.] main
>
> |--48.15%--main
> |
> | std::__detail::_Adaptor<std::linear_congruential_engi
> | ne<unsigned long, 16807ul, 0ul, 2147483647ul>,
> | double>::operator() (inline)
> | std::uniform_real_distribution<double>::operator()<s
> | td::linear_congruential_engine<unsigned long,
> | 16807ul, 0ul, 2147483647ul> > (inline)
> | std::uniform_real_distribution<double>::operator()<s
> | td::linear_congruential_engine<unsigned long,
> | 16807ul, 0ul, 2147483647ul> > (inline) main (inline)
> | __libc_start_main
> | _start
> |
> |--47.61%--main
> |
> | std::__detail::__mod<unsigned long, 2147483647ul,
> | 16807ul, 0ul> (inline)
> | std::linear_congruential_engine<unsigned long,
> | 16807ul, 0ul, 2147483647ul>::operator() (inline)
> | std::generate_canonical<double, 53ul,
> | std::linear_congruential_engine<unsigned long,
> | 16807ul, 0ul, 2147483647ul> > (inline)
> | std::__detail::_Adaptor<std::linear_congruential_eng
> | ine<unsigned long, 16807ul, 0ul, 2147483647ul>,
> | double>::operator() (inline)
> | std::uniform_real_distribution<double>::operator()<s
> | td::linear_congruential_engine<unsigned long,
> | 16807ul, 0ul, 2147483647ul> > (inline)
> | std::uniform_real_distribution<double>::operator()<s
> | td::linear_congruential_engine<unsigned long,
> | 16807ul, 0ul, 2147483647ul> > (inline) main (inline)
> | __libc_start_main
> | _start
>
> --3.35%--main
>
> std::uniform_real_distribution<double>::operator()<std::linear_congruential
> _engine<unsigned long, 16807ul, 0ul, 2147483647ul> > (inline) main (inline)
> __libc_start_main
> _start
> ...
>
> $ perf report --stdio --inline
> # Children Self Command Shared Object Symbol
> # ........ ........ ....... ...................
> ........................................................ #
> 99.40% 99.11% a.out a.out [.] main
>
> --99.11%--_start
> __libc_start_main
>
> |--70.51%--main
> |
> | main (inline)
> | std::uniform_real_distribution<double>::op
> | erator()<std::linear_congruential_engine<u
> | nsigned long, 16807ul, 0ul, 2147483647ul>
> | > (inline)
> | std::uniform_real_distribution<double>::o
> | perator()<std::linear_congruential_engine<
> | unsigned long, 16807ul, 0ul, 2147483647ul>
> | > (inline)
> | std::__detail::_Adaptor<std::linear_congr
> | uential_engine<unsigned long, 16807ul,
> | 0ul, 2147483647ul>, double>::operator()
> | (inline) |
> |--25.25%--main
> |
> | main (inline)
> | std::uniform_real_distribution<double>::op
> | erator()<std::linear_congruential_engine<u
> | nsigned long, 16807ul, 0ul, 2147483647ul>
> | > (inline)
> | std::uniform_real_distribution<double>::o
> | perator()<std::linear_congruential_engine<
> | unsigned long, 16807ul, 0ul, 2147483647ul>
> | > (inline)
> | std::__detail::_Adaptor<std::linear_congr
> | uential_engine<unsigned long, 16807ul,
> | 0ul, 2147483647ul>, double>::operator()
> | (inline) std::generate_canonical<double,
> | 53ul,
> | std::linear_congruential_engine<unsigned
> | long, 16807ul, 0ul, 2147483647ul> >
> | (inline)
> | std::linear_congruential_engine<unsigned
> | long, 16807ul, 0ul,
> | 2147483647ul>::operator() (inline)
> | std::__detail::__mod<unsigned long,
> | 2147483647ul, 16807ul, 0ul> (inline)
> --3.35%--main
> main (inline)
>
> std::uniform_real_distribution<double>::operator()<std::linear_congruential
> _engine<unsigned long, 16807ul, 0ul, 2147483647ul> > (inline) ~~~~~
>
> Note that the latter top-down call graphs require us to traverse the
> full inliner call chain when comparing for equality. Without it,
> we would potentially combine the three distinct branches again, since
> they share an equal first inline frame "main (inline)".
Ping? Any chance that I could get a review on this one please? It works really
well for me and greatly improves perf's usability for C++ code bases.
Thanks
--
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-08 8:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 21:35 [PATCH v2] perf report: distinguish between inliners in the same function Milian Wolff
2017-05-08 8:45 ` Milian Wolff [this message]
2017-05-08 16:17 ` Arnaldo Carvalho de Melo
2017-05-10 5:53 ` Namhyung Kim
2017-05-12 10:37 ` Milian Wolff
2017-05-12 13:01 ` Namhyung Kim
2017-05-14 18:10 ` Milian Wolff
2017-05-15 1:21 ` Namhyung Kim
2017-05-15 10:01 ` Milian Wolff
2017-05-16 0:53 ` Namhyung Kim
2017-05-16 13:18 ` Milian Wolff
2017-05-17 6:13 ` Namhyung Kim
2017-05-18 12:20 ` Milian Wolff
2017-05-12 14:55 ` Andi Kleen
2017-05-15 0:44 ` Namhyung Kim
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=11256670.HWKrRQARBr@agathebauer \
--to=milian.wolff@kdab.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=yao.jin@linux.intel.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 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).