From 2badfee8a86a6b91d29138c3d9ca15e88db293c4 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Fri, 27 Nov 2015 23:14:49 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254211 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/SampleProfile.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index 1f18fb76aea..69194eac078 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -71,8 +71,8 @@ static cl::opt SampleProfileSampleCoverage( "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 SampleProfileHotThreshold( - "sample-profile-inline-hot-threshold", cl::init(5), cl::value_desc("N"), +static cl::opt 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 *CallerFS, 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; } -- 2.34.1