[llvm] [BOLT] Report input staleness (PR #79496)
Amir Ayupov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 13:11:04 PST 2024
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/79496
>From 692fef3fb7b3fab4fc4c67412474576fdeba13b2 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Wed, 1 Nov 2023 14:44:55 -0700
Subject: [PATCH 1/3] [BOLT] Report input staleness
---
bolt/lib/Passes/BinaryPasses.cpp | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/bolt/lib/Passes/BinaryPasses.cpp b/bolt/lib/Passes/BinaryPasses.cpp
index 4e1343e2c30be5..955cd3726ad41a 100644
--- a/bolt/lib/Passes/BinaryPasses.cpp
+++ b/bolt/lib/Passes/BinaryPasses.cpp
@@ -1417,9 +1417,9 @@ void PrintProgramStats::runOnFunctions(BinaryContext &BC) {
<< (NumNonSimpleProfiledFunctions == 1 ? "" : "s")
<< " with profile could not be optimized\n";
}
- if (NumStaleProfileFunctions) {
+ if (NumAllStaleFunctions) {
const float PctStale =
- NumStaleProfileFunctions / (float)NumAllProfiledFunctions * 100.0f;
+ NumAllStaleFunctions / (float)NumAllProfiledFunctions * 100.0f;
auto printErrorOrWarning = [&]() {
if (PctStale > opts::StaleThreshold)
errs() << "BOLT-ERROR: ";
@@ -1427,16 +1427,18 @@ void PrintProgramStats::runOnFunctions(BinaryContext &BC) {
errs() << "BOLT-WARNING: ";
};
printErrorOrWarning();
- errs() << NumStaleProfileFunctions
+ errs() << NumAllStaleFunctions
<< format(" (%.1f%% of all profiled)", PctStale) << " function"
- << (NumStaleProfileFunctions == 1 ? "" : "s")
+ << (NumAllStaleFunctions == 1 ? "" : "s")
<< " have invalid (possibly stale) profile."
" Use -report-stale to see the list.\n";
if (TotalSampleCount > 0) {
printErrorOrWarning();
- errs() << StaleSampleCount << " out of " << TotalSampleCount
- << " samples in the binary ("
- << format("%.1f", ((100.0f * StaleSampleCount) / TotalSampleCount))
+ errs() << (StaleSampleCount + InferredSampleCount) << " out of "
+ << TotalSampleCount << " samples in the binary ("
+ << format("%.1f",
+ ((100.0f * (StaleSampleCount + InferredSampleCount)) /
+ TotalSampleCount))
<< "%) belong to functions with invalid"
" (possibly stale) profile.\n";
}
>From 3e6462ca86b4daca47b00ce51a647b890a3b2f43 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Wed, 1 Nov 2023 14:44:55 -0700
Subject: [PATCH 2/3] Update reader-stale-yaml.test
---
bolt/test/X86/reader-stale-yaml.test | 1 +
1 file changed, 1 insertion(+)
diff --git a/bolt/test/X86/reader-stale-yaml.test b/bolt/test/X86/reader-stale-yaml.test
index ad0945b1493407..2c6a1a0358a29e 100644
--- a/bolt/test/X86/reader-stale-yaml.test
+++ b/bolt/test/X86/reader-stale-yaml.test
@@ -51,6 +51,7 @@ CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 300), .LFT[[#BB1:]
CHECK1: .LFT[[#BB1:]] (2 instructions, align : 1)
# Check the overall inference stats.
CHECK1: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
+CHECK1: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile
CHECK1: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})
>From 700778fe24bb6abaa4f8e5d8c3c74e488d30becf Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Thu, 25 Jan 2024 13:10:50 -0800
Subject: [PATCH 3/3] Update reader-stale-yaml.test
---
bolt/test/X86/reader-stale-yaml.test | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/bolt/test/X86/reader-stale-yaml.test b/bolt/test/X86/reader-stale-yaml.test
index 2c6a1a0358a29e..533ed917c1aeb0 100644
--- a/bolt/test/X86/reader-stale-yaml.test
+++ b/bolt/test/X86/reader-stale-yaml.test
@@ -3,6 +3,9 @@
REQUIRES: asserts
RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
+RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
+RUN: --infer-stale-profile=0 --profile-ignore-hash=1 --profile-use-dfs=0 \
+RUN: 2>&1 | FileCheck %s -check-prefix=CHECK0
# Testing "usqrt"
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 \
@@ -12,6 +15,10 @@ RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --print-cfg --print-only=SolveCubic --infer-stale-profile=1 \
RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK2
+CHECK0: BOLT-INFO: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
+CHECK0: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile
+CHECK0: BOLT-WARNING: 1192 out of 1192 samples in the binary (100.0%) belong to functions with invalid (possibly stale) profile
+
# Function "usqrt" has stale profile, since the number of blocks in the profile
# (nblocks=6) does not match the size of the CFG in the binary. The entry
# block (bid=0) has an incorrect (missing) count, which should be inferred by
@@ -52,6 +59,7 @@ CHECK1: .LFT[[#BB1:]] (2 instructions, align : 1)
# Check the overall inference stats.
CHECK1: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
CHECK1: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile
+CHECK1: BOLT-WARNING: 1192 out of 1192 samples in the binary (100.0%) belong to functions with invalid (possibly stale) profile
CHECK1: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})
More information about the llvm-commits
mailing list