Skip to content

perf: skip achievement metric recounts for live player count updates#4860

Open
wescopeland wants to merge 1 commit intoRetroAchievements:masterfrom
wescopeland:ach-recount-perf
Open

perf: skip achievement metric recounts for live player count updates#4860
wescopeland wants to merge 1 commit intoRetroAchievements:masterfrom
wescopeland:ach-recount-perf

Conversation

@wescopeland
Copy link
Copy Markdown
Member

Addresses RAWEB-1QM.

When a player's unlock count for a game becomes non-zero, we do two different jobs worth of work:

  1. We update the game's player count. "The game now has 80,001 players instead of 80,000."
  2. We recount the stats for every achievement on the game's set from scratch. "For achievement X, count all unlocks. For achievement Y, count all unlocks. For achievement Z... etc".

That second step is the slow player_achievements GROUP BY achievement_id query from RAWEB-1QM.

This PR makes a minor adjustment: for these player count driven cascades, we'll no longer recount every achievement's unlock totals. Instead, we'll use the unlock totals already cached on each achievement's row and just recompute the unlock percentage, unlock hardcore percentage, and weighted points.

In other words, this PR introduces a "fast track" path for when only the player count changes. The "slow track" path (current behavior) is still present for:

  • achievements promoted / demoted
  • achievement transfers
  • resets
  • players getting untracked / retracked

@wescopeland wescopeland requested a review from a team May 6, 2026 23:10
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.

1 participant