This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profdata] Extend support of --topn to sample profiles
ClosedPublic

Authored by modimo on Sep 24 2021, 2:47 PM.

Diff Detail

Event Timeline

modimo created this revision.Sep 24 2021, 2:47 PM
modimo requested review of this revision.Sep 24 2021, 2:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 24 2021, 2:47 PM

hot-func-list of sample pgo is the equivalent of topn for instr pgo. Sample pgo diverged from instr pgo here in the sense we use hot-func-list to print a hot function list where "hot" is defined by the dyn-instr percentile based threshold. So simply adding topn might be confusing, as using topn alone for sample pgo won't print the hot function list, unlike instr pgo.

if you want to grow or trim the hot function list, you could use the threshold cutoff switches. Ideally we should unify the switches for both instr pgo and sample pgo.

llvm/tools/llvm-profdata/llvm-profdata.cpp
2352–2353

nit: TopN

hot-func-list of sample pgo is the equivalent of topn for instr pgo. Sample pgo diverged from instr pgo here in the sense we use hot-func-list to print a hot function list where "hot" is defined by the dyn-instr percentile based threshold. So simply adding topn might be confusing, as using topn alone for sample pgo won't print the hot function list, unlike instr pgo.

if you want to grow or trim the hot function list, you could use the threshold cutoff switches. Ideally we should unify the switches for both instr pgo and sample pgo.

My usage of topn was to be able to compare and analyze a fixed number of functions rather than defining different cut-off values to get similar effects across many different binaries. That being said, this was all running in a script so I could've also had the script do this pruning instead of llvm-profdata.

Unifying switches was the main reason I added this to prof-data, since topn being documented but being a complete no-op in sample profile threw me off.

hot-func-list of sample pgo is the equivalent of topn for instr pgo. Sample pgo diverged from instr pgo here in the sense we use hot-func-list to print a hot function list where "hot" is defined by the dyn-instr percentile based threshold. So simply adding topn might be confusing, as using topn alone for sample pgo won't print the hot function list, unlike instr pgo.

if you want to grow or trim the hot function list, you could use the threshold cutoff switches. Ideally we should unify the switches for both instr pgo and sample pgo.

My usage of topn was to be able to compare and analyze a fixed number of functions rather than defining different cut-off values to get similar effects across many different binaries. That being said, this was all running in a script so I could've also had the script do this pruning instead of llvm-profdata.

Unifying switches was the main reason I added this to prof-data, since topn being documented but being a complete no-op in sample profile threw me off.

topn alone would still not do anything with your change. perhaps when topn is on, the hot func list should be printed. llvm-profdata has many switches that are only applicable to either instr. pgo or sample pgo (showcs for ipgo, show-prof-sym-list for spgo, etc..)

llvm/tools/llvm-profdata/llvm-profdata.cpp
2453–2454

ShowHotFuncList || TopN would make it more consistent between instr pgo and sample pgo.

modimo updated this revision to Diff 374989.Sep 24 2021, 4:33 PM

Have topn also output the top function list.

wenlei accepted this revision.Sep 24 2021, 4:37 PM

lgtm with a nit, thanks.

llvm/test/tools/llvm-profdata/sample-topn.test
1

I think it's better to merge the tests into sample-hot-func-list.test. This is improving hot func list and the tests also use the same inputs.

This revision is now accepted and ready to land.Sep 24 2021, 4:37 PM
modimo updated this revision to Diff 374991.Sep 24 2021, 4:41 PM
modimo marked 2 inline comments as done.

Merge tests back into sample-hot-func-list.test

This revision was landed with ongoing or failed builds.Sep 24 2021, 4:42 PM
This revision was automatically updated to reflect the committed changes.