[PR #1770] OLD-9776: scripts: measure the translator (us per instruction) and compare two tools/ trees #1783

Open
opened 2026-11-26 21:18:56 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1770
Author: @potatoe0100
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: carry/old-9776


📝 Commits (5)

  • 5ffdc50 scripts: a throughput benchmark for the translator (us per instruction)
  • 03a92ee scripts: --compare A B, interleaved timing of two tools/ trees
  • 4c70aea bench_translate: honour --max-slowdown in --json too, and let a run save its own baseline
  • 3bcb621 bench_translate: --compare honours --max-slowdown, and a partial baseline no longer aborts
  • f03dfe2 bench_translate: refuse flag combinations that were silently ignored, and require a baseline that exists

📊 Changes

2 files changed (+436 additions, -0 deletions)

View changed files

➕ scripts/bench_translate.py (+309 -0)
➕ tests/test_bench_translate.py (+127 -0)

📄 Description

Claimed in the coordination issue as: OLD-9776 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161510791)

What and why

Carries on old PR 9776 by @pes7 (draft #54, branch old-pr/9776, listed in #17), rebased on current main with the author's five commits kept.

The tests check what tools/rdna2spirv.py emits but nothing about how long it takes, so a change to the parser or the instruction table can slow a full shader build a lot and still pass. scripts/bench_translate.py times translate() on the hand-written semantic fixtures and on two generated straight-line programs (ALU work and s_nop dispatch), reports best-of-N microseconds per instruction, can compare two tools/ trees with interleaved timing (--compare A B), prints JSON, and can fail on --max-slowdown. Standard library only; no game data, LLVM or SPIRV-Tools. tests/test_bench_translate.py covers the options and error cases. Its baseline numbers are from one machine, so --baseline/--write-baseline let a run use its own.

Tested

  • python -I tests/test_bench_translate.py: 10 tests OK (Linux, Python 3.13; also OK on Windows 11, Python 3.14).
  • python -I scripts/bench_translate.py --runs 1 on current main's translator: runs, 52 fixtures timed, 54 compute/mesh listings skipped as designed (they need an FSSM header). Python 3.13, Linux.
  • python -m compileall -q scripts tests: clean.

GPUs tested: n/a (no GPU code)

AI-assisted: yes (Claude rebased and tested; the change is pes7's)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1770 **Author:** [@potatoe0100](https://github.com/potatoe0100) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/old-9776` --- ### 📝 Commits (5) - [`5ffdc50`](https://github.com/ubiquitarianism/leonida/commit/5ffdc50fed161ea04fd8086772a9e01b5271777e) scripts: a throughput benchmark for the translator (us per instruction) - [`03a92ee`](https://github.com/ubiquitarianism/leonida/commit/03a92eecd067805299935d747d4d60def54b97e6) scripts: --compare A B, interleaved timing of two tools/ trees - [`4c70aea`](https://github.com/ubiquitarianism/leonida/commit/4c70aeaf76942a02532a91f96e0f51ac20123d6d) bench_translate: honour --max-slowdown in --json too, and let a run save its own baseline - [`3bcb621`](https://github.com/ubiquitarianism/leonida/commit/3bcb6212a22afe78c85900dbd93d40f1c3554d70) bench_translate: --compare honours --max-slowdown, and a partial baseline no longer aborts - [`f03dfe2`](https://github.com/ubiquitarianism/leonida/commit/f03dfe23ae29c56bc705865367d4fa00b7100fa4) bench_translate: refuse flag combinations that were silently ignored, and require a baseline that exists ### 📊 Changes **2 files changed** (+436 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `scripts/bench_translate.py` (+309 -0) ➕ `tests/test_bench_translate.py` (+127 -0) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9776 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161510791) ### What and why Carries on old PR 9776 by @pes7 (draft #54, branch `old-pr/9776`, listed in #17), rebased on current `main` with the author's five commits kept. The tests check what `tools/rdna2spirv.py` emits but nothing about how long it takes, so a change to the parser or the instruction table can slow a full shader build a lot and still pass. `scripts/bench_translate.py` times `translate()` on the hand-written semantic fixtures and on two generated straight-line programs (ALU work and `s_nop` dispatch), reports best-of-N microseconds per instruction, can compare two `tools/` trees with interleaved timing (`--compare A B`), prints JSON, and can fail on `--max-slowdown`. Standard library only; no game data, LLVM or SPIRV-Tools. `tests/test_bench_translate.py` covers the options and error cases. Its baseline numbers are from one machine, so `--baseline`/`--write-baseline` let a run use its own. ### Tested - `python -I tests/test_bench_translate.py`: 10 tests OK (Linux, Python 3.13; also OK on Windows 11, Python 3.14). - `python -I scripts/bench_translate.py --runs 1` on current `main`'s translator: runs, 52 fixtures timed, 54 compute/mesh listings skipped as designed (they need an FSSM header). Python 3.13, Linux. - `python -m compileall -q scripts tests`: clean. GPUs tested: n/a (no GPU code) AI-assisted: yes (Claude rebased and tested; the change is pes7's) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1783
No description provided.