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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for adding the feature.
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
1032–1048 | Please make it a member function of FunctionSamples so it can be used elsewhere. The max count can either be in inlinee or in itself. Your comment explicitly says that and it is good. Just the name getInlineeMaxCount is a little misleading. Perhaps use another name like getMaxCountInside? | |
1058 | Uses a const variable instead of a raw number. | |
1092–1127 | Can you wrap the output part in a function? I feel it can be useful as well for Instr profile. It is also better to be flexible about which metric is used to decide whether the function is hot (currently it is MaxCount). That could be different between PGO and SampleFDO. |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
1032–1048 | Sounds good! I'll move and rename it. Thank you for your suggestions. | |
1058 | Yeah, I'll change it. Thanks you! | |
1092–1127 | Thank you for the suggestions! I would like to ask the following questions to make sure I understand them correctly: For wrapping the output part into a function, is this function supposed to be reusable for other output format or only for the current format? For making the metric flexible, is the purpose to make the showHotFunctionList() reusable for PGO? I'm asking this question because this function is currently coupled with FunctionSample objects and interfaces that may not work with other types of profiles. Thanks! |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
1092–1127 | It is to make the output part usable for PGO profile. I see that showHotFunctionList is coupled with FunctionSample, but after you decide which functions to output based on Function Sample, the output content and format are independent from profile kind and can be shared with PGO. |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
1092–1127 | Thank you for the clarification! I'm working on it now. |
Moved getInlineeMaxCount() to be FunctionSamples' member and wrapped printing code into a separate function.
The original static function getInlineeMaxCount() has been moved to be FunctionSamples::getMaxCountInside(). The output code in the original showHotFunctionList() has been wrapped into a separate function dumpHotFunctionList().
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
1092–1127 | Hello, I moved the output code into a function dumpHotFunctionList() in the current revision. I tried to make it more flexible by allowing callers to determine column titles and column offsets. But the attributes to print out is still hard-coded in this function. There needs to be some changes if PGO would like to reuse this code. Please let me know if you have any suggestions. |
This is causing an Asan failure (see for example: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/17880).
I have reverted it for now. Thanks!
Thanks for the heads up. We'll fix and resubmit later.
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
1054 | ColNum isn't modified in the function, no need to pass by reference. | |
1141 | ColumnOffset needs 4 slots too, otherwise dumpHotFunctionList will access out-of-bound. I think this is what's causing the asan failure. |
Please make it a member function of FunctionSamples so it can be used elsewhere.
The max count can either be in inlinee or in itself. Your comment explicitly says that and it is good. Just the name getInlineeMaxCount is a little misleading. Perhaps use another name like getMaxCountInside?