llvm-project/llvm/tools/llvm-profgen
Hongtao Yu a4190037fa [CSSPGO][Preinliner] Use linear threshold to drive inline decision.
The per-callsite size threshold used today to drive preinline decision is based on hotness/coldness cutoff. The default setup is for callsites with a sample count above the hotness cutoff (99%), a 1500 size threshold is used. Any callsite below 99.99% coldness cutoff uses a zero threshold. This has a couple issues:

1. While both cutoffs and size thoresholds are configurable, different applications may need different setups, making a universal setup impractical.

2. The callsites between hotness cutoff and coldness cutoff are not considered as inline candidates, which could be a missing opportunity.

3. Hot callsites always use the same threshold. In reality we may want a bigger threshold for hotter callsites.

In this change we are introducing a linear threshold regardless of hot/cold cutoffs. Given a sample space, a threshold is computed for a callsite based on the position of that callsite sample in the whole space. With that we no longer need to define what's hot or cold. Callsites with different hotness will get a different threshold. This should overcome the above three issues.

I have seen good results with a universal default setup for two of our internal services.

For one service, 0.2% to 0.5% perf improvement over a baseline with a previous default setup, on-par code size.
For the second service, 0.5% to 0.8% perf improvement over a baseline with a previous default setup, 0.2% code size increase; on-par performance and code size with a baseline that is with a carefully tuned cutoff to cover enough hot functions.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D125023
2022-05-08 22:07:58 -07:00
..
CMakeLists.txt [llvm-profgen] Switch to DWARF-based symbol and ranges 2021-10-29 09:59:12 -07:00
CSPreInliner.cpp [CSSPGO][Preinliner] Use linear threshold to drive inline decision. 2022-05-08 22:07:58 -07:00
CSPreInliner.h [CSSPGO][Preinliner] Use linear threshold to drive inline decision. 2022-05-08 22:07:58 -07:00
CallContext.h [CSSPGO] Rename the field of SampleContextFrame 2021-10-04 19:06:59 -07:00
ErrorHandling.h [llvm-profgen] Fix bug of setting function entry 2021-11-12 12:18:43 -08:00
PerfReader.cpp [CSSPGO] Rename ProfileIsCSNested and ProfileIsCSFlat 2022-04-29 17:03:52 -07:00
PerfReader.h [CSSPGO] Rename ProfileIsCSNested and ProfileIsCSFlat 2022-04-29 17:03:52 -07:00
ProfileGenerator.cpp [CSSPGO][Preinliner] Use linear threshold to drive inline decision. 2022-05-08 22:07:58 -07:00
ProfileGenerator.h [CSSPGO][Preinliner] Use linear threshold to drive inline decision. 2022-05-08 22:07:58 -07:00
ProfiledBinary.cpp [llvm-profgen] Decouple artificial branch from LBR parser and fix external address related issues 2022-04-28 16:07:28 -07:00
ProfiledBinary.h [llvm-profgen] Decoding pseudo probe for profiled function only. 2022-03-23 14:15:11 -07:00
llvm-profgen.cpp [CSSPGO] Rename ProfileIsCSNested and ProfileIsCSFlat 2022-04-29 17:03:52 -07:00