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

Restructuring rankings saving mechanism for better efficieincy and accessibility #1282

Open
farooqkz opened this issue Apr 10, 2024 · 2 comments
Assignees

Comments

@farooqkz
Copy link
Contributor

Currently the rankings are stored in Redis in a really bad manner. shangul is a stringified json. I propose to save rankings in a sorted set for more efficiency during lookups. Benefits include:

  • lookup of player by name/nick in constant time(O(1)) using ZSCORE
  • lookup of player by rank is also done in constant time
  • most other operations are O(log(n))

However the disadvantage exists that the current implementation does increasing score by O(1). But the current implementation has a very inefficient way of looking up a range. e.g. top100, bottom100(!) and so on.

@LoneWolfHT If I have your approval, I will start this transition with the rankings api on the test server.

@LoneWolfHT
Copy link
Member

Make sure to do this by creating a new ranking backend, don't overwrite anything redis, and let me know if the code on top of the backends needs changing

@farooqkz farooqkz self-assigned this Apr 11, 2024
@savilli
Copy link
Contributor

savilli commented Apr 14, 2024

the current implementation has a very inefficient way of looking up a range

That's not exactly true. We already have a sorted set at home - ctf_rankings/top.lua file. All rank lookup operations use it and don't make requests to redis.

lookup of player by rank is also done in constant time

I'm sure it's O(log(n)). In practice the difference between O(1) and O(log(n)) is negligible tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants