This is an archive of the discontinued LLVM Phabricator instance.

Add --hot-func-list to llvm-profdata show for sample profiles
ClosedPublic

Authored by weihe on Jun 23 2020, 12:20 AM.

Details

Summary

Add the --hot-func-list feature to llvm-profdata show for sample profiles. This feature prints a list of hot functions whose max sample count are above the 99% threshold, with their numbers of total samples, total samples percentage, max samples, entry samples, and their function names.

Test Plan:

Diff Detail

Event Timeline

weihe created this revision.Jun 23 2020, 12:20 AM
weihe added subscribers: wenlei, hoyFB.
wenlei added inline comments.Jun 23 2020, 11:12 PM
llvm/tools/llvm-profdata/llvm-profdata.cpp
1059

Same, remove ColNum, then change to assert(ColumnOffset.size() == ColumnTitle.size());

1088–1099

I think we can just assume ColNum is ColumnOffset .size(), then remove the nested ifs.

1164

Why do we need ColNum as a parameter? We are always going to print ColumnTitle.size() columns, right? Can we simplify the code to remove ColNum parameter?

hoyFB added inline comments.Jun 23 2020, 11:40 PM
llvm/tools/llvm-profdata/llvm-profdata.cpp
1088–1099

yeah, or to loop on min(ColNum, ColumnOffset.size()) if ColNum can ever be greater than ColumnOffset.size(). When could that happen?

weihe updated this revision to Diff 273121.Jun 24 2020, 11:57 AM

Removed the ColNum parameter of dumpHotFunctionList()

Removed the ColNum parameter of dumpHotFunctionList() and added assertions to this function about size of ColumnTitle and ColumnOffset.

wenlei accepted this revision.Jun 24 2020, 12:05 PM

LGTM, thanks! l can re-commit the change on your behalf..

This revision is now accepted and ready to land.Jun 24 2020, 12:05 PM
hoyFB added inline comments.Jun 24 2020, 12:07 PM
llvm/tools/llvm-profdata/llvm-profdata.cpp
1076

Remove ColNum? like for (size_t I = 0; I < ColumnTitle.size(); ++I)?

weihe updated this revision to Diff 273128.Jun 24 2020, 12:37 PM

Removed temporary ColNum from a loop header

hoyFB accepted this revision.Jun 24 2020, 12:41 PM
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.
llvm/include/llvm/ProfileData/SampleProf.h
505

You have used many auto in this file. Please write the underlying type unless obvious.

Braces around simple statements can be dropped.

llvm/test/tools/llvm-profdata/sample-hot-func-list.test
2

Should use --match-full-lines --strict-whitespace

llvm/tools/llvm-profdata/llvm-profdata.cpp
1072

Please avoid trailing dot in informative diagnostics to be consistent with other tools (in coding standard now)