Skip to content

Commit d61442c

Browse files
committed
Use isHotCountNthPercentile and total_samples to decide if function is hot
1 parent 02bb76c commit d61442c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,10 @@ static cl::opt<unsigned> ProfileICPRelativeHotnessSkip(
234234
cl::desc(
235235
"Skip relative hotness check for ICP up to given number of targets."));
236236

237-
static cl::opt<unsigned> ChecksumMismatchFuncHotBlockSkip(
238-
"checksum-mismatch-func-hot-block-skip", cl::Hidden, cl::init(100),
239-
cl::desc("For checksum-mismatch error check, skip checking the function "
240-
"whose num of hot(on average) blocks is smaller than the "
241-
"given number."));
237+
static cl::opt<unsigned> HotFuncCutoffForStalenessError(
238+
"hot-func-cutoff-for-staleness-error", cl::Hidden, cl::init(999000),
239+
cl::desc("Hot function cutoff for staleness error. It's percentile value "
240+
"(multiplied by 10000), e.g. 995000 for 99.5 percentile."));
242241

243242
static cl::opt<unsigned> MinfuncsForStalenessError(
244243
"min-functions-for-staleness-error", cl::Hidden, cl::init(50),
@@ -647,7 +646,7 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
647646
std::unique_ptr<ProfiledCallGraph> buildProfiledCallGraph(Module &M);
648647
void generateMDProfMetadata(Function &F);
649648
bool rejectHighStalenessProfile(Module &M, ProfileSummaryInfo *PSI,
650-
const SampleProfileMap &Profiles);
649+
const SampleProfileMap &Profiles);
651650

652651
/// Map from function name to Function *. Used to find the function from
653652
/// the function name. If the function name contains suffix, additional
@@ -2214,7 +2213,7 @@ bool SampleProfileLoader::doInitialization(Module &M,
22142213
// big set of functions that are supposed to be globally performance
22152214
// significant, only compute and check the mismatch within those functions. The
22162215
// function selection is based on two criteria: 1) The function is "hot" enough,
2217-
// which is tuned by a hotness-based flag(ChecksumMismatchFuncHotBlockSkip). 2)
2216+
// which is tuned by a hotness-based flag(HotFuncCutoffForStalenessError). 2)
22182217
// The num of function is large enough which is tuned by the
22192218
// MinfuncsForStalenessError flag.
22202219
bool SampleProfileLoader::rejectHighStalenessProfile(
@@ -2234,8 +2233,8 @@ bool SampleProfileLoader::rejectHighStalenessProfile(
22342233
// checksum-mismatched and dropped, the whole binary will likely be
22352234
// impacted, so here we use a hotness-based threshold to control the
22362235
// selection.
2237-
if (FS.getTotalSamples() <
2238-
ChecksumMismatchFuncHotBlockSkip * PSI->getOrCompHotCountThreshold())
2236+
if (!PSI->isHotCountNthPercentile(HotFuncCutoffForStalenessError,
2237+
FS.getTotalSamples()))
22392238
continue;
22402239

22412240
TotalHotFunc++;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
; REQUIRES: x86_64-linux
2-
; RUN: not opt < %S/pseudo-probe-profile-mismatch.ll -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof -checksum-mismatch-func-hot-block-skip=0 -min-functions-for-staleness-error=1 -precent-mismatch-for-staleness-error=1 -S 2>&1 | FileCheck %s
2+
; RUN: not opt < %S/pseudo-probe-profile-mismatch.ll -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof -min-functions-for-staleness-error=1 -precent-mismatch-for-staleness-error=1 -S 2>&1 | FileCheck %s
33

44
; CHECK: error: {{.*}}: The input profile significantly mismatches current source code. Please recollect profile to avoid performance regression.

0 commit comments

Comments
 (0)