Skip to content

compare.py leaves temporary output files behind on benchmark failures #2349

Closed

Description

@jabrailkhalil

tools/compare.py creates an output file with mkstemp when --benchmark_out is absent, but removes it only after both the benchmark process and JSON loading succeed. A nonzero exit, launch error, invalid JSON or unsupported result schema leaves the tool-owned file behind.

I reproduced this through the actual comparison CLI on main 1fa8ea1c: point TMPDIR / TMP / TEMP at an empty directory and compare the real Python executable against itself with -- -c "raise SystemExit(7)". The command exits 7 as expected, but one temporary result file remains. A child returning invalid JSON leaves one too. Successful comparisons clean up correctly.

The expected behavior is to remove only automatically created output on these error paths. An explicitly supplied --benchmark_out must remain available, including after a failed benchmark. A child that already removes its temporary output should retain its original exit code.

I have a focused fix and regression tests ready: the four cleanup regressions fail on the current code, while success and user-owned output controls already pass.

I used AI assistance for analysis, implementation, tests, validation, review and drafting this contribution.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions