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

Calculation performance is slow at scale #4

Open
ktschmidt opened this issue Jan 2, 2024 · 1 comment
Open

Calculation performance is slow at scale #4

ktschmidt opened this issue Jan 2, 2024 · 1 comment

Comments

@ktschmidt
Copy link

When calculating ratings for 10s or 100s of results in a rating period, performance is acceptable, but if there are thousands or more, some issues in the implementation can cause the updateRatings method to perform very slowly.

A few issues are:

  • getResults(player) iterates over the whole list of results to get the filtered list, when there are a lot of results this can be slow
  • There are two separate calls to getResults(player), one to check if empty then another to get the list to iterate over
  • The above is done N times, once for each player

The result is a 2N^2 number of executions which gets really slow.

The participants is also semi-dynamic in that it iterates over all the results to make sure all players are populated.

The second issue isn't that severe, one solution would be to update the participants set as results are added, which isn't really different than iterating over the results once, but as written calling getParticipants twice will iterate every time.

The first issue is the severe one and could be solved by keeping a list of results for each player in a map so it can simply be retrieved and not dynamically determined.

@ktschmidt
Copy link
Author

If there is interest in fixing these issues, I can create a PR, let me know.

ktschmidt pushed a commit to ktschmidt/glicko2 that referenced this issue Jan 3, 2024
ktschmidt pushed a commit to ktschmidt/glicko2 that referenced this issue Jan 3, 2024
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

No branches or pull requests

1 participant