[BOLT][heatmap] Produce zoomed-out heatmaps (#140153)
Add a capability to produce multiple heatmaps with given bucket sizes. The default heatmap block size (64B) could be too fine-grained for large binaries. Extend the option `block-size` to accept a list of bucket sizes for additional heatmaps with coarser granularity. The heatmap is simply rescaled so provided sizes should be multiples of each other. Human-readable suffixes can be used, e.g. 4K, 16kb, 1MiB. New defaults: 64B (base bucket size), 4KB (default page size), 256KB (for large binaries). Test Plan: updated heatmap-preagg.test
This commit is contained in:
@@ -1314,8 +1314,9 @@ std::error_code DataAggregator::printLBRHeatMap() {
|
||||
opts::HeatmapMaxAddress = 0xffffffffffffffff;
|
||||
opts::HeatmapMinAddress = KernelBaseAddr;
|
||||
}
|
||||
Heatmap HM(opts::HeatmapBlock, opts::HeatmapMinAddress,
|
||||
opts::HeatmapMaxAddress, getTextSections(BC));
|
||||
opts::HeatmapBlockSizes &HMBS = opts::HeatmapBlock;
|
||||
Heatmap HM(HMBS[0], opts::HeatmapMinAddress, opts::HeatmapMaxAddress,
|
||||
getTextSections(BC));
|
||||
auto getSymbolValue = [&](const MCSymbol *Symbol) -> uint64_t {
|
||||
if (Symbol)
|
||||
if (ErrorOr<uint64_t> SymValue = BC->getSymbolValue(*Symbol))
|
||||
@@ -1365,6 +1366,14 @@ std::error_code DataAggregator::printLBRHeatMap() {
|
||||
HM.printCDF(opts::HeatmapOutput + ".csv");
|
||||
HM.printSectionHotness(opts::HeatmapOutput + "-section-hotness.csv");
|
||||
}
|
||||
// Provide coarse-grained heatmaps if requested via zoom-out scales
|
||||
for (const uint64_t NewBucketSize : ArrayRef(HMBS).drop_front()) {
|
||||
HM.resizeBucket(NewBucketSize);
|
||||
if (opts::HeatmapOutput == "-")
|
||||
HM.print(opts::HeatmapOutput);
|
||||
else
|
||||
HM.print(formatv("{0}-{1}", opts::HeatmapOutput, NewBucketSize).str());
|
||||
}
|
||||
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user