Skip to content

Commit ccc2aa2

Browse files
authored
Merge pull request #445 from mdboom/fix-bisect
Fix the bisect command to not cache results
2 parents 099f774 + 8f0f1a0 commit ccc2aa2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

bench_runner/result.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def _load_contents(filename: Path) -> dict[str, Any]:
4040
return json.load(fd)
4141

4242

43+
def clear_contents_cache() -> None:
44+
_load_contents.cache_clear()
45+
46+
4347
def _clean(string: str) -> str:
4448
"""
4549
Clean an arbitrary string to be suitable for a filename.

bench_runner/scripts/bisect.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def parse_result(benchmark_json: PathLike) -> float:
4545
# The name of the benchmark in the JSON file may be different from the one
4646
# used to select the benchmark. Therefore, just take the mean of all the
4747
# benchmarks in the JSON file.
48+
result.clear_contents_cache()
4849
r = result.Result.from_arbitrary_filename(benchmark_json)
4950
timing_data = r.get_timing_data()
5051
return float(np.mean([x.mean() for x in timing_data.values()]))
@@ -123,6 +124,12 @@ def _main(
123124
bad_timing = get_result(benchmark, pgo, flags, cpython=cpython)
124125
log(f"KNOWN BAD ({bad[:7]}): {format_seconds(bad_timing)}")
125126

127+
if good_timing >= bad_timing:
128+
show_log()
129+
raise ValueError(
130+
f"Good timing ({good_timing}) must be less than bad timing ({bad_timing})."
131+
)
132+
126133
try:
127134
with contextlib.chdir(cpython):
128135
subprocess.run(["git", "bisect", "start"])

0 commit comments

Comments
 (0)