Skip to content

perf(riichi): skip structurally impossible discard reactions#111

Closed
TypeThe0ry wants to merge 1 commit into
devfrom
codex/perf-riichi-reaction-gate
Closed

perf(riichi): skip structurally impossible discard reactions#111
TypeThe0ry wants to merge 1 commit into
devfrom
codex/perf-riichi-reaction-gate

Conversation

@TypeThe0ry

Copy link
Copy Markdown
Member

What changed

  • Caches normalized base-tile counts by hand version.
  • Checks pon, open-kan, and legal left-player chii structure before invoking the full shanten search.
  • Preserves the exact ron-only result when no structural call is possible.
  • Adds fixed-seed differential coverage against the original reaction path.

Why

Discard reactions were spending most CPU and allocation in furoChanceShanten even when the hand could not possibly pon, kan, or chii the discarded tile.

Impact

External APIs, event order, action availability, and ron behavior are unchanged. The fast path only skips a search after proving that no structural meld action exists.

Evidence

Paired JMH:

  • impossible-call path: about 98.8% lower time and effectively zero allocation
  • ron-only path: about 98.7% lower time and 99.4% lower allocation
  • possible-pon path remains within the allocation guardrail

Validation

  • RiichiReactionStructuralGateTest
  • spotlessCheck
  • full integration test suite passed before commit splitting

@Arbousier1
Arbousier1 force-pushed the codex/perf-riichi-reaction-gate branch from ef4d2e3 to aa4313f Compare July 18, 2026 12:56
@Arbousier1 Arbousier1 added performance-riichi-reaction Use the riichi discard reaction performance profile performance-ab Run the base-owned paired performance gate and removed performance-ab Run the base-owned paired performance gate performance-riichi-reaction Use the riichi discard reaction performance profile labels Jul 18, 2026
@Arbousier1

Copy link
Copy Markdown
Collaborator

Formal trusted A/B run did not pass: INCONCLUSIVE_NOISE_OR_NO_GAIN. Evidence: https://github.com/EllanServer/MahjongEngine/actions/runs/29645449549. Closing per the performance gate policy.

@Arbousier1 Arbousier1 closed this Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants