[PATCH] D132602: [llvm-profdata] Adjust profile supplementation heuristics
Rong Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 14:34:15 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd22c5d0f5520: [llvm-profdata] Adjust profile supplementation heuristics (authored by xur).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132602/new/
https://reviews.llvm.org/D132602
Files:
llvm/test/tools/llvm-profdata/Inputs/mix_instr_small.proftext
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
llvm/tools/llvm-profdata/llvm-profdata.cpp
Index: llvm/tools/llvm-profdata/llvm-profdata.cpp
===================================================================
--- llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -461,6 +461,7 @@
/// The profile entry for a function in instrumentation profile.
struct InstrProfileEntry {
uint64_t MaxCount = 0;
+ uint64_t NumEdgeCounters = 0;
float ZeroCounterRatio = 0.0;
InstrProfRecord *ProfRecord;
InstrProfileEntry(InstrProfRecord *Record);
@@ -476,6 +477,7 @@
ZeroCntNum += !Record->Counts[I];
}
ZeroCounterRatio = (float)ZeroCntNum / CntNum;
+ NumEdgeCounters = CntNum;
}
/// Either set all the counters in the instr profile entry \p IFE to -1
@@ -584,10 +586,10 @@
auto &FContext = PD.first;
const sampleprof::FunctionSamples &FS = PD.second;
auto It = InstrProfileMap.find(FContext.toString());
- if (FS.getHeadSamples() > ColdSampleThreshold &&
+ if (FS.getMaxCountInside() > ColdSampleThreshold &&
It != InstrProfileMap.end() &&
It->second.MaxCount <= ColdInstrThreshold &&
- FS.getBodySamples().size() >= SupplMinSizeThreshold) {
+ It->second.NumEdgeCounters >= SupplMinSizeThreshold) {
updateInstrProfileEntry(It->second, HotInstrThreshold,
ZeroCounterThreshold);
}
Index: llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
===================================================================
--- llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
+++ llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
@@ -64,21 +64,21 @@
RUN: llvm-profdata merge \
RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \
RUN: -suppl-min-size-threshold=2 -zero-counter-threshold=0.7 \
-RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
+RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t
RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4
MIX4: foo:
MIX4-NEXT: Hash: 0x0000000000000007
-MIX4-NEXT: Counters: 5
-MIX4-NEXT: Block counts: [12, 13, 0, 0, 0]
+MIX4-NEXT: Counters: 1
+MIX4-NEXT: Block counts: [0]
MIX4: goo:
MIX4-NEXT: Hash: 0x0000000000000005
MIX4-NEXT: Counters: 3
MIX4-NEXT: Block counts: [18446744073709551615, 18446744073709551615, 18446744073709551615]
MIX4: moo:
MIX4-NEXT: Hash: 0x0000000000000009
-MIX4-NEXT: Counters: 4
-MIX4-NEXT: Block counts: [3000, 1000, 2000, 500]
+MIX4-NEXT: Counters: 1
+MIX4-NEXT: Block counts: [0]
Test profile summary won't be affected by -1 counter.
RUN: llvm-profdata merge \
Index: llvm/test/tools/llvm-profdata/Inputs/mix_instr_small.proftext
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-profdata/Inputs/mix_instr_small.proftext
@@ -0,0 +1,18 @@
+:ir
+foo
+7
+1
+0
+
+goo
+5
+3
+0
+0
+0
+
+moo
+9
+1
+0
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132602.456464.patch
Type: text/x-patch
Size: 2926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220829/b2a7f43d/attachment.bin>
More information about the llvm-commits
mailing list