-
Notifications
You must be signed in to change notification settings - Fork 63
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
Optimize rating initialization #839
Optimize rating initialization #839
Conversation
Codecov Report
|
66a6afa
to
418b331
Compare
Determine if a player should see this game in their games list. | ||
|
||
Note: This is a *hot* function, it can have significant impacts on | ||
performance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it because of the rating initialization? It doesn't become clear, why this comment on performance is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s there because this is now the second time I’ve had to optimize something that was added to that function because it showed up in the profiler.
|
||
chained_ratings["global"] = (1000, 50) | ||
|
||
assert chained_ratings["tmm_2v2"] == chained_ratings["tmm_2v2"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a typo? How will this ever fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks that the rating is cached and not recomputed. If it were recomputed we would get different mock objects for the two calls.
418b331
to
d51f11f
Compare
This should significantly reduce calls to rating initialization code
d51f11f
to
4828ee3
Compare
I had a look at the server profile generated after the last update, and it looks like the rating initialization was being called an excessive amount. This is mostly because it gets invoked both when generating
game_info
as well asplayer_info
messages.In the
game_info
messages it would be called even if the rating data wasn't actually needed, just because it had been easier to write that ways. Now, it checks whether rating enforcement is enabled first and only queries the rating if it is. I also added some caching to the rating computation itself so that the queries generated by theplayer_info
message creation will now short circuit the majority of the time.