This is an archive of the discontinued LLVM Phabricator instance.

Use isFunctionHotInCallGraph to set the function section prefix.
ClosedPublic

Authored by danielcdh on Mar 21 2017, 5:33 PM.

Details

Summary

The current prefix based function layout algorithm only looks at function's entry count, which is not sufficient. A function should be grouped together if its entry count or any call edge count is hot.

Event Timeline

danielcdh created this revision.Mar 21 2017, 5:33 PM
eraman edited edge metadata.Mar 22 2017, 2:12 PM

I concur that the current state of checking the hotness of entry count is not good. I am not sure this is the right approach without seeing some numbers. Consider a function foo with calls to bar1 and bar2. Let's say foo's entry is cold. Neither foo->bar1 nor foo->bar2 is hot, but the sum of their counts is hot. Your new solution will still place foo in cold section. So may be we should add all outgoing counts and check its hotness. Even then, we may not want to put foo in cold section if the sum of outgoing edges is not cold.

Updated the patch to change for the cold prefix tool.

In terms of performance, it will only affect ITLB performance on very large applications. For the perf test I've done, it shows improved ITLB and heatmap, but no visible performance difference is observed.

eraman added inline comments.Mar 22 2017, 3:42 PM
lib/Analysis/ProfileSummaryInfo.cpp
128

Based on our offline conversation, I thought we want a function to be labeled only if both its entry count and the outgoing edge count sum is cold, no? With this code, a cold function can still have non-hot non-cold out edges.

I think it makes sense to have

coldInCallGraph => cold entry count AND cold out edges
hotInCallGraph => hot entry count OR hot out edges.

Do you agree?

danielcdh added inline comments.Mar 22 2017, 3:59 PM
lib/Analysis/ProfileSummaryInfo.cpp
128

You are right. Updated the code.

The code looks fine to me, but the test needs to be updated.

lib/Analysis/ProfileSummaryInfo.cpp
120

Nit: function's entry AND total call edge count is cold

121

Comment has been pasted from the previous function and hasn't been properly updated.

test/Transforms/CodeGenPrepare/section.ll
1

The test needs to be updated. You've added one case - a function with cold entry with hot call edge - but the other scenarios (sum of outgoing edges is hot, cold function with non-cold outgoing edges etc) are not tested.

danielcdh updated this revision to Diff 92734.Mar 22 2017, 4:18 PM
danielcdh marked 3 inline comments as done.

update

LGTM after addressing the test changes.

test/Transforms/CodeGenPrepare/section.ll
1

It's better now, but I prefer you add cases where there are multiple out edges where sum of outgoing edges is hot (and individual edges are not) and sum of outgoing edges is not cold with individual edges being cold.

eraman accepted this revision.Mar 23 2017, 4:13 PM
This revision is now accepted and ready to land.Mar 23 2017, 4:13 PM
danielcdh closed this revision.Mar 23 2017, 4:26 PM