Skip to content

Commit 3c87e5b

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents ab2c4a0 + 4f136a0 commit 3c87e5b

File tree

10 files changed

+325
-53
lines changed

10 files changed

+325
-53
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,6 @@ class BinaryContext {
775775
uint64_t PseudoProbeLooseMatchedSampleCount{0};
776776
/// the count of call matched samples
777777
uint64_t CallMatchedSampleCount{0};
778-
/// the number of stale functions that have matching number of blocks in
779-
/// the profile
780-
uint64_t NumStaleFuncsWithEqualBlockCount{0};
781-
/// the number of blocks that have matching size but a differing hash
782-
uint64_t NumStaleBlocksWithEqualIcount{0};
783778
} Stats;
784779

785780
// Original binary execution count stats.

bolt/include/bolt/Profile/ProfileYAMLMapping.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ struct PseudoProbeInfo {
101101
std::vector<uint64_t> CallProbes;
102102
std::vector<uint64_t> IndCallProbes;
103103
std::vector<uint32_t> InlineTreeNodes;
104+
uint32_t BlockProbe;
105+
std::string BlockProbesStr;
106+
std::string InlineTreeNodesStr;
104107

105108
bool operator==(const PseudoProbeInfo &Other) const {
106109
return InlineTreeIndex == Other.InlineTreeIndex &&
@@ -112,10 +115,13 @@ struct PseudoProbeInfo {
112115

113116
template <> struct MappingTraits<bolt::PseudoProbeInfo> {
114117
static void mapping(IO &YamlIO, bolt::PseudoProbeInfo &PI) {
118+
YamlIO.mapOptional("bl", PI.BlockProbe, 0);
119+
YamlIO.mapOptional("bs", PI.BlockProbesStr, "");
115120
YamlIO.mapOptional("blx", PI.BlockMask, 0);
116121
YamlIO.mapOptional("blk", PI.BlockProbes, std::vector<uint64_t>());
117122
YamlIO.mapOptional("call", PI.CallProbes, std::vector<uint64_t>());
118123
YamlIO.mapOptional("icall", PI.IndCallProbes, std::vector<uint64_t>());
124+
YamlIO.mapOptional("is", PI.InlineTreeNodesStr, "");
119125
YamlIO.mapOptional("id", PI.InlineTreeIndex, 0);
120126
YamlIO.mapOptional("ids", PI.InlineTreeNodes, std::vector<uint32_t>());
121127
}

bolt/include/bolt/Profile/YAMLProfileReader.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class YAMLProfileReader : public ProfileReaderBase {
174174

175175
/// Maps profiled function id to function, for function matching with calls as
176176
/// anchors.
177-
ProfileLookupMap IdToYamLBF;
177+
ProfileLookupMap IdToYamlBF;
178178

179179
/// For LTO symbol resolution.
180180
/// Map a common LTO prefix to a list of YAML profiles matching the prefix.
@@ -183,6 +183,10 @@ class YAMLProfileReader : public ProfileReaderBase {
183183
/// Map a common LTO prefix to a set of binary functions.
184184
StringMap<std::unordered_set<BinaryFunction *>> LTOCommonNameFunctionMap;
185185

186+
/// For pseudo probe function matching.
187+
/// Map profile GUID to YAML profile.
188+
std::unordered_map<uint64_t, yaml::bolt::BinaryFunctionProfile *> GUIDMap;
189+
186190
/// Function names in profile.
187191
StringSet<> ProfileFunctionNames;
188192

@@ -244,6 +248,10 @@ class YAMLProfileReader : public ProfileReaderBase {
244248

245249
/// Check if the profile uses an event with a given \p Name.
246250
bool usesEvent(StringRef Name) const;
251+
252+
/// Dump profile as dot.
253+
void dumpGraph(BinaryContext &BC, raw_ostream &OS,
254+
const yaml::bolt::BinaryFunctionProfile &YamlBF) const;
247255
};
248256

249257
} // namespace bolt

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,12 +1505,6 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
15051505
if (NumAllStaleFunctions) {
15061506
const float PctStale =
15071507
NumAllStaleFunctions / (float)NumAllProfiledFunctions * 100.0f;
1508-
const float PctStaleFuncsWithEqualBlockCount =
1509-
(float)BC.Stats.NumStaleFuncsWithEqualBlockCount /
1510-
NumAllStaleFunctions * 100.0f;
1511-
const float PctStaleBlocksWithEqualIcount =
1512-
(float)BC.Stats.NumStaleBlocksWithEqualIcount /
1513-
BC.Stats.NumStaleBlocks * 100.0f;
15141508
auto printErrorOrWarning = [&]() {
15151509
if (PctStale > opts::StaleThreshold)
15161510
BC.errs() << "BOLT-ERROR: ";
@@ -1533,17 +1527,6 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
15331527
<< "%) belong to functions with invalid"
15341528
" (possibly stale) profile.\n";
15351529
}
1536-
BC.outs() << "BOLT-INFO: " << BC.Stats.NumStaleFuncsWithEqualBlockCount
1537-
<< " stale function"
1538-
<< (BC.Stats.NumStaleFuncsWithEqualBlockCount == 1 ? "" : "s")
1539-
<< format(" (%.1f%% of all stale)",
1540-
PctStaleFuncsWithEqualBlockCount)
1541-
<< " have matching block count.\n";
1542-
BC.outs() << "BOLT-INFO: " << BC.Stats.NumStaleBlocksWithEqualIcount
1543-
<< " stale block"
1544-
<< (BC.Stats.NumStaleBlocksWithEqualIcount == 1 ? "" : "s")
1545-
<< format(" (%.1f%% of all stale)", PctStaleBlocksWithEqualIcount)
1546-
<< " have matching icount.\n";
15471530
if (PctStale > opts::StaleThreshold) {
15481531
return createFatalBOLTError(
15491532
Twine("BOLT-ERROR: stale functions exceed specified threshold of ") +

bolt/lib/Profile/StaleProfileMatching.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ bool YAMLProfileReader::inferStaleProfile(
10231023
// Match as many block/jump counts from the stale profile as possible
10241024
size_t MatchedBlocks =
10251025
matchWeights(BF.getBinaryContext(), BlockOrder, YamlBF, Func,
1026-
YamlBP.Header.HashFunction, IdToYamLBF, BF, ProbeMatchSpecs);
1026+
YamlBP.Header.HashFunction, IdToYamlBF, BF, ProbeMatchSpecs);
10271027

10281028
// Adjust the flow function by marking unreachable blocks Unlikely so that
10291029
// they don't get any counts assigned.

0 commit comments

Comments
 (0)