This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Report per-section hotness in bolt-heatmap.
ClosedPublic

Authored by rahmanl on Apr 25 2022, 12:43 PM.

Details

Summary

This patch adds a new feature to bolt heatmap to print the hotness of each section in terms of the percentage of samples within that section.

Sample output generated for the clang binary:

Section Name, Begin Address, End Address, Percentage Hotness
.text, 0x1a7b9b0, 0x20a2cc0, 1.4709
.init, 0x20a2cc0, 0x20a2ce1, 0.0001
.fini, 0x20a2ce4, 0x20a2cf2, 0.0000
.text.unlikely, 0x20a2d00, 0x431990c, 0.3061
.text.hot, 0x4319910, 0x4bc6927, 97.2197
.text.startup, 0x4bc6930, 0x4c10c89, 0.0058
.plt, 0x4c10c90, 0x4c12010, 0.9974

Diff Detail

Event Timeline

rahmanl created this revision.Apr 25 2022, 12:43 PM
Herald added a project: Restricted Project. · View Herald Transcript
rahmanl updated this revision to Diff 425044.Apr 25 2022, 3:53 PM

Refactoring.

rahmanl published this revision for review.Apr 25 2022, 3:59 PM
rahmanl edited the summary of this revision. (Show Details)
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2022, 3:59 PM
rahmanl updated this revision to Diff 425050.Apr 25 2022, 4:02 PM

Refactoring.

That's a nice functionality, thanks!

bolt/include/bolt/Profile/Heatmap.h
57–61

What happens if I want a heatmap that shows activity in addresses that are not mapped to a text section? (e.g. jitted code)

We need to support recording samples in unmapped regions as well.

bolt/lib/Profile/DataAggregator.cpp
114

Instead of using static, wrap it in an anonymous namespace (just the extend the one we already have in lines 132-137).

bolt/lib/Profile/Heatmap.cpp
255–258
271
276

This and the next comment are optional. Either do that or assert(). The intent is to avoid crashing if Address is greater than the last EndAddress (I know this doesn't happen, but it is an invariant that would be nice if made explicit via an assertion).

278
rahmanl updated this revision to Diff 427102.May 4 2022, 11:52 AM
rahmanl marked 5 inline comments as done.

Add entry for unmapped regions.

rahmanl added inline comments.May 4 2022, 11:55 AM
bolt/include/bolt/Profile/Heatmap.h
57–61

Good idea. I removed this check and instead added a separate (unmapped) entry in the text section hotness data.

rafauler accepted this revision.May 4 2022, 2:48 PM

LGTM

This revision is now accepted and ready to land.May 4 2022, 2:48 PM
This revision was automatically updated to reflect the committed changes.