This is an archive of the discontinued LLVM Phabricator instance.

[CSSPGO] Use merged base profile for hot threshold calculation
ClosedPublic

Authored by wenlei on Feb 3 2021, 2:58 PM.

Details

Summary

Context-sensitive profile effectively split a function profile into many copies each representing the CFG profile of a particular calling context. That makes the count distribution looks more flat as we now have more function profiles each with lower counts, which in turn leads to lower hot thresholds. Now we tells threshold computation to merge context profile first before calculating percentile based cutoffs to compensate for seemingly flat context profile. This can be controlled by swtich sample-profile-contextless-threshold.

Earlier measurement showed ~0.4% perf boost with this tuning on spec2k6 for CSSPGO (with pseudo-probe and new inliner).

Diff Detail

Event Timeline

wenlei created this revision.Feb 3 2021, 2:58 PM
wenlei requested review of this revision.Feb 3 2021, 2:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 2:58 PM
wmi added a comment.Feb 5 2021, 9:59 AM

For debug info based CSSPGO, I assume the threshold should be the same, correct?

llvm/lib/ProfileData/SampleProfWriter.cpp
766

ProfileMap --> *ProfilesToUse here?

Actually the computeSummary in the Reader and the Writer are mostly the same. It is better to extract them and make it a shared function somewhere, for example in SampleProfileBuilder.

In D95980#2545546, @wmi wrote:

For debug info based CSSPGO, I assume the threshold should be the same, correct?

Yes, this applies to both. In fact the issue was originally uncovered by experimenting with debug info based CSSPGO.

llvm/lib/ProfileData/SampleProfWriter.cpp
766

Good catch, thanks! I moved everything into ProfileSummaryBuilder, including the switch.

wenlei updated this revision to Diff 321850.Feb 5 2021, 12:30 PM

Address Wei's comment, rebase.

wmi accepted this revision.Feb 5 2021, 3:02 PM

LGTM.

This revision is now accepted and ready to land.Feb 5 2021, 3:02 PM
This revision was landed with ongoing or failed builds.Feb 5 2021, 5:59 PM
This revision was automatically updated to reflect the committed changes.