Whenever a player respawns in-game, the game freezes up slightly. Sometimes, this freezing can last for as long as 3 seconds.
R6 games suffer from this to a lesser extent, but R15 games seem to suffer the most. In particular, this is irritating when playing my game, because players are spawning in and dying frequently, and the long freezes can ruin fights between players.
I have confirmed that this occurs even in empty places.
Pay particular attention to the Heartbeat in Diagnostics. See how it drops to about 3/s when players spawn in? In longer freezes it’ll drop to around 0.8/s.
REPRO:
Start up a server with 3+ players and have 1 player jump continuously.
Set up a loop that respawns the other players at regular intervals, preferably with these respawns coinciding at nearly the same time as eachother.
Watch the jumping player whilst players respawn in. Wait a while and you should see some longer freezes.
The inGame parameter is true by default, setting it explicitly has no effect. If you set it to false however the performance will be really bad, the inGame parameter should never be set to false when loading characters in live game servers).
As for the other issue, we definitely need to look into this and ensure that loading characters does not effect server performance. It looks like a server write lock is being held during some portion of the character loading process and this is slowing down the entire server.
I think this issue is improving though, there have been some LoadCharacter changes since the thread that @TwentyTwoPilots linked that should have already improved performance for R15 character loading and I think there are some sound loading performance improvements coming soon which might also help with this.
Yeah, we should print a warning when LoadCharacter is called with false. As far as I know there are no valid use cases. (Maybe you could use it in a plugin, but certainly not in a game). We use LoadCharacter with inGame set to false for creating thumbnails, but we really should have made a new method with higher security.