Skip to content

Commit

Permalink
[BOLT] Improve Jump-Distance Metric -- Consider Function Execution Count
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Bohan Ren authored and maksfb committed Jul 25, 2017
1 parent 787db1c commit 87481cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bolt/CalcCacheMetrics.cpp
Expand Up @@ -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;
Expand All @@ -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 "
Expand Down

0 comments on commit 87481cb

Please sign in to comment.