Skip to content

Commit

Permalink
Clean up benchmark directories after building (rust-lang#2583)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
karkhaz authored Jul 10, 2023
1 parent ca66814 commit bb53ec2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tools/benchcomp/benchcomp/cmd_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ def _get_args_dict():
"help":
"do not make a fresh copy of the benchmark "
"directories before running each variant",
}, {
"flags": ["--keep-temps"],
"action": "store_false",
"dest": "cleanup_directory",
"help":
"do not delete fresh copies of benchmark "
"directories after running each variant",
}],
},
"collate": {
Expand Down
8 changes: 7 additions & 1 deletion tools/benchcomp/benchcomp/entry/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class _SingleInvocation:
command_line: str
directory: pathlib.Path

cleanup_directory: bool
env: dict = dataclasses.field(default_factory=dict)
timeout: int = None
memout: int = None
Expand Down Expand Up @@ -85,6 +86,9 @@ def __call__(self):
encoding="utf-8") as handle:
yaml.dump(suite, handle, default_flow_style=False)

if self.cleanup_directory and self.copy_benchmarks_dir:
shutil.rmtree(self.working_copy)


@dataclasses.dataclass
class _Run:
Expand All @@ -95,6 +99,7 @@ class _Run:
out_dir: str
out_symlink: str
copy_benchmarks_dir: bool
cleanup_directory: bool
result: dict = None

def __call__(self):
Expand All @@ -110,6 +115,7 @@ def __call__(self):
suite_id, variant_id,
parse, suite_yaml_out_dir=out_path,
copy_benchmarks_dir=self.copy_benchmarks_dir,
cleanup_directory=self.cleanup_directory,
**config)
invoke()

Expand Down Expand Up @@ -137,6 +143,6 @@ def get_default_out_prefix():
def main(args):
run = _Run(
args.config, args.out_prefix, args.out_dir, args.out_symlink,
args.copy_benchmarks_dir)
args.copy_benchmarks_dir, args.cleanup_directory)
run()
return run

0 comments on commit bb53ec2

Please sign in to comment.