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.
Thanks for adding the feature.
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?
Uses a const variable instead of a raw number.
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.
Sounds good! I'll move and rename it. Thank you for your suggestions.
Yeah, I'll change it. Thanks you!
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.
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.
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().
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.
Thanks for the heads up. We'll fix and resubmit later.
ColNum isn't modified in the function, no need to pass by reference.
ColumnOffset needs 4 slots too, otherwise dumpHotFunctionList will access out-of-bound. I think this is what's causing the asan failure.