Skip to content

perf(sichuan): reuse ordinal hand counts#112

Closed
TypeThe0ry wants to merge 1 commit into
devfrom
codex/perf-sichuan-ordinal-counts
Closed

perf(sichuan): reuse ordinal hand counts#112
TypeThe0ry wants to merge 1 commit into
devfrom
codex/perf-sichuan-ordinal-counts

Conversation

@TypeThe0ry

Copy link
Copy Markdown
Member

What changed

  • Replaces tile-name parsing with MahjongTile.ordinal() lookup tables.
  • Builds one 27-entry count array and increments/decrements candidates in place.
  • Uses count-based recursion for waiting-tile checks.
  • Retains the existing complete shape construction, ordering, fixed-meld handling, and red-five normalization.

Why

The Sichuan evaluator repeatedly parsed tile names and rebuilt collections for every waiting-tile candidate.

Impact

Waiting-tile order and complete winning shapes remain byte-for-byte compatible in differential tests. No public API or rules behavior changes.

Evidence

Paired JMH median reductions:

  • canWin: about 48.9% time and 76.8% allocation
  • evaluate: about 52.4% time and 56.1% allocation
  • waitingTiles: about 78.3% time and 97.2% allocation

Validation

  • SichuanHuEvaluatorTest, including randomized legal hands and fixed melds
  • spotlessCheck
  • full integration test suite passed before commit splitting

@Arbousier1
Arbousier1 force-pushed the codex/perf-sichuan-ordinal-counts branch from 731b9c4 to d02e837 Compare July 18, 2026 12:56
@Arbousier1 Arbousier1 added performance-sichuan-hu Use the Sichuan hand evaluation performance profile performance-ab Run the base-owned paired performance gate and removed performance-ab Run the base-owned paired performance gate performance-sichuan-hu Use the Sichuan hand evaluation 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/29645450524. 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