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 > #include > #include > > using namespace std; > > int main() > { > uniform_real_distribution 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 | ne, > | double>::operator() (inline) > | std::uniform_real_distribution::operator() | td::linear_congruential_engine | 16807ul, 0ul, 2147483647ul> > (inline) > | std::uniform_real_distribution::operator() | td::linear_congruential_engine | 16807ul, 0ul, 2147483647ul> > (inline) main (inline) > | __libc_start_main > | _start > | > |--47.61%--main > | > | std::__detail::__mod | 16807ul, 0ul> (inline) > | std::linear_congruential_engine | 16807ul, 0ul, 2147483647ul>::operator() (inline) > | std::generate_canonical | std::linear_congruential_engine | 16807ul, 0ul, 2147483647ul> > (inline) > | std::__detail::_Adaptor | ine, > | double>::operator() (inline) > | std::uniform_real_distribution::operator() | td::linear_congruential_engine | 16807ul, 0ul, 2147483647ul> > (inline) > | std::uniform_real_distribution::operator() | td::linear_congruential_engine | 16807ul, 0ul, 2147483647ul> > (inline) main (inline) > | __libc_start_main > | _start > > --3.35%--main > > std::uniform_real_distribution::operator() _engine > (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::op > | erator() | nsigned long, 16807ul, 0ul, 2147483647ul> > | > (inline) > | std::uniform_real_distribution::o > | perator() | unsigned long, 16807ul, 0ul, 2147483647ul> > | > (inline) > | std::__detail::_Adaptor | uential_engine | 0ul, 2147483647ul>, double>::operator() > | (inline) | > |--25.25%--main > | > | main (inline) > | std::uniform_real_distribution::op > | erator() | nsigned long, 16807ul, 0ul, 2147483647ul> > | > (inline) > | std::uniform_real_distribution::o > | perator() | unsigned long, 16807ul, 0ul, 2147483647ul> > | > (inline) > | std::__detail::_Adaptor | uential_engine | 0ul, 2147483647ul>, double>::operator() > | (inline) std::generate_canonical | 53ul, > | std::linear_congruential_engine | long, 16807ul, 0ul, 2147483647ul> > > | (inline) > | std::linear_congruential_engine | long, 16807ul, 0ul, > | 2147483647ul>::operator() (inline) > | std::__detail::__mod | 2147483647ul, 16807ul, 0ul> (inline) > --3.35%--main > main (inline) > > std::uniform_real_distribution::operator() _engine > (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