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

Add metrics for certain data structure sizes #609

Open
Askaholic opened this issue Jun 20, 2020 · 3 comments · May be fixed by #887
Open

Add metrics for certain data structure sizes #609

Askaholic opened this issue Jun 20, 2020 · 3 comments · May be fixed by #887

Comments

@Askaholic
Copy link
Collaborator

There are some dictionaries that hold strong references to their values which we should post some metrics about to make sure they aren't growing without bound. Mostly I want to know "how many elements are in the dictionary".

self.searches: Dict[str, Dict[Player, Search]] = defaultdict(dict)

self._players = dict()

self._games: Dict[int, Game] = dict()

self.queue: Dict[Search, Search] = OrderedDict()

@46bit
Copy link
Contributor

46bit commented Aug 28, 2020

@cleborys noticed:

  • The size of PlayerService._players is already monitored by server_user_online
  • The size of GameService._games is equal to the sum over all server_game_active_games_total labels

@cleborys
Copy link
Member

To collect thoughts from @46bit's PR for the future:

I believe MatchmakerQueue.queue should be updated here:

with MatchmakerSearchTimer(self.name):
self.push(search)

if search in self._queue:
del self._queue[search]

and LadderService.searches updated here:

self._searches[player][queue_name] = search

https://github.com/46bit/faforever-server/blob/a024a2fe8c8b7b905a5bdd41795f8134ee01e677/server/ladder_service.py#L250

Even if we would expect that there is a linear relation between len(matchmaker_queue.queue) and len(ladder_service.searches), I would suggest tracking both, since that might catch future bugs.

@cleborys
Copy link
Member

One could also write a wrapper class for a dictionary that accepts a metric endpoint on instantiation and automatically reports the new length on insertion and deletion, if one is so inclined.

@Askaholic Askaholic linked a pull request Jan 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants