Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751520AbdF1Jxd (ORCPT ); Wed, 28 Jun 2017 05:53:33 -0400 Received: from mail.kdab.com ([176.9.126.58]:44828 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751498AbdF1Jx0 (ORCPT ); Wed, 28 Jun 2017 05:53:26 -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 11:53:22 +0200 Message-ID: <1571575.U9nG2MaxHg@milian-kdab2> Organization: KDAB In-Reply-To: <1498619888-1305-1-git-send-email-treeze.taeung@gmail.com> References: <1498619888-1305-1-git-send-email-treeze.taeung@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart10793721.1pC3Hq5r17"; 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: 12255 Lines: 247 --nextPart10793721.1pC3Hq5r17 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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 request= ed > by others some time ago..) >=20 > If someone wants to see the cause, he/she will need to dig into the asm. > 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 > Percent | Source code of util.c for cycles:ppp (42 samples) > ----------------------------------------------------------------- > 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 > 30.95 : 362 while (*p) { > 23.81 : 363 const int hex_val =3D hex(*p); > 0.00 : 364 > 14.29 : 365 if (hex_val < 0) > 0.00 : 366 break; > 0.00 : 367 > 26.19 : 368 *long_val =3D (*long_val << 4) | hex_val; > 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! :) Thanks Taeung, I requested this feature some time ago and it's really cool to see someone= =20 step up and implement it - much appreciated! I just tested it out on my pet-example that leverages C++ instead of C: ~~~~~ #include #include #include #include using namespace std; int main() { uniform_real_distribution uniform(-1E5, 1E5); default_random_engine engine; double s =3D 0; for (int i =3D 0; i < 10000000; ++i) { s +=3D norm(complex(uniform(engine), uniform(engine))); } cout << s << '\n'; return 0; } ~~~~~ Compile it with: g++ -O2 -g -std=3Dc++11 test.cpp -o test Then record it with perf: perf record --call-graph dwarf ./test Then analyse it with `perf report`. You'll see one entry for main with=20 something like: + 100.00% 39.69% cpp-inlining cpp-inlining [.] main Select it and annotate it, then switch to your new source-only view: main test.cpp =E2=94=82 30 = = =20 =E2=94=82 31 using namespace std; = = =20 =E2=94=82 32 = = =20 =E2=94=82 33 int main() = = =20 =E2=94=82+ 34 { = = =20 =E2=94=82 35 uniform_real_distribution uniform(-1E5,= 1E5); = =20 =E2=94=82 36 default_random_engine engine; = = =20 =E2=94=82+ 37 double s =3D 0; = = =20 =E2=94=82+ 38 for (int i =3D 0; i < 10000000; ++i) { = = =20 4.88 =E2=94=82+ 39 s +=3D norm(complex(uniform(engine)= ,=20 uniform(engine))); = =20 =E2=94=82 40 } = = =20 =E2=94=82 41 cout << s << '\n'; = = =20 =E2=94=82 42 return 0; = = =20 =E2=94=82+ 43 }=20 Note: the line numbers are off b/c my file contains a file-header on-top.=20 Ignore that. Note2: There is no column header shown, so it's unclear what the first colu= mn=20 represents. Note 3: report showed 39.69% self cost in main, 100.00% inclusive. annotate= =20 shows 4.88... What is that? What this shows, is that it's extremely important to visualize inclusive co= st=20 _and_ self cost in this view. Additionally, we need to account for inlining= =2E=20 Right now, we only see the self cost that is directly within main, I suspec= t.=20 =46or C++ this is usually very misleading, and basically makes the annotate= view=20 completely useless for application-level profiling. If a second column woul= d=20 be added with the inclusive cost with the ability to drill down, then I cou= ld=20 easily see myself using this view. I would appreciate if you could take this into account. Thanks a lot =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 --nextPart10793721.1pC3Hq5r17 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCDEIw ggXmMIIDzqADAgECAhBqm+E4O/8ra58B1dm4p1JWMA0GCSqGSIb3DQEBDAUAMIGFMQswCQYDVQQG EwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYD VQQKExFDT01PRE8gQ0EgTGltaXRlZDErMCkGA1UEAxMiQ09NT0RPIFJTQSBDZXJ0aWZpY2F0aW9u IEF1dGhvcml0eTAeFw0xMzAxMTAwMDAwMDBaFw0yODAxMDkyMzU5NTlaMIGXMQswCQYDVQQGEwJH QjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQK ExFDT01PRE8gQ0EgTGltaXRlZDE9MDsGA1UEAxM0Q09NT0RPIFJTQSBDbGllbnQgQXV0aGVudGlj YX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