[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 12 14:18:51 PDT 2024


================
@@ -592,10 +599,15 @@ void preprocessUnreachableBlocks(FlowFunction &Func) {
 /// Decide if stale profile matching can be applied for a given function.
 /// Currently we skip inference for (very) large instances and for instances
 /// having "unexpected" control flow (e.g., having no sink basic blocks).
-bool canApplyInference(const FlowFunction &Func) {
+bool canApplyInference(const FlowFunction &Func,
+                       const yaml::bolt::BinaryFunctionProfile &YamlBF) {
   if (Func.Blocks.size() > opts::StaleMatchingMaxFuncSize)
     return false;
 
+  if ((double)Func.MatchedExecCount / YamlBF.ExecCount >=
+      opts::MatchedProfileThreshold / 100.0)
+    return false;
----------------
aaupov wrote:

It's a tricky question how to define the cutoff in terms of sufficient matching.
I first thought of defining a block count based cutoff (if we matched >5% of blocks, proceed with matching), but then what if these are cold blocks covering <1% of exec count? In this case we'd end up guessing/propagating most samples.

For block-based matching, the threshold should be higher than 5%, perhaps closer to a half? For exec count based matching, I'd feel comfortable with 5% as threshold.

https://github.com/llvm/llvm-project/pull/95156


More information about the llvm-branch-commits mailing list