Skip to content

Commit f7b41df

Browse files
committed
Make flag effect plots with runner_map work:
- When using a runner_map, force benchmark comparisons to be valid, since results from a different runner would otherwise not count. - Add version to flag effect plots so we don't end up comparing e.g. v3.14.0a7 and v3.13.10, which were created 15 minutes apart but do not make sense to compare even with a runner_map. - If a runner_map is used, don't plot runners that aren't listed in the runner_map.
1 parent aa2ac8c commit f7b41df

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ The flag effect plot shows the effect of specified configuration flags against a
169169
In `bench_runner.toml`, the `flag_effect_plot` table has a `subplots` key which is an array of tables with the following keys:
170170

171171
- `name`: The description of the flags to use in the title.
172+
- `version`: The version series to compare. Should be a 2-part version, e.g. "3.14"
172173
- `head_flags`: A list of flags to use as the head.
173174
- `base_flags`: (optional) A list of flags to use as the base. By default, this is a default build, i.e. no flags.
174175
- `runner_map`: (optional) If you need to map a runner to a base in a different runner, you can provide that mapping here. For example, with tail-calling, you may want to compare runners configured to use clang against runners configured with the "default compiler" for a given platform. The mapping is from the "head" runner nickname to the "base" runner nickname.
@@ -178,10 +179,12 @@ For example:
178179
```toml
179180
[[flag_effect_plot.subplots]]
180181
name = "JIT"
182+
version = "3.14"
181183
head_flags = ["JIT"]
182184

183185
[[flag_effect_plot.subplots]]
184186
name = "Tail calling interpreter"
187+
version = "3.14"
185188
head_flags = ["TAILCALL"]
186189
runner_map = { linux_clang = "linux" }
187190
```

bench_runner/plot.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def get_flag_effect_plot_config():
105105

106106
for subplot in subplots:
107107
assert "name" in subplot
108+
assert "version" in subplot
108109
assert "head_flags" in subplot
109110
subplot["head_flags"] = sorted(set(subplot["head_flags"]))
110111
if "base_flags" not in subplot:
@@ -428,12 +429,14 @@ def flag_effect_plot(
428429
print("No flag effect plot config found. Skipping.")
429430
return
430431

431-
def get_comparison_value(ref, r):
432+
def get_comparison_value(ref, r, force_valid):
432433
key = ",".join((str(ref.filename)[8:], str(r.filename)[8:]))
433434
if key in data:
434435
return data[key]
435436
else:
436-
value = getter(result.BenchmarkComparison(ref, r, "default"))
437+
value = getter(
438+
result.BenchmarkComparison(ref, r, "default", force_valid=force_valid)
439+
)
437440
data[key] = value
438441
return value
439442

@@ -464,8 +467,15 @@ def get_comparison_value(ref, r):
464467

465468
for subplot, ax in zip(subplots, axs):
466469
ax.set_title(f"Effect of {subplot['name']}")
470+
version = tuple(int(x) for x in subplot["version"].split("."))
471+
assert len(version) == 2, (
472+
"Version config in {subplot['name']}" " should only be major.minor"
473+
)
467474

468475
for runner in mrunners.get_runners():
476+
runner_is_mapped = runner.nickname in subplot["runner_map"]
477+
if subplot["runner_map"] and not runner_is_mapped:
478+
continue
469479
head_results = commits.get(runner.nickname, {}).get(
470480
tuple(subplot["head_flags"]), {}
471481
)
@@ -476,10 +486,14 @@ def get_comparison_value(ref, r):
476486
line = []
477487
for cpython_hash, r in head_results.items():
478488
if cpython_hash in base_results:
489+
if r.parsed_version.release[0:2] != version:
490+
continue
479491
line.append(
480492
(
481493
r.commit_datetime,
482-
get_comparison_value(base_results[cpython_hash], r),
494+
get_comparison_value(
495+
base_results[cpython_hash], r, runner_is_mapped
496+
),
483497
)
484498
)
485499
line.sort(key=lambda x: datetime.datetime.fromisoformat(x[0]))

0 commit comments

Comments
 (0)