This is an archive of the discontinued LLVM Phabricator instance.

[CSSPGO] Fix issues with post-link function checksum check
Changes PlannedPublic

Authored by wlei on Jul 31 2023, 9:47 AM.

Details

Reviewers
hoy
wenlei
Summary

Previously we used profileIsValid to check if the function checksum is mismatched in profile matching, however I recently found profileIsValid also returns false if the function doesn't have pseudo probe desc, which doesn't match the original intention.
This tried to fix it by checking the checksum directly. Note that it could cause two changes in thin-lto pipeline that might affect the perf or even regress the perf , those are just by-design and non-trivial to fix here, so I sent this first, we can fix them in different patches depending on more perf measurements.

  • Imported functions don't have the probe desc, now they will be blocked for stale profile matching.
  • During profile annotation, imported functions are blocked to reload/overwrite the profile.

Diff Detail

Event Timeline

wlei created this revision.Jul 31 2023, 9:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 9:47 AM
wlei requested review of this revision.Jul 31 2023, 9:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 9:47 AM
wlei edited the summary of this revision. (Show Details)Jul 31 2023, 10:54 AM
wlei added reviewers: hoy, wenlei.
hoy added a comment.Aug 1 2023, 8:40 AM

How does perf look like after disabling annotating imported functions?

llvm/lib/Transforms/IPO/SampleProfile.cpp
1825

nit: external -> imported

2279

Can we assert FuncDesc to be non-null here?

wlei updated this revision to Diff 546974.Aug 3 2023, 12:34 PM

Updating D156715: [CSSPGO] Fix issues with post-link function checksum check

wlei added a comment.Aug 3 2023, 12:34 PM

How does perf look like after disabling annotating imported functions?

So far from what I tested, there is no perf change if only disabling annotating imported functions. Note that this also disables the profile matching for the imported functions, so it could cause perf issue, depending on if the imported functions is stale.

llvm/lib/Transforms/IPO/SampleProfile.cpp
2279

As I said in other comments, FuncDesc can be null for imported functions, this patch disables the matching for them, we need a new patch to cover this.

hoy added a comment.Aug 4 2023, 2:45 PM

How does perf look like after disabling annotating imported functions?

So far from what I tested, there is no perf change if only disabling annotating imported functions. Note that this also disables the profile matching for the imported functions, so it could cause perf issue, depending on if the imported functions is stale.

Discussed offline. This effect of this change is potentially two-fold :

  1. positive impact of disabling unnecessary matching for non-stale profiles
  2. negative impact of disabling matching for to-be-inlined imported functions with a stale profile.

Currently they are not tested separately. With a solution of #1, allowing matching for #2 might be a win. Suggesting to hold on this change until we have a good solution for #1.

Thoughts?

wlei planned changes to this revision.Aug 4 2023, 2:53 PM

How does perf look like after disabling annotating imported functions?

So far from what I tested, there is no perf change if only disabling annotating imported functions. Note that this also disables the profile matching for the imported functions, so it could cause perf issue, depending on if the imported functions is stale.

Discussed offline. This effect of this change is potentially two-fold :

  1. positive impact of disabling unnecessary matching for non-stale profiles
  2. negative impact of disabling matching for to-be-inlined imported functions with a stale profile.

Currently they are not tested separately. With a solution of #1, allowing matching for #2 might be a win. Suggesting to hold on this change until we have a good solution for #1.

Thoughts?

Yeah, as we discussed offline, sounds good to hold on this, will work on a proper solution for #1 or #2 (alternatively we can pass the metadata or a mismatch flag for the imported function)

How does perf look like after disabling annotating imported functions?

So far from what I tested, there is no perf change if only disabling annotating imported functions. Note that this also disables the profile matching for the imported functions, so it could cause perf issue, depending on if the imported functions is stale.

Discussed offline. This effect of this change is potentially two-fold :

  1. positive impact of disabling unnecessary matching for non-stale profiles
  2. negative impact of disabling matching for to-be-inlined imported functions with a stale profile.

Currently they are not tested separately. With a solution of #1, allowing matching for #2 might be a win. Suggesting to hold on this change until we have a good solution for #1.

Thoughts?

Yeah, as we discussed offline, sounds good to hold on this, will work on a proper solution for #1 or #2 (alternatively we can pass the metadata or a mismatch flag for the imported function)

Sounds reasonable. Hope we can make progress on #1.