perf(gb): reuse adjacent discard preference on memo hit#69
Merged
Conversation
Arbousier1
force-pushed
the
codex/perf-gb-discard-preference-memo
branch
from
July 16, 2026 07:34
c5a1779 to
23ff27c
Compare
TypeThe0ry
marked this pull request as ready for review
July 16, 2026 08:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure performance scope
This PR changes only the GB bot discard preference lookup inside the existing per-index decision loop and adds focused behavior-preservation tests. It does not change the protected benchmark, thresholds, Gradle configuration, bot timing, scoring, evaluator order, or discard tie-breaking.
Candidate
After the previous ting memo optimization, an adjacent duplicate tile can reuse the same non-null ting response while still rescanning the entire hand for the same discard preference.
The candidate reuses only the immediately preceding preference when all of these invariants hold:
MahjongTileenum constant as the previous indexreadyScoreis still evaluated before the preference, preserving argument evaluation orderDiscardChoiceNull evaluator responses remain uncached and recompute at every index.
M5andM5_REDremain distinct; nosameKindcomparison is used. Equal candidates still retain the earliest index.Behavior coverage
Focused tests cover:
[M1, M1, M1]retaining the earliest index[M5, M5_RED, M5]preventing red-five preference reuse for the exact regular tileEvidence gate
No performance claim is made from source inspection or local execution. GitHub is the authoritative validator.
Required before merge recommendation:
gb-botA/A drift control passesIf the trusted decision is not
PASS_OPTIMIZED, this candidate will not be merged.