Server issue. Cycle times are exceeding 600 milliseconds.
|
Good morning everyone, I just have a question about why my server lags...
I am using vencilio base and I have 206 data added but when I log in my server process starts to lag and when I walk it stutters and stops it every tile before going on to the next. I just want to be pushed in the right direction. Is this a client or server issue? I have also checked Java, visual VM and it's saying that my client is running at 1.6 GB RAM and server is only at 400. Wondering if a memory leak could be the culprit here but I have never received out of memory exception
The RuneScape game operates on a game cycle (this is what players refer to as the 'tick system'). This cycle happens every 600ms (0.6 seconds).
So every game cycle, the server processes all of the necessary logic in the game and sends updates to all connected clients. (Logic such as player movement, npc movement, combat, skilling, basically every single interaction in the game). So for example with walking/running, the server is logically moving your player location every tile (1 tile if walking, 2 tiles if running).
What Kris is trying to say is you have so much logic happening in your game cycle, that the next game cycle is starting before the last game cycle even finished. (basically downright horrible server design)
The correct high level flow is:
Game Cycle 1 Starts
Game Cycle 1 Processes
Game Cycle 1 Finishes
Game Cycle 2 Starts
Game Cycle 2 Processes Logic
Game Cycle 2 Finishes
Game Cycle 3 Starts
Game Cycle 3 Processes Logic
Game Cycle 3 Finishes
etc
Instead of....
Game Cycle 1 Starts
Game Cycle 1 Processes Logic
Game Cycle 2 Starts
Game Cycle 2 Processes Logic
Game Cycle 1 Finishes
Game Cycle 3 Starts
Game Cycle 3 Processes Logic
Game Cycle 2 Finishes
etc
Game Cycle 3 Finishes
But I am assuming in general your game cycles never actually finish it just moves on if you're using a ScheduledThreadExecutor
Thank you very much guys! So for me to fix this I would have to do trial and error by commenting out each process that happens in the main game loop to find out which one it is? Or is there a better way of debugging this?
EDIT sorry I believe Jordan already answered this by saying that processes must have a finish to them instead of sitting there abandoned. So to my understanding I just add flush and stop at the end of the loop?
The end of the loop is never even reached which is the problem. You have logic processes deep in your code that is bottlenecking so much that the total time for your cycle is > 600ms. Because of this the game cycles never actually finish everything within that time frame and the next game cycle is already starting.
To debug this and fix this issue is to basically start with your game loop and go into each individual function that happens, comment it out, see what happens and trial and error find the culprit(s). Or use a profiler and that will basically tell you what function(s) is eating up the most used time.
If you want confirmation about the cycle times you can do this... And by the way, game loop = game cycle = main loop = ticks, these are all synonymous names for the same thing.
Go to your game loop method and add this at the very top of the method:
Then go to the very bottom of the method and add this:Code:Long start = System.currentTimeMillis();
This is very crude but it will tell you the total time in milliseconds it takes for your game loop.Code:Long finish = System.currentTimeMillis(); System.out.println(finish - start);
1. If it's >600ms, this is bad.
2. If you never see the println in your console, then yeah your game loop is never finishing. (because ur using a ScheduledExecutor) (this isn't a problem with ScheduledExecutor it's the actual logic processes taking too much time that the executor doesnt care and will move on to the next cycle no matter what)
There's only one loop/600ms executor.
1. If it's >600ms then that confirms your game cycle is too high and everything about what Kris and I said is correct.
2. If it's <=600ms then we are wrong and you have some other weird problem idk lmao (But a server with 1 player online and npcs should only be like 10ms or something like that, nowhere near 600ms)
3. But you probably won't see the println because your executor is moved on to the game cycle before the previous game cycle finishes (so you will never see the println and this also confirms your time taken is >600ms)
The goal: Your time should be <=600ms for everything to work correctly.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |