Skip to content

Commit 8d5bd09

Browse files
committed
fix: update benchmark scripts for DU-based metrics
Benchmark output changed from per-instruction to per-dispatch-unit: ns_per_insn → ns_per_du, handler_ns → delta_ns, insn_count → du_count, ips → du_per_sec, --insns → --dus Scripts accept both old and new field names for backward compatibility.
1 parent 02bde9f commit 8d5bd09

3 files changed

Lines changed: 26 additions & 20 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
# ── Run benchmark ──
103103
- name: Run benchmark
104104
shell: bash
105-
run: ${{ matrix.bin }} --iterations=11 --insns=500 --policy=debug > bench_raw.json
105+
run: ${{ matrix.bin }} --iterations=11 --dus=125 --policy=debug > bench_raw.json
106106

107107
# ── Upload raw result ──
108108
- name: Upload raw JSON

scripts/bench_compare.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def render_markdown(current: dict, baseline: dict | None, platform: str) -> str:
4646

4747
lines.append(f"### {platform}")
4848
lines.append(f"")
49-
lines.append(f"| Opcode | Cat | ns/insn | handler ns | delta |")
50-
lines.append(f"|--------|-----|--------:|-----------:|------:|")
49+
lines.append(f"| Opcode | Cat | ns/DU | delta ns | vs base |")
50+
lines.append(f"|--------|-----|------:|--------:|--------:|")
5151

5252
# Group by category
5353
from collections import defaultdict
@@ -57,17 +57,18 @@ def render_markdown(current: dict, baseline: dict | None, platform: str) -> str:
5757

5858
for cat_id in sorted(cats.keys()):
5959
for name, r in cats[cat_id]:
60-
ns = r["ns_per_insn"]
61-
hns = r["handler_ns"]
60+
ns = r.get("ns_per_du", r.get("ns_per_insn", 0))
61+
hns = r.get("delta_ns", r.get("handler_ns", 0))
6262
d = ""
6363
if name in base:
64-
d = delta_str(ns, base[name]["ns_per_insn"])
64+
base_ns = base[name].get("ns_per_du", base[name].get("ns_per_insn", 0))
65+
d = delta_str(ns, base_ns)
6566
cat = CAT_NAMES.get(cat_id, "?")
6667
lines.append(f"| `{name}` | {cat} | {ns:.1f} | {hns:+.1f} | {d} |")
6768

68-
bl = current.get("baseline_ns_per_insn", 0)
69+
bl = current.get("baseline_ns_per_du", current.get("baseline_ns_per_insn", 0))
6970
lines.append(f"")
70-
lines.append(f"_Pipeline baseline (NOP): {bl:.1f} ns/insn "
71+
lines.append(f"_Pipeline baseline (NOP): {bl:.1f} ns/DU "
7172
f"| Policy: {meta.get('policy','?')} "
7273
f"| Build: {meta.get('build_type','?')}_")
7374
return "\n".join(lines)

scripts/bench_to_chart.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,39 @@
1515
def convert(raw: dict) -> list:
1616
"""Convert our benchmark JSON to github-action-benchmark format."""
1717
entries = []
18-
baseline = raw.get("baseline_ns_per_insn", 0)
18+
baseline = raw.get("baseline_ns_per_du",
19+
raw.get("baseline_ns_per_insn", 0))
1920

2021
for r in raw.get("results", []):
2122
name = r["opcode"]
2223

23-
# ns_per_insn — total pipeline cost (smaller is better)
24+
# ns_per_du — total pipeline cost per dispatch unit (smaller is better)
25+
ns_per = r.get("ns_per_du", r.get("ns_per_insn", 0))
26+
du_count = r.get("du_count", r.get("insn_count", 0))
2427
entries.append({
2528
"name": f"{name} (total)",
26-
"unit": "ns/insn",
27-
"value": round(r["ns_per_insn"], 2),
29+
"unit": "ns/DU",
30+
"value": round(ns_per, 2),
2831
"extra": f"median={r['median_ns']}ns p95={r['p95_ns']}ns "
2932
f"stddev={r['stddev_ns']:.1f}ns "
30-
f"iterations={r['iterations']} insns={r['insn_count']}",
33+
f"iterations={r['iterations']} DUs={du_count}",
3134
})
3235

33-
# handler_ns — handler overhead above baseline (smaller is better)
36+
# delta_ns — handler overhead above baseline (smaller is better)
37+
delta = r.get("delta_ns", r.get("handler_ns", ns_per - baseline))
3438
entries.append({
3539
"name": f"{name} (handler)",
3640
"unit": "ns",
37-
"value": round(r.get("handler_ns", r["ns_per_insn"] - baseline), 2),
41+
"value": round(delta, 2),
3842
})
3943

40-
# IPS — throughput (bigger is better, separate chart group)
41-
if r.get("ips", 0) > 0:
44+
# du_per_sec — throughput (bigger is better, separate chart group)
45+
throughput = r.get("du_per_sec", r.get("ips", 0))
46+
if throughput > 0:
4247
entries.append({
43-
"name": f"{name} (IPS)",
44-
"unit": "insn/s",
45-
"value": round(r["ips"]),
48+
"name": f"{name} (DU/s)",
49+
"unit": "DU/s",
50+
"value": round(throughput),
4651
})
4752

4853
return entries

0 commit comments

Comments
 (0)