[llvm] r254211 - SamplePGO - Fix default threshold for hot callsites.

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 27 15:14:49 PST 2015


Author: dnovillo
Date: Fri Nov 27 17:14:49 2015
New Revision: 254211

URL: http://llvm.org/viewvc/llvm-project?rev=254211&view=rev
Log:
SamplePGO - Fix default threshold for hot callsites.

Based on testing of internal benchmarks, I'm lowering this threshold to
a value of 0.1%.  This means that SamplePGO will respect 99.9% of the
original inline decisions when following a profile.

The performance difference is noticeable in some tests. With the
previous threshold, the speedups over baseline -O2 was about 0.63%. With
the new default, the speedups are around 3% on average.

The point of this threshold is not to do more aggressive inlining. When
an inlined callsite crosses this threshold, SamplePGO will redo the
inline decision so that it can better apply the input profile.

By respecting most original inline decisions, we can apply more of the
input profile because the shape of the code follows the profile more
closely.

In the next series, I'll be looking at adding some inline hints for the
cold callsites and for toplevel functions that are hot/cold as well.

Modified:
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp

Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=254211&r1=254210&r2=254211&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Fri Nov 27 17:14:49 2015
@@ -71,8 +71,8 @@ static cl::opt<unsigned> SampleProfileSa
     "sample-profile-check-sample-coverage", cl::init(0), cl::value_desc("N"),
     cl::desc("Emit a warning if less than N% of samples in the input profile "
              "are matched to the IR."));
-static cl::opt<unsigned> SampleProfileHotThreshold(
-    "sample-profile-inline-hot-threshold", cl::init(5), cl::value_desc("N"),
+static cl::opt<double> SampleProfileHotThreshold(
+    "sample-profile-inline-hot-threshold", cl::init(0.1), cl::value_desc("N"),
     cl::desc("Inlined functions that account for more than N% of all samples "
              "collected in the parent function, will be inlined again."));
 
@@ -262,7 +262,8 @@ bool callsiteIsHot(const FunctionSamples
   if (CallsiteTotalSamples == 0)
     return false; // Callsite is trivially cold.
 
-  uint64_t PercentSamples = CallsiteTotalSamples * 100 / ParentTotalSamples;
+  double PercentSamples =
+      (double)CallsiteTotalSamples / (double)ParentTotalSamples * 100.0;
   return PercentSamples >= SampleProfileHotThreshold;
 }
 




More information about the llvm-commits mailing list