Recently I have had quite a few lag spikes occuring on the server in our game loop.
- Code: Select all
public void Update()
{
DateTime newTime = DateTime.Now;
frameTime = (newTime - currentTime).TotalMilliseconds;
currentTime = newTime;
if (frameTime > 1000)
{
PlayerIO.ErrorLog.WriteError("Server lag spike, > 1000 ms");
frameTime = 1000;
}
accumulator += frameTime;
while (accumulator >= PERIOD)
{
shipManager.Update();
bodyManager.Update();
projectileManager.Update();
dropManager.Update();
spawnManager.Update();
turretManager.Update();
accumulator -= PERIOD;
}
}
Now, this did not happen at all before (+2 weeks ago) but occurs at least 2-3 times each day now. What kind of stuff can cause this? Dead-locks, exceptions or just something that takes really long to execute? Is this common or something really dangerous for our game? The player will see this as a lag spike, but then its corrected and it doesn't snowball into something bigger as far as we know yet.