AutoFDO/CSSPGO often has to deal with stale profiles collected on binaries built from several revisions behind release. It’s likely to get incorrect profile annotations using the stale profile, which results in unstable or low performing binaries. Currently for source location based profile, once a code change causes a profile mismatch, all the locations afterward are mismatched, the affected samples or inlining info are lost. If we can provide a matching framework to reuse parts of the mismatched profile - aka incremental PGO, it will make PGO more stable, also increase the optimization coverage and boost the performance of binary.
This patch is the part 1 of stale profile matching, summary of the implementation:
- Added a structure for the matching result:LocToLocMap, which is a location to location map meaning the location of current build is matched to the location of the previous build(to be used to query the “stale” profile).
- In order to use the matching results for sample query, we need to pass them to all the location queries. For code cleanliness, we added a new pointer field(IRToProfileLocationMap) to FunctionSamples.
- Added a wrapper(mapIRLocToProfileLoc) for the query to the location, the location from input IR will be remapped to the matched profile location.
- Added a new switch --salvage-stale-profile.
- Some refactoring for the staleness detection.
Test case is in part 2 with the matching algorithm.
similarly, mapIRLocToProfileLoc?