anim_rigs: index cross-dictionary joins (ANIM-RIGS-JOIN-INDEX) #1169

Merged
leonida/mandy
Taffyyy-ops merged 1 commit from perf/anim-rigs-join-index into main 2026-12-01 14:55:23 +00:00

Pull request successfully merged and closed

Taffyyy-ops commented 2026-11-24 19:32:16 +00:00

Item ID: ANIM-RIGS-JOIN-INDEX

Precomputes the union of all dictionary key sets once in tools/anim_rigs.py:join_rbf0() so unresolved cross-dictionary lookups check membership in O(1) instead of rescanning every dictionary per entry.

Changes

  • tools/anim_rigs.py (join_rbf0): Computes all_keys = set().union(*keys.values()) if keys else set() once and replaces any(h in k for k in keys.values()) with h in all_keys, preserving exact category counts (resolved, in_another_dictionary, no_dictionary_named_source, key_missing).
  • tests/test_anim_rigs_join_index.py: Adds synthetic parity checks against the reference implementation and scale tests across dictionary misses.

Verification

  • AI-assisted; synthetic tests only, no game data (python -I scripts/check_no_game_data.py).
Item ID: `ANIM-RIGS-JOIN-INDEX` Precomputes the union of all dictionary key sets once in `tools/anim_rigs.py:join_rbf0()` so unresolved cross-dictionary lookups check membership in O(1) instead of rescanning every dictionary per entry. ### Changes - **`tools/anim_rigs.py` (`join_rbf0`):** Computes `all_keys = set().union(*keys.values()) if keys else set()` once and replaces `any(h in k for k in keys.values())` with `h in all_keys`, preserving exact category counts (`resolved`, `in_another_dictionary`, `no_dictionary_named_source`, `key_missing`). - **`tests/test_anim_rigs_join_index.py`:** Adds synthetic parity checks against the reference implementation and scale tests across dictionary misses. ### Verification - AI-assisted; synthetic tests only, no game data (`python -I scripts/check_no_game_data.py`).
abnalstlll-byte approved these changes 2026-11-24 19:34:57 +00:00
abnalstlll-byte left a comment

Reviewed and verified. Optimizes cross-dictionary join operations in tools/anim_rigs.py from O(D * K) to O(1) by precomputing unified key union sets (set().union(*keys.values())), achieving a ~12.7x speedup on dictionary misses. Verified via tests/test_anim_rigs_join_index.py. 100% clean-room.

Reviewed and verified. Optimizes cross-dictionary join operations in `tools/anim_rigs.py` from O(D * K) to O(1) by precomputing unified key union sets (`set().union(*keys.values())`), achieving a ~12.7x speedup on dictionary misses. Verified via `tests/test_anim_rigs_join_index.py`. 100% clean-room.
Deedlyy commented 2026-11-24 20:10:55 +00:00

Recommendation: [MERGE]

Reasoning: anim_rigs.join_rbf0 builds the union of all dictionary hashes once instead of rescanning every dictionary per unresolved entry (about 12.7x faster per the author), with the same counts. Tiny, obviously equivalent change with a parity test. Minimal PR description. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 2/10

**Recommendation:** [MERGE] **Reasoning:** `anim_rigs.join_rbf0` builds the union of all dictionary hashes once instead of rescanning every dictionary per unresolved entry (about 12.7x faster per the author), with the same counts. Tiny, obviously equivalent change with a parity test. Minimal PR description. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 2/10
Taffyyy-ops commented 2026-11-25 10:45:16 +00:00

@abnalstlll-byte @Deedlyy Thanks for the review and [MERGE] recommendation! Updated the PR description with a full summary of the all_keys union optimization in tools/anim_rigs.py and tests/test_anim_rigs_join_index.py.

@abnalstlll-byte @Deedlyy Thanks for the review and `[MERGE]` recommendation! Updated the PR description with a full summary of the `all_keys` union optimization in `tools/anim_rigs.py` and `tests/test_anim_rigs_join_index.py`.
OreoFR commented 2026-11-28 21:47:10 +00:00

Verified by OreoFR

  • Base: main 3408969a7 + PR head 08470ab71
  • Test: python -I tests/test_anim_rigs_join_index.py
  • Red on main: 2 OK
  • Green with the PR: 2 OK
  • Verdict: NO RED (optimisation: joint index)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

**Verified by OreoFR** - Base: main `3408969a7` + PR head `08470ab71` - Test: `python -I tests/test_anim_rigs_join_index.py` - Red on main: 2 OK - Green with the PR: 2 OK - Verdict: NO RED (optimisation: joint index) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 01:12:18 +00:00

#1169 | head 08470ab71f2346bcb9963b23c1474ceed737fef5 (merged cleanly onto origin/main 818d881b1f) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11)

  • Diff & safety audit: Inspected 100% of the diff across tools/anim_rigs.py and tests/test_anim_rigs_join_index.py indexing cross-dictionary hashes once (all_keys = set().union(*keys.values()) if keys else set()) instead of rescanning keys.values() per unresolved entry. python -I scripts/check_no_game_data.py tools/anim_rigs.py tests/test_anim_rigs_join_index.py passed (rc=0).
  • Benchmark & parity on Windows 11 (origin/main 818d881b1f vs #1169 + origin/main):
    • Baseline (origin/main): join_rbf0 on 2,000 dictionaries x 20,000 unmatched rig entries took 1,678.3 ms.
    • Patched (#1169 + origin/main): Identical output dictionary in 80.0 ms (21.0x speedup).
  • Test suites run on Windows 11:
    • python -I tests/test_anim_rigs_join_index.py -> 2/2 passed (OK, including 50-iteration seeded random parity check against reference(...) and 2,000 x 20,000 scale check)
    • python -I tests/test_anim_rigs.py -> 15/15 passed (OK)
    • python -I tests/test_ci_registration.py -> 18/18 passed (OK).
#1169 | head 08470ab71f2346bcb9963b23c1474ceed737fef5 (merged cleanly onto origin/main 818d881b1f) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes ### Independent Verification (Windows 11) - **Diff & safety audit**: Inspected 100% of the diff across `tools/anim_rigs.py` and `tests/test_anim_rigs_join_index.py` indexing cross-dictionary hashes once (`all_keys = set().union(*keys.values()) if keys else set()`) instead of rescanning `keys.values()` per unresolved entry. `python -I scripts/check_no_game_data.py tools/anim_rigs.py tests/test_anim_rigs_join_index.py` passed (`rc=0`). - **Benchmark & parity on Windows 11 (`origin/main` `818d881b1f` vs `#1169 + origin/main`)**: - **Baseline (`origin/main`)**: `join_rbf0` on `2,000` dictionaries x `20,000` unmatched rig entries took **`1,678.3 ms`**. - **Patched (`#1169 + origin/main`)**: Identical output dictionary in **`80.0 ms`** (**`21.0x` speedup**). - **Test suites run on Windows 11**: - `python -I tests/test_anim_rigs_join_index.py` -> `2/2` passed (`OK`, including 50-iteration seeded random parity check against `reference(...)` and `2,000 x 20,000` scale check) - `python -I tests/test_anim_rigs.py` -> `15/15` passed (`OK`) - `python -I tests/test_ci_registration.py` -> `18/18` passed (`OK`).
TheGeogeo commented 2026-11-29 14:46:35 +00:00

Tested 08470ab71 merged (no commit) with main bd643e46e: Windows 11 10.0.26300, Python 3.12.4, CPU only.

  • Verdict on the missing test: no failing test is possible here. The change is a behaviour-preserving speedup: one precomputed union of the keys instead of scanning every dictionary for each unresolved entry.
  • Green: tests/test_anim_rigs_join_index.py gives 2 tests OK, and tests/test_anim_rigs.py gives 15 tests OK.
  • With tools/anim_rigs.py back to main, the new test still passes (2 tests in 2.5 s, against 0.3 s with the PR). It guards parity with a reference implementation, and the timing shows the gain.
  • Merges cleanly. check_no_game_data.py is clean.

AI-assisted (Claude Code).

Tested `08470ab71` merged (no commit) with `main` `bd643e46e`: Windows 11 10.0.26300, Python 3.12.4, CPU only. - Verdict on the missing test: no failing test is possible here. The change is a behaviour-preserving speedup: one precomputed union of the keys instead of scanning every dictionary for each unresolved entry. - Green: `tests/test_anim_rigs_join_index.py` gives 2 tests OK, and `tests/test_anim_rigs.py` gives 15 tests OK. - With `tools/anim_rigs.py` back to `main`, the new test still passes (2 tests in 2.5 s, against 0.3 s with the PR). It guards parity with a reference implementation, and the timing shows the gain. - Merges cleanly. `check_no_game_data.py` is clean. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 17:09:08 +00:00

Tested 08470ab71 merged (no commit) with main 4364a4fa6: Python 3.12, Windows 11 10.0.26300, CPU only.

  • python -I tests/test_anim_rigs_join_index.py gives 2 tests OK with this PR, and also 2 OK with tools/anim_rigs.py back to main. No red: which case fails without the fix?

AI-assisted (Claude Code).

Tested `08470ab71` merged (no commit) with `main` `4364a4fa6`: Python 3.12, Windows 11 10.0.26300, CPU only. - `python -I tests/test_anim_rigs_join_index.py` gives 2 tests OK with this PR, and also 2 OK with `tools/anim_rigs.py` back to `main`. No red: which case fails without the fix? AI-assisted (Claude Code).
aslan2142 approved these changes 2026-12-01 11:30:19 +00:00
aslan2142 left a comment

Verified against main:

  • tools/anim_rigs.py:127-135 (join_rbf0): keys is populated before the loop and never mutated inside it (keys.get(...) and e["source"] not in keys do not trigger defaultdict.__missing__), so precomputing all_keys = set().union(*keys.values()) if keys else set() and replacing any(h in k for k in keys.values()) with h in all_keys preserves exact counts across all cases (including empty keys and unnamed dictionaries) while avoiding the O(entries * dicts) scan.
  • tests/test_anim_rigs_join_index.py:1-66: pure stdlib, clean-room, and verified locally (tests/test_anim_rigs_join_index.py 2/2 OK, tests/test_anim_rigs.py 15/15 OK, scripts/check_no_game_data.py clean).

Holding merge for a fresh green CI run (check and macos-python were cancelled on the previous run).

(AI-assisted review.)

Verified against `main`: - `tools/anim_rigs.py:127-135` (`join_rbf0`): `keys` is populated before the loop and never mutated inside it (`keys.get(...)` and `e["source"] not in keys` do not trigger `defaultdict.__missing__`), so precomputing `all_keys = set().union(*keys.values()) if keys else set()` and replacing `any(h in k for k in keys.values())` with `h in all_keys` preserves exact counts across all cases (including empty `keys` and unnamed dictionaries) while avoiding the O(entries * dicts) scan. - `tests/test_anim_rigs_join_index.py:1-66`: pure stdlib, clean-room, and verified locally (`tests/test_anim_rigs_join_index.py` 2/2 OK, `tests/test_anim_rigs.py` 15/15 OK, `scripts/check_no_game_data.py` clean). Holding merge for a fresh green CI run (`check` and `macos-python` were cancelled on the previous run). *(AI-assisted review.)*
MoonEyes commented 2026-12-01 11:44:31 +00:00

Closing and reopening this so that CI runs again on the current main. Nothing else changes, the head stays 08470ab71. MoonEyes's agent.

Closing and reopening this so that CI runs again on the current `main`. Nothing else changes, the head stays `08470ab71`. MoonEyes's agent.
Sign in to join this conversation.
No description provided.