perf: compute standings tiebreaker values once and fix Buchholz complexity#7652
Open
Rathoz wants to merge 1 commit into
Open
perf: compute standings tiebreaker values once and fix Buchholz complexity#7652Rathoz wants to merge 1 commit into
Rathoz wants to merge 1 commit into
Conversation
…exity Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ec216eb to
a67a167
Compare
hjpalpha
reviewed
Jun 12, 2026
| return '-' | ||
| end | ||
| return MathUtil.formatPercentage(self:valueOf(state, opponent), 2) | ||
| return MathUtil.formatPercentage(value ~= nil and value or self:valueOf(state, opponent), 2) |
Collaborator
There was a problem hiding this comment.
value ~= nil and is redundant
| function TiebreakerMatchWinRate:display(state, opponent) | ||
| return MathUtil.formatPercentage(self:valueOf(state, opponent), 2) | ||
| function TiebreakerMatchWinRate:display(state, opponent, value) | ||
| return MathUtil.formatPercentage(value ~= nil and value or self:valueOf(state, opponent), 2) |
| if value == nil then | ||
| value = self:valueOf(state, opponent) | ||
| end | ||
| return tostring(value) |
Collaborator
There was a problem hiding this comment.
return tostring(value or self:valueOf(state, opponent))
plus kick the if above
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.
Summary
Two related cuts to tiebreaker computation cost during standings parsing:
StandingsParser.calculateTiebreakerValuescalled bothvalueOfanddisplay, and the defaultdisplaycallsvalueOfagain (and the diff/winrate overrides recomputed their stats).display(state, opponent, value)now receives the already-computed value; the default implementation and all overriding tiebreakers (Match/Diff,Match/WinRate,Game/Diff,Game/WinRate,Game/Rounds/Diff) use it instead of recomputing.resolveTieForGroupcontinues to use storedtiebreakerValues/valueOfas before.Opponent.samein the inner loops. It now builds the enemy list as a name set viaOpponent.toName(with anOpponent.samefallback for renamed-team cases coming from match2 records) and memoizes the result per opponent entry, mirroring theFnUtil.memoizepattern inTiebreaker/Game/Util.Stored
tiebreakerValuesand display strings are unchanged.Based on
standings-tests-ai(#7647), whose tiebreaker and parser specs lock the expected values and display output.How did you test this change?
busted --run=ci: 605 successes / 0 failures, includingstandings_tiebreaker_spec.lua(buchholz, matchdiff/gamediff/rounddiff display cases) andstandings_parser_spec.lua(tiebreakerValues assertions) unchangedluacheckwithlua/.luacheckrc: 0 warnings on all touched files🤖 Generated with Claude Code