server icon indicating copy to clipboard operation
server copied to clipboard

Add metrics for certain data structure sizes

Open Askaholic opened this issue 5 years ago • 3 comments

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".

https://github.com/FAForever/server/blob/ccf349e3b4bbaee95373d79a0e2f4ee9c5d064a2/server/ladder_service.py#L53

https://github.com/FAForever/server/blob/ccf349e3b4bbaee95373d79a0e2f4ee9c5d064a2/server/player_service.py#L25

https://github.com/FAForever/server/blob/ccf349e3b4bbaee95373d79a0e2f4ee9c5d064a2/server/game_service.py#L46

https://github.com/FAForever/server/blob/ccf349e3b4bbaee95373d79a0e2f4ee9c5d064a2/server/matchmaker/matchmaker_queue.py#L49

Askaholic avatar Jun 20 '20 07:06 Askaholic

@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

46bit avatar Aug 28 '20 00:08 46bit

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

I believe MatchmakerQueue.queue should be updated here: https://github.com/FAForever/server/blob/a024a2fe8c8b7b905a5bdd41795f8134ee01e677/server/matchmaker/matchmaker_queue.py#L134-L135 https://github.com/FAForever/server/blob/a024a2fe8c8b7b905a5bdd41795f8134ee01e677/server/matchmaker/matchmaker_queue.py#L144-L145

and LadderService.searches updated here: https://github.com/FAForever/server/blob/542eb721fcc7603015cf846413cc75c42f6f8bdd/server/ladder_service.py#L218 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 avatar Aug 29 '20 20:08 cleborys

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.

cleborys avatar Aug 29 '20 20:08 cleborys