[BOLT] Improve Jump-Distance Metric -- Consider Function Execution Count

Summary:
Function execution count is very important. When calculating metric, we
should care more about functions which are known to be executed.

The correlations between this metric and both CPU time is slightly improved
to be close to  96% and the correlation between this metric and Cache Miss
remains the same 96%.

Thanks the suggestion from Sergey!

(cherry picked from FBD5494720)
This commit is contained in:
Bohan Ren 2017-07-25 16:27:00 -07:00 committed by Maksim Panchenko
parent 787db1cf3e
commit 87481cb494
1 changed files with 4 additions and 1 deletions

View File

@ -141,6 +141,9 @@ void CalcCacheMetrics::calcGraphDistance(
uint64_t FuncCount = 0;
for (auto &BFI : BinaryFunctions) {
auto &Function = BFI.second;
// Only consider functions which are known to be executed
if (Function.getKnownExecutionCount() == 0)
continue;
std::unordered_map<uint64_t, double> TraversalMap;
uint64_t TraversalCount = 0;
@ -159,7 +162,7 @@ void CalcCacheMetrics::calcGraphDistance(
double AverageValue =
TraversalMap.empty() ? 0 : (TotalValue * 1.0 / TraversalMap.size());
TotalFuncValue += AverageValue;
++FuncCount;
FuncCount += TraversalMap.empty() ? 0 : 1;
}
outs() << format(" Sum of averages of traversal distance for all "