This is an archive of the discontinued LLVM Phabricator instance.

[CSSPGO] Turn on priority inlining for probe-only profile
ClosedPublic

Authored by hoy on Apr 28 2022, 12:02 PM.

Details

Summary

We have seen that the prioirty inliner delivered on-par performance with the old inliner for probe-only CSSPGO profile, as long as without a size budget. I'm turning on the priority inliner for probe-only profile by default.

Diff Detail

Event Timeline

hoy created this revision.Apr 28 2022, 12:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 12:02 PM
hoy requested review of this revision.Apr 28 2022, 12:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 12:02 PM
wenlei added inline comments.Apr 28 2022, 4:29 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
2035–2038

Do we also need to clear ProfileInlineGrowthLimit here?

hoy added inline comments.Apr 28 2022, 4:58 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
2035–2038

That one is used as a multiplier. Giving it a large value may cause overflow, so not sure what is a good value to give.

unsigned SizeLimit = F.getInstructionCount() * ProfileInlineGrowthLimit;
SizeLimit = std::min(SizeLimit, (unsigned)ProfileInlineLimitMax);
SizeLimit = std::max(SizeLimit, (unsigned)ProfileInlineLimitMin);
wenlei added inline comments.Apr 28 2022, 9:54 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
2030

Actually when we use preinline decision should we also ignore size limits? We don't have to do it here, but perhaps something worth trying.

When preinliner is well tuned, I think size limit only makes sense if we have flat cs profile without preinline.

2035–2038

Ok, with that SizeLimit calculation, as long as we have ProfileInlineLimitMin as int max, the SizeLimit will be int max. We should be good then.

2043

Is it actually possible that FunctionSamples::ProfileIsCS is true but Reader->profileIsCS() is false?

hoy added inline comments.Apr 28 2022, 11:21 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
2030
2043

I don't think so. They are defined by same value in the reader:

https://github.com/llvm/llvm-project/blob/d3e5f0ab01c6b885082a1e12a7dfe5e55d340e52/llvm/lib/ProfileData/SampleProfReader.cpp#L367

https://github.com/llvm/llvm-project/blob/d3e5f0ab01c6b885082a1e12a7dfe5e55d340e52/llvm/lib/ProfileData/SampleProfReader.cpp#L657

Actually I think the ProfileIsCS field should be removed, and instead using FunctionSamples::ProfileIsCS everywhere. I can make a separate diff to clean this up.

wenlei added inline comments.Apr 28 2022, 11:29 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
2030

The code you linked (shouldInlineCandidate) is about how we evaluate a candidate, but when size limit is hit, we stop evaluating new candidate: https://github.com/llvm/llvm-project/blob/fc7573f29c79a4bbcfc0d6d001b7c7ae9f1344c7/llvm/lib/Transforms/IPO/SampleProfile.cpp#L1451

2043

If it's not possible, we can do

ProfileIsCS = true;

instead of

ProfileIsCS = Reader->profileIsCS();
hoy added inline comments.Apr 28 2022, 11:36 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
2030

Oh I see. Good point, yeah, the size limits should be ignored. I'll give it an evaluation.

2043

It should be possible. Let me make ProfileIsCS = true; for now.

hoy updated this revision to Diff 425979.Apr 28 2022, 11:37 PM

Updating D124632: [CSSPGO] Turn on priority inlining for probe-only profile

wenlei accepted this revision.Apr 28 2022, 11:40 PM

Let's evaluate ignoring size limit for preinline case; otherwise lgtm, thanks.

This revision is now accepted and ready to land.Apr 28 2022, 11:40 PM
This revision was landed with ongoing or failed builds.Apr 29 2022, 5:32 PM
This revision was automatically updated to reflect the committed changes.