Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752534AbdF1QdN (ORCPT ); Wed, 28 Jun 2017 12:33:13 -0400 Received: from mail.kdab.com ([176.9.126.58]:54382 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbdF1Qcx (ORCPT ); Wed, 28 Jun 2017 12:32:53 -0400 From: Milian Wolff To: Taeung Song Cc: Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Adrian Hunter , Andi Kleen , David Ahern , Jin Yao , Jiri Olsa , Kim Phillips , Masami Hiramatsu , Namhyung Kim , Wang Nan Subject: Re: [PATCH/RFC 0/4] perf annotate: Add --source-only option and the new source code TUI view Date: Wed, 28 Jun 2017 18:32:49 +0200 Message-ID: <1850968.73fxbRD0Hc@milian-kdab2> Organization: KDAB In-Reply-To: References: <1498619888-1305-1-git-send-email-treeze.taeung@gmail.com> <1571575.U9nG2MaxHg@milian-kdab2> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1841987.W11tjQQGOH"; micalg="sha256"; protocol="application/pkcs7-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11092 Lines: 254 --nextPart1841987.W11tjQQGOH Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" On Wednesday, June 28, 2017 6:27:34 PM CEST Taeung Song wrote: > On 06/28/2017 06:53 PM, Milian Wolff wrote: > > On Wednesday, June 28, 2017 5:18:08 AM CEST Taeung Song wrote: > >> Hi, > >>=20 > >> The --source-only option and new source code TUI view can show > >> the result of performance analysis based on full source code per > >> symbol(function). (Namhyung Kim told me this idea and it was also > >> requested > >> by others some time ago..) > >>=20 > >> If someone wants to see the cause, he/she will need to dig into the as= m. > >> But before that, looking at the source level can give a hint or clue > >> for the problem. > >>=20 > >> For example, if target symbol is 'hex2u64' of util/util.c, > >> the output is like below. > >>=20 > >> $ perf annotate --source-only --stdio -s hex2u64 > >> =20 > >> Percent | Source code of util.c for cycles:ppp (42 samples) > >>=20 > >> ----------------------------------------------------------------- > >>=20 > >> 0.00 : 354 * While we find nice hex chars, build a long_val. > >> 0.00 : 355 * Return number of chars processed. > >> 0.00 : 356 */ > >> 0.00 : 357 int hex2u64(const char *ptr, u64 *long_val) > >> 2.38 : 358 { > >> 2.38 : 359 const char *p =3D ptr; > >> 0.00 : 360 *long_val =3D 0; > >> 0.00 : 361 > >> =20 > >> 30.95 : 362 while (*p) { > >> 23.81 : 363 const int hex_val =3D hex(*p); > >> =20 > >> 0.00 : 364 > >> =20 > >> 14.29 : 365 if (hex_val < 0) > >> =20 > >> 0.00 : 366 break; > >> 0.00 : 367 > >> =20 > >> 26.19 : 368 *long_val =3D (*long_val << 4) | hex_= val; > >> =20 > >> 0.00 : 369 p++; > >> 0.00 : 370 } > >> 0.00 : 371 > >> 0.00 : 372 return p - ptr; > >> 0.00 : 373 } > >>=20 > >> And I added many perf developers into Cc: because I want to listen to > >> your > >> opinions about this new feature, if you don't mind. > >>=20 > >> If you give some feedback, I'd appreciate it! :) > >=20 > > Thanks Taeung, > >=20 > > I requested this feature some time ago and it's really cool to see some= one > > step up and implement it - much appreciated! >=20 > Thank you so much, Milian !! :) >=20 > > I just tested it out on my pet-example that leverages C++ instead of C: > >=20 > > ~~~~~ > > #include > > #include > > #include > > #include > >=20 > > using namespace std; > >=20 > > int main() > > { > >=20 > > uniform_real_distribution uniform(-1E5, 1E5); > > default_random_engine engine; > > double s =3D 0; > > for (int i =3D 0; i < 10000000; ++i) { > > =20 > > s +=3D norm(complex(uniform(engine), uniform(engine))); > > =20 > > } > > cout << s << '\n'; > > return 0; > >=20 > > } > > ~~~~~ > >=20 > > Compile it with: > >=20 > > g++ -O2 -g -std=3Dc++11 test.cpp -o test > >=20 > > Then record it with perf: > >=20 > > perf record --call-graph dwarf ./test > >=20 > > Then analyse it with `perf report`. You'll see one entry for main with > > something like: > >=20 > > + 100.00% 39.69% cpp-inlining cpp-inlining [.] main > >=20 > > Select it and annotate it, then switch to your new source-only view: > >=20 > > main test.cpp > >=20 > > =E2=94=82 30 > > =E2=94=82 31 using namespace std; > > =E2=94=82 32 > > =E2=94=82 33 int main() > > =E2=94=82+ 34 { > > =E2=94=82 35 uniform_real_distribution uniform(= =2D1E5, 1E5); > > =E2=94=82 36 default_random_engine engine; > > =E2=94=82+ 37 double s =3D 0; > > =E2=94=82+ 38 for (int i =3D 0; i < 10000000; ++i) { > > =20 > > 4.88 =E2=94=82+ 39 s +=3D norm(complex(uniform(en= gine), > >=20 > > uniform(engine))); > >=20 > > =E2=94=82 40 } > > =E2=94=82 41 cout << s << '\n'; > > =E2=94=82 42 return 0; > > =E2=94=82+ 43 } > >=20 > > Note: the line numbers are off b/c my file contains a file-header on-to= p. > > Ignore that. > >=20 > > Note2: There is no column header shown, so it's unclear what the first > > column represents. > >=20 > > Note 3: report showed 39.69% self cost in main, 100.00% inclusive. > > annotate > > shows 4.88... What is that? > >=20 > > What this shows, is that it's extremely important to visualize inclusive > > cost _and_ self cost in this view. Additionally, we need to account for > > inlining. Right now, we only see the self cost that is directly within > > main, I suspect. For C++ this is usually very misleading, and basically > > makes the annotate view completely useless for application-level > > profiling. If a second column would be added with the inclusive cost wi= th > > the ability to drill down, then I could easily see myself using this > > view. > >=20 > > I would appreciate if you could take this into account. > >=20 > > Thanks a lot >=20 > Sure, I got it. > I'll investigate this weird case and recheck this patchset based on your > comments, > and then I'll reply again. :) Cool, I'm happy to test this. Note though that this is not really a "weird= =20 case" for a C++ developer. It's rather the norm of what we have to deal=20 with... Cheers =2D-=20 Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH&Co KG, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt Experts --nextPart1841987.W11tjQQGOH Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglgh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