Skip to content

Commit 0d16d90

Browse files
committed
update
Created using spr 1.3.4
1 parent 1b7d2ed commit 0d16d90

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

bolt/lib/Profile/Heatmap.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void Heatmap::printSectionHotness(StringRef FileName) const {
297297
void Heatmap::printSectionHotness(raw_ostream &OS) const {
298298
uint64_t NumTotalCounts = 0;
299299
StringMap<uint64_t> SectionHotness;
300-
StringMap<uint64_t> SectionUtilization;
300+
StringMap<uint64_t> BucketUtilization;
301301
unsigned TextSectionIndex = 0;
302302

303303
if (TextSections.empty())
@@ -312,42 +312,39 @@ void Heatmap::printSectionHotness(raw_ostream &OS) const {
312312
UnmappedHotness += Frequency;
313313
};
314314

315-
for (const auto [Bucket, Count] : Map) {
316-
NumTotalCounts += Count;
315+
for (const std::pair<const uint64_t, uint64_t> &KV : Map) {
316+
NumTotalCounts += KV.second;
317317
// We map an address bucket to the first section (lowest address)
318318
// overlapping with that bucket.
319-
auto Address = Bucket * BucketSize;
319+
auto Address = KV.first * BucketSize;
320320
while (TextSectionIndex < TextSections.size() &&
321321
Address >= TextSections[TextSectionIndex].EndAddress)
322322
TextSectionIndex++;
323323
if (TextSectionIndex >= TextSections.size() ||
324324
Address + BucketSize < TextSections[TextSectionIndex].BeginAddress) {
325-
RecordUnmappedBucket(Address, Count);
325+
RecordUnmappedBucket(Address, KV.second);
326326
continue;
327327
}
328-
StringRef Name = TextSections[TextSectionIndex].Name;
329-
SectionHotness[Name] += Count;
330-
++SectionUtilization[Name];
328+
SectionHotness[TextSections[TextSectionIndex].Name] += KV.second;
329+
++BucketUtilization[TextSections[TextSectionIndex].Name];
331330
}
332331

333-
auto getNumBuckets = [&](uint64_t Begin, uint64_t End) {
334-
return End / BucketSize + !!(End % BucketSize) - Begin / BucketSize;
335-
};
336-
337332
assert(NumTotalCounts > 0 &&
338333
"total number of heatmap buckets should be greater than 0");
339334

340335
OS << "Section Name, Begin Address, End Address, Percentage Hotness, "
341-
<< "Utilization Pct\n";
336+
<< "Utilization Pct, Partition Score\n";
342337
for (const auto [Name, Begin, End] : TextSections) {
343-
const float RelHotness = 100. * SectionHotness[Name] / NumTotalCounts;
344-
const float BucketUtilization =
345-
100. * SectionUtilization[Name] / getNumBuckets(Begin, End);
346-
OS << formatv("{0}, {1:x}, {2:x}, {3:f4}, {4:f4}\n", Name, Begin, End,
347-
RelHotness, BucketUtilization);
338+
const float Hotness = 1. * SectionHotness[Name] / NumTotalCounts;
339+
const uint64_t NumBuckets =
340+
End / BucketSize + !!(End % BucketSize) - Begin / BucketSize;
341+
const float Utilization = 1. * BucketUtilization[Name] / NumBuckets;
342+
const float PartitionScore = Hotness * Utilization;
343+
OS << formatv("{0}, {1:x}, {2:x}, {3:f4}, {4:f4}, {5:f4}\n", Name, Begin,
344+
End, 100. * Hotness, 100. * Utilization, PartitionScore);
348345
}
349346
if (UnmappedHotness > 0)
350-
OS << formatv("[unmapped], 0x0, 0x0, {0:f4}, 0\n",
347+
OS << formatv("[unmapped], 0x0, 0x0, {0:f4}, 0, 0\n",
351348
100.0 * UnmappedHotness / NumTotalCounts);
352349
}
353350
} // namespace bolt

bolt/test/X86/heatmap-preagg.test

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ RUN: FileCheck %s --check-prefix CHECK-SEC-HOT-BAT --input-file %t2-section-hotn
1717
CHECK-HEATMAP: PERF2BOLT: read 81 aggregated LBR entries
1818
CHECK-HEATMAP: HEATMAP: invalid traces: 1
1919

20-
CHECK-SEC-HOT: Section Name, Begin Address, End Address, Percentage Hotness, Utilization Pct
21-
CHECK-SEC-HOT-NEXT: .init, 0x401000, 0x40101b, 16.8545, 100.0000
22-
CHECK-SEC-HOT-NEXT: .plt, 0x401020, 0x4010b0, 4.7583, 66.6667
23-
CHECK-SEC-HOT-NEXT: .text, 0x4010b0, 0x401c25, 78.3872, 85.1064
24-
CHECK-SEC-HOT-NEXT: .fini, 0x401c28, 0x401c35, 0.0000, 0.0000
20+
CHECK-SEC-HOT: Section Name, Begin Address, End Address, Percentage Hotness, Utilization Pct, Partition Score
21+
CHECK-SEC-HOT-NEXT: .init, 0x401000, 0x40101b, 16.8545, 100.0000, 0.1685
22+
CHECK-SEC-HOT-NEXT: .plt, 0x401020, 0x4010b0, 4.7583, 66.6667, 0.0317
23+
CHECK-SEC-HOT-NEXT: .text, 0x4010b0, 0x401c25, 78.3872, 85.1064, 0.6671
24+
CHECK-SEC-HOT-NEXT: .fini, 0x401c28, 0x401c35, 0.0000, 0.0000, 0.0000
2525

2626
CHECK-HEATMAP-BAT: PERF2BOLT: read 79 aggregated LBR entries
2727
CHECK-HEATMAP-BAT: HEATMAP: invalid traces: 2
2828

29-
CHECK-SEC-HOT-BAT: Section Name, Begin Address, End Address, Percentage Hotness, Utilization Pct
30-
CHECK-SEC-HOT-BAT-NEXT: .init, 0x401000, 0x40101b, 17.2888, 100.0000
31-
CHECK-SEC-HOT-BAT-NEXT: .plt, 0x401020, 0x4010b0, 5.6132, 66.6667
32-
CHECK-SEC-HOT-BAT-NEXT: .bolt.org.text, 0x4010b0, 0x401c25, 38.3385
33-
CHECK-SEC-HOT-BAT-NEXT: .fini, 0x401c28, 0x401c35, 0.0000, 0.0000
34-
CHECK-SEC-HOT-BAT-NEXT: .text, 0x800000, 0x8002cc, 38.7595, 91.6667
35-
CHECK-SEC-HOT-BAT-NEXT: .text.cold, 0x800300, 0x800415, 0.0000, 0.0000
29+
CHECK-SEC-HOT-BAT: Section Name, Begin Address, End Address, Percentage Hotness, Utilization Pct, Partition Score
30+
CHECK-SEC-HOT-BAT-NEXT: .init, 0x401000, 0x40101b, 17.2888, 100.0000, 0.1729
31+
CHECK-SEC-HOT-BAT-NEXT: .plt, 0x401020, 0x4010b0, 5.6132, 66.6667, 0.0374
32+
CHECK-SEC-HOT-BAT-NEXT: .bolt.org.text, 0x4010b0, 0x401c25, 38.3385, 0.1958
33+
CHECK-SEC-HOT-BAT-NEXT: .fini, 0x401c28, 0x401c35, 0.0000, 0.0000, 0.0000
34+
CHECK-SEC-HOT-BAT-NEXT: .text, 0x800000, 0x8002cc, 38.7595, 91.6667, 0.3553
35+
CHECK-SEC-HOT-BAT-NEXT: .text.cold, 0x800300, 0x800415, 0.0000, 0.0000, 0.0000

0 commit comments

Comments
 (0)