goochjs / glicko2

Java implementation of the Glicko-2 rating algorithm
BSD 2-Clause "Simplified" License
40 stars 16 forks source link

Calculation performance is slow at scale #4

Open ktschmidt opened 9 months ago

ktschmidt commented 9 months ago

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:

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 commented 9 months ago

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