Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: aggressively cache getUsersCompletedGamesAndMax #1722

Merged

Conversation

wescopeland
Copy link
Member

@wescopeland wescopeland commented Aug 7, 2023

This PR adds caching to the Awarded data retrieved from the getUsersCompletedGamesAndMax() call on user profiles.

The cache is populated on page load, and busted when the user unlocks an achievement or resets progress.

If cached data is present, a lightweight query runs instead and the cached data is merged onto the lightweight fetch results.

Benchmarks

These benchmarks are taken with the local MySQL cache disabled.

User: televandalist

Before After
1 421ms 11ms
2 410ms 10ms
3 432ms 10ms
4 423ms 11ms
5 425ms 11ms
Average 422ms 11ms

Speedup Factor: ~38x


User: CobaltZeroni

Before After
1 483ms 31ms
2 493ms 31ms
3 619ms 29ms
4 601ms 32ms
5 512ms 53ms
Average 542ms 35ms

Speedup Factor: ~15x

@wescopeland wescopeland requested a review from a team August 7, 2023 20:38
@luchaos luchaos merged commit 87dfd75 into RetroAchievements:master Aug 8, 2023
5 checks passed
@wescopeland wescopeland deleted the cache-user-profile-awarded-data branch August 8, 2023 11:21
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