[PR #1996] [MERGED] parity: choose harnesses faster (shared parse cache, early stop, time budget); skip the prepare_output check before #1947 #3924

Closed
opened 2026-11-03 04:13:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1996
Author: @ludovic111
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: perf/reach-planning


📝 Commits (2)

  • 7b01921 parity: choose harnesses faster (shared parse cache, early stop, time budget)
  • 886ecd9 Merge remote-tracking branch 'origin/main' into perf/reach-planning

📊 Changes

5 files changed (+154 additions, -92 deletions)

View changed files

📝 .github/workflows/parity.yml (+8 -1)
📝 docs/parity-workflow.md (+1 -1)
📝 tests/test_parity_reach.py (+10 -0)
📝 tools/parity.py (+31 -10)
📝 tools/parity_reach.py (+104 -80)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

Follow-up to #1964, after contrib-gate-16's pr_ready.py hung 14+ min in planning on a 17-file diff.

Why it hung: pr_ready.py called parity.affected_harnesses() inside a generator, once per harness (343 full plannings). #1991 already fixes that call. This PR makes each planning cheaper and bounded:

  • Shared parse cache: reach-cache.json moves to the shared parity folder (beside passes/). It is keyed by content, so a fresh worktree starts warm. Writes are atomic, and other worktrees' entries are kept within bounds.
  • Early stop: a harness's reach search ends as soon as it reaches a changed file that differs in more than its mod declarations. Such a file counts once reached, whatever else is reached. A partial search is never memoized. Declaration diffs are memoized (one git show per file, not per harness).
  • Shortcut: a harness whose changed dependency is outside crates/ (its script, a Java oracle) is picked without any search, since narrowing always keeps those.
  • Time budget: after PARITY_REACH_BUDGET seconds (default 180), the remaining harnesses count every source their probes link (the old rule). Choosing never holds a slow machine for long.
  • crate_of is cached, and pathlib is gone from the hot paths.

The 343 of 343 on main cc7534341 is not reach. That checkout (~/code/horizon) has no .local/minecraft link, so SHARED points to a missing folder: no dependency templates and no recorded state. Every harness counts as "nothing recorded yet" and is picked. In a worktree linked to the shared data, the same 19 paths pick 79.

Also in this PR (orchestrator's request): parity.yml with heads made before #1947. The job runs main's workflow file (from the PR's merge ref) on the head's checked-out files. A head made before #1947 has neither tools/prepare_output.py nor OUTPUT_VERSION, so the "prepared output" step is skipped for it with a message. The failures tonight in "Vanilla data, and resources prepared by this preparer" (#1790, #1809, #1896...) were a different cause: real .local/horizon-client* folders left by a failed preparation. #1994 (merged) fixed those. parity-main (#1981) runs main and isn't affected.

Before / after

contrib-gate-16's 19 paths (--changed-files ... --list), fresh worktree, Mac mini at ~90% CPU from other sessions. Wall time is dominated by the load, so CPU time is the fair number:

CPU (user) Wall Picked
main, cold cache 19.9 s 132 s 79
main, warm cache 16.6 s 93 s 79
this PR, cold (empty shared cache) 13.1 s 83 s 79
this PR, warm (any worktree after the first) 9.9 s 46 s 79

The same 79 harnesses are picked: the selection is identical by diff.

Self-check

  • python3 -m unittest tests.test_parity_reach tests.test_parity_runner: all pass except OracleReuseTests.test_reuses_until_an_input_or_output_changes, which fails the same way on main on this machine. The new test covers a stopped search: it keeps the stop file and is not memoized, and a stop file outside the harness's sources doesn't stop its search.
  • parity.yml parses. Pre-#1947 head f36a27876: OUTPUT_VERSION count 0, so the step is skipped; current main: 3, so it runs.

🤖 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/horizon-rust/horizon/pull/1996 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/reach-planning` --- ### 📝 Commits (2) - [`7b01921`](https://github.com/horizon-rust/horizon/commit/7b0192118e8a4e23cfc209d0ae7b2710824a993c) parity: choose harnesses faster (shared parse cache, early stop, time budget) - [`886ecd9`](https://github.com/horizon-rust/horizon/commit/886ecd9b20ef716a98e0d4734d3893acffbb5d1a) Merge remote-tracking branch 'origin/main' into perf/reach-planning ### 📊 Changes **5 files changed** (+154 additions, -92 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/parity.yml` (+8 -1) 📝 `docs/parity-workflow.md` (+1 -1) 📝 `tests/test_parity_reach.py` (+10 -0) 📝 `tools/parity.py` (+31 -10) 📝 `tools/parity_reach.py` (+104 -80) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Follow-up to #1964, after contrib-gate-16's `pr_ready.py` hung 14+ min in planning on a 17-file diff. **Why it hung:** `pr_ready.py` called `parity.affected_harnesses()` inside a generator, once per harness (343 full plannings). #1991 already fixes that call. This PR makes each planning cheaper and bounded: - **Shared parse cache:** `reach-cache.json` moves to the shared parity folder (beside `passes/`). It is keyed by content, so a fresh worktree starts warm. Writes are atomic, and other worktrees' entries are kept within bounds. - **Early stop:** a harness's reach search ends as soon as it reaches a changed file that differs in more than its `mod` declarations. Such a file counts once reached, whatever else is reached. A partial search is never memoized. Declaration diffs are memoized (one `git show` per file, not per harness). - **Shortcut:** a harness whose changed dependency is outside `crates/` (its script, a Java oracle) is picked without any search, since narrowing always keeps those. - **Time budget:** after `PARITY_REACH_BUDGET` seconds (default 180), the remaining harnesses count every source their probes link (the old rule). Choosing never holds a slow machine for long. - `crate_of` is cached, and pathlib is gone from the hot paths. **The 343 of 343** on main `cc7534341` is not reach. That checkout (`~/code/horizon`) has no `.local/minecraft` link, so `SHARED` points to a missing folder: no dependency templates and no recorded state. Every harness counts as "nothing recorded yet" and is picked. In a worktree linked to the shared data, the same 19 paths pick 79. **Also in this PR (orchestrator's request): `parity.yml` with heads made before #1947.** The job runs main's workflow file (from the PR's merge ref) on the head's checked-out files. A head made before #1947 has neither `tools/prepare_output.py` nor `OUTPUT_VERSION`, so the "prepared output" step is skipped for it with a message. The failures tonight in "Vanilla data, and resources prepared by this preparer" (#1790, #1809, #1896...) were a different cause: real `.local/horizon-client*` folders left by a failed preparation. #1994 (merged) fixed those. parity-main (#1981) runs main and isn't affected. ## Before / after contrib-gate-16's 19 paths (`--changed-files ... --list`), fresh worktree, Mac mini at ~90% CPU from other sessions. Wall time is dominated by the load, so CPU time is the fair number: | | CPU (user) | Wall | Picked | | --- | --- | --- | --- | | main, cold cache | 19.9 s | 132 s | 79 | | main, warm cache | 16.6 s | 93 s | 79 | | this PR, cold (empty shared cache) | 13.1 s | 83 s | 79 | | this PR, warm (any worktree after the first) | 9.9 s | 46 s | 79 | The same 79 harnesses are picked: the selection is identical by diff. ## Self-check - `python3 -m unittest tests.test_parity_reach tests.test_parity_runner`: all pass except `OracleReuseTests.test_reuses_until_an_input_or_output_changes`, which fails the same way on main on this machine. The new test covers a stopped search: it keeps the stop file and is not memoized, and a stop file outside the harness's sources doesn't stop its search. - `parity.yml` parses. Pre-#1947 head f36a27876: `OUTPUT_VERSION` count 0, so the step is skipped; current main: 3, so it runs. 🤖 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>
bsakaguchi 2026-11-03 04:13:17 +07:00
Sign in to join this conversation.
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
horizon-rust/horizon#3924
No description provided.