hotfix: Improve lobby performance - #41
Merged
x64-dev merged 2 commits intoAug 15, 2026
Merged
Conversation
added 2 commits
August 15, 2026 20:15
…to prevent blocking of Tick() actions
Move AppDbContext instance to class level instead of method level in Lobby and LobbyManager to prevent unnecessary database connection creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Possible solution for the server issues of late.
PR consists of two commits, each solving a particular issue.
Commit 1: Move
ProcessLobbbiesNeedingDestroyed()into its own lobby timer to prevent blocking ofTick()actionsThe destruction of lobbies involves the processing of game results and statistics, involving multiple database calls. This is a synchronous process and is being awaited by the
Tick()function. The nextTick()event call and update of lobbies does not proceed untilProcessLobbiesNeedingDestroyed()has finished.The hotfix solution is to remove ProcessLobbbiesNeedingDestroyed() from Tick() and creation of a new seperate timer that handles
ProcessLobbbiesNeedingDestroyed()Commit 2: Prevent unnecessary creation of AppDbContext
A new
AppDbContextis created for everyLobbyManager.DeleteLobby()call andLobby.UpdateStatecall.Database contexts should not be recreated for every call, but reused as much as possible.
Hotfix solution is to move the creation of
AppDbContextto the constructors ofLobbyManagerandLobby.The implementations have not been tested.