@@ -240,17 +240,15 @@ static cl::opt<unsigned> ChecksumMismatchFuncHotBlockSkip(
240
240
" whose num of hot(on average) blocks is smaller than the "
241
241
" given number." ));
242
242
243
- static cl::opt<unsigned > ChecksumMismatchNumFuncSkip (
244
- " checksum-mismatch-num-func-skip " , cl::Hidden, cl::init(50 ),
245
- cl::desc(" For checksum-mismatch error check, skip the check if the total "
246
- " number of selected function is smaller than the given number." ));
243
+ static cl::opt<unsigned > MinfuncsForStalenessError (
244
+ " min-functions-for-staleness-error " , cl::Hidden, cl::init(50 ),
245
+ cl::desc(" Skip the check if the number of hot functions is smaller than "
246
+ " the given number." ));
247
247
248
- static cl::opt<unsigned > ChecksumMismatchErrorThreshold (
249
- " checksum-mismatch-error-threshold" , cl::Hidden, cl::init(80 ),
250
- cl::desc(
251
- " For checksum-mismatch error check, error out if the percentage of "
252
- " function mismatched-checksum is higher than the given percentage "
253
- " threshold" ));
248
+ static cl::opt<unsigned > PrecentMismatchForStalenessError (
249
+ " precent-mismatch-for-staleness-error" , cl::Hidden, cl::init(80 ),
250
+ cl::desc(" Reject the profile if the mismatch percent is higher than the "
251
+ " given number" ));
254
252
255
253
static cl::opt<bool > CallsitePrioritizedInline (
256
254
" sample-profile-prioritized-inline" , cl::Hidden,
@@ -648,7 +646,7 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
648
646
std::vector<Function *> buildFunctionOrder (Module &M, LazyCallGraph &CG);
649
647
std::unique_ptr<ProfiledCallGraph> buildProfiledCallGraph (Module &M);
650
648
void generateMDProfMetadata (Function &F);
651
- bool errorIfHighChecksumMismatch (Module &M, ProfileSummaryInfo *PSI,
649
+ bool rejectHighStalenessProfile (Module &M, ProfileSummaryInfo *PSI,
652
650
const SampleProfileMap &Profiles);
653
651
654
652
// / Map from function name to Function *. Used to find the function from
@@ -2218,12 +2216,12 @@ bool SampleProfileLoader::doInitialization(Module &M,
2218
2216
// function selection is based on two criteria: 1) The function is "hot" enough,
2219
2217
// which is tuned by a hotness-based flag(ChecksumMismatchFuncHotBlockSkip). 2)
2220
2218
// The num of function is large enough which is tuned by the
2221
- // ChecksumMismatchNumFuncSkip flag.
2222
- bool SampleProfileLoader::errorIfHighChecksumMismatch (
2219
+ // MinfuncsForStalenessError flag.
2220
+ bool SampleProfileLoader::rejectHighStalenessProfile (
2223
2221
Module &M, ProfileSummaryInfo *PSI, const SampleProfileMap &Profiles) {
2224
2222
assert (FunctionSamples::ProfileIsProbeBased &&
2225
2223
" Only support for probe-based profile" );
2226
- uint64_t TotalSelectedFunc = 0 ;
2224
+ uint64_t TotalHotFunc = 0 ;
2227
2225
uint64_t NumMismatchedFunc = 0 ;
2228
2226
for (const auto &I : Profiles) {
2229
2227
const auto &FS = I.second ;
@@ -2240,22 +2238,22 @@ bool SampleProfileLoader::errorIfHighChecksumMismatch(
2240
2238
ChecksumMismatchFuncHotBlockSkip * PSI->getOrCompHotCountThreshold ())
2241
2239
continue ;
2242
2240
2243
- TotalSelectedFunc ++;
2241
+ TotalHotFunc ++;
2244
2242
if (ProbeManager->profileIsHashMismatched (*FuncDesc, FS))
2245
2243
NumMismatchedFunc++;
2246
2244
}
2247
2245
// Make sure that the num of selected function is not too small to distinguish
2248
2246
// from the user's benign changes.
2249
- if (TotalSelectedFunc < ChecksumMismatchNumFuncSkip )
2247
+ if (TotalHotFunc < MinfuncsForStalenessError )
2250
2248
return false ;
2251
2249
2252
2250
// Finally check the mismatch percentage against the threshold.
2253
2251
if (NumMismatchedFunc * 100 >=
2254
- TotalSelectedFunc * ChecksumMismatchErrorThreshold ) {
2252
+ TotalHotFunc * PrecentMismatchForStalenessError ) {
2255
2253
auto &Ctx = M.getContext ();
2256
2254
const char *Msg =
2257
- " The FDO profile is too old and will cause big performance regression, "
2258
- " please drop the profile and collect a new one ." ;
2255
+ " The input profile significantly mismatches current source code. "
2256
+ " Please recollect profile to avoid performance regression ." ;
2259
2257
Ctx.diagnose (DiagnosticInfoSampleProfile (M.getModuleIdentifier (), Msg));
2260
2258
return true ;
2261
2259
}
@@ -2796,7 +2794,7 @@ bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
2796
2794
2797
2795
// Error out if the profile checksum mismatch is too high.
2798
2796
if (FunctionSamples::ProfileIsProbeBased &&
2799
- errorIfHighChecksumMismatch (M, PSI, Reader->getProfiles ()))
2797
+ rejectHighStalenessProfile (M, PSI, Reader->getProfiles ()))
2800
2798
return false ;
2801
2799
2802
2800
// Compute the total number of samples collected in this profile.
0 commit comments