[clang] [perf-training][merge-fdata] Clean up input fdata files (PR #245890)
Amir Ayupov via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 22:19:49 PST 2026
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/245890
Reland #139650 (reverted in #240375) with two fixes.
The BOLT AArch64 worker runs out of disk space because the clang-bolt build leaves the per-process fdata files behind. Delete the inputs after merge-fdata has merged them.
Fixes over #139650:
- Pass the inputs as separate arguments. #139650 passed the list as one argv element, so subprocess raised TypeError and broke every clang-bolt build.
- Keep the output out of the inputs. clang's BOLT_FDATA (prof.fdata) lives in the perf-training directory that merge_fdata scans, so when bolt-optimize runs again after clang is relinked, the previous prof.fdata would be merged into itself and then deleted, and the following BOLT step would fail on the missing profile.
The inputs are only deleted after merge-fdata succeeds.
>From c3e0da30f70a469d401545aea05936db4d3cf5bf Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Tue, 24 Nov 2026 14:43:58 -0800
Subject: [PATCH] [perf-training][merge-fdata] Clean up input fdata files
Reland #139650 (reverted in #240375) with two fixes.
The BOLT AArch64 worker runs out of disk space because the clang-bolt build
leaves the per-process fdata files behind. Delete the inputs after
merge-fdata has merged them.
Fixes over #139650:
- Pass the inputs as separate arguments. #139650 passed the list as one argv
element, so subprocess raised TypeError and broke every clang-bolt build.
- Keep the output out of the inputs. clang's BOLT_FDATA (prof.fdata) lives
in the perf-training directory that merge_fdata scans, so when
bolt-optimize runs again after clang is relinked, the previous prof.fdata
would be merged into itself and then deleted, and the following BOLT step
would fail on the missing profile.
The inputs are only deleted after merge-fdata succeeds.
---
clang/utils/perf-training/perf-helper.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py
index e28920f3e0c43c..d9a35b8e9ea136 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -73,9 +73,19 @@ def merge_fdata(args):
+ "\tMerges all fdata files from path into output."
)
return 1
- cmd = [args[0], "-o", args[1]]
- cmd.extend(findFilesWithExtension(args[2], "fdata"))
- subprocess.check_call(cmd)
+ merge_fdata_bin, output, path = args
+ # The output may live under path (e.g. prof.fdata in the perf-training
+ # dir), so keep a previous output out of the inputs.
+ output_path = os.path.realpath(output)
+ inputs = [
+ filename
+ for filename in findFilesWithExtension(path, "fdata")
+ if os.path.realpath(filename) != output_path
+ ]
+ subprocess.check_call([merge_fdata_bin, "-o", output, *inputs])
+ # Remove merged input fdata files to save space.
+ for filename in inputs:
+ os.remove(filename)
return 0
More information about the cfe-commits
mailing list