Skip to content

Commit bb53ec2

Browse files
authored
Clean up benchmark directories after building (rust-lang#2583)
This commit makes benchcomp delete fresh copies of benchmark directories after running the benchmark suite, by default. This is to save disk space, especially on CI machines which do not have enough disk space to run the perf suite. The new behavior can be turned off with the new --no-cleanup-run-dirs flag.
1 parent ca66814 commit bb53ec2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tools/benchcomp/benchcomp/cmd_args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ def _get_args_dict():
138138
"help":
139139
"do not make a fresh copy of the benchmark "
140140
"directories before running each variant",
141+
}, {
142+
"flags": ["--keep-temps"],
143+
"action": "store_false",
144+
"dest": "cleanup_directory",
145+
"help":
146+
"do not delete fresh copies of benchmark "
147+
"directories after running each variant",
141148
}],
142149
},
143150
"collate": {

tools/benchcomp/benchcomp/entry/run.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class _SingleInvocation:
3939
command_line: str
4040
directory: pathlib.Path
4141

42+
cleanup_directory: bool
4243
env: dict = dataclasses.field(default_factory=dict)
4344
timeout: int = None
4445
memout: int = None
@@ -85,6 +86,9 @@ def __call__(self):
8586
encoding="utf-8") as handle:
8687
yaml.dump(suite, handle, default_flow_style=False)
8788

89+
if self.cleanup_directory and self.copy_benchmarks_dir:
90+
shutil.rmtree(self.working_copy)
91+
8892

8993
@dataclasses.dataclass
9094
class _Run:
@@ -95,6 +99,7 @@ class _Run:
9599
out_dir: str
96100
out_symlink: str
97101
copy_benchmarks_dir: bool
102+
cleanup_directory: bool
98103
result: dict = None
99104

100105
def __call__(self):
@@ -110,6 +115,7 @@ def __call__(self):
110115
suite_id, variant_id,
111116
parse, suite_yaml_out_dir=out_path,
112117
copy_benchmarks_dir=self.copy_benchmarks_dir,
118+
cleanup_directory=self.cleanup_directory,
113119
**config)
114120
invoke()
115121

@@ -137,6 +143,6 @@ def get_default_out_prefix():
137143
def main(args):
138144
run = _Run(
139145
args.config, args.out_prefix, args.out_dir, args.out_symlink,
140-
args.copy_benchmarks_dir)
146+
args.copy_benchmarks_dir, args.cleanup_directory)
141147
run()
142148
return run

0 commit comments

Comments
 (0)