Thread: Server lag question

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 Server lag question 
    Registered Member
    Join Date
    Apr 2021
    Posts
    25
    Thanks given
    34
    Thanks received
    7
    Rep Power
    30
    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
    Reply With Quote  
     

  2. #2  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Server issue. Cycle times are exceeding 600 milliseconds.
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Apr 2021
    Posts
    25
    Thanks given
    34
    Thanks received
    7
    Rep Power
    30
    Quote Originally Posted by Kris View Post
    Server issue. Cycle times are exceeding 600 milliseconds.
    Would that be in server.java ?
    Reply With Quote  
     

  4. Thankful users:


  5. #4  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Quote Originally Posted by 1001 View Post
    Would that be in server.java ?
    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
    Attached image
    Attached image
    Reply With Quote  
     

  6. #5  
    Registered Member
    Join Date
    Apr 2021
    Posts
    25
    Thanks given
    34
    Thanks received
    7
    Rep Power
    30
    Quote Originally Posted by Kris View Post
    Server issue. Cycle times are exceeding 600 milliseconds.



    Quote Originally Posted by _jordan View Post
    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?
    Reply With Quote  
     

  7. #6  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Quote Originally Posted by 1001 View Post
    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.
    Attached image
    Attached image
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    Apr 2021
    Posts
    25
    Thanks given
    34
    Thanks received
    7
    Rep Power
    30
    Quote Originally Posted by _jordan View Post
    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 is eating up the most used time.
    Perfect I appreciate that! The profiler is showing that the run[] is obnoxiously high, I think that's pretty much the main loop that you are taking about, I will now attempt to find this main game loop and start commenting out processes
    Reply With Quote  
     

  9. #8  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Quote Originally Posted by 1001 View Post
    Perfect I appreciate that! The profiler is showing that the run[] is obnoxiously high, I think that's pretty much the main loop that you are taking about, I will now attempt to find this main game loop and start commenting out processes
    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:
    Code:
    Long start = System.currentTimeMillis();
    Then go to the very bottom of the method and add this:
    Code:
    Long finish = System.currentTimeMillis();
    System.out.println(finish - start);
    This is very crude but it will tell you the total time in milliseconds it takes for your game loop.

    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)
    Attached image
    Attached image
    Reply With Quote  
     

  10. #9  
    Registered Member
    Join Date
    Apr 2021
    Posts
    25
    Thanks given
    34
    Thanks received
    7
    Rep Power
    30
    Quote Originally Posted by _jordan View Post
    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:
    Code:
    Long start = System.currentTimeMillis();
    Then go to the very bottom of the method and add this:
    Code:
    Long finish = System.currentTimeMillis();
    System.out.println(finish - start);
    This is very crude but it will tell you the total time in milliseconds it takes for your game loop.

    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)
    I'll ty this after I finish work! Very excited to see what it is ! So if it's higher than 600 then it's probably out of loop. If I never see it in console then it must be an unclosed loop. But what could happen let's say if it's less than 600 or is that impossible?
    Reply With Quote  
     

  11. #10  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Quote Originally Posted by 1001 View Post
    I'll ty this after I finish work! Very excited to see what it is ! So if it's higher than 600 then it's probably out of loop. If I never see it in console then it must be an unclosed loop. But what could happen let's say if it's less than 600 or is that impossible?
    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.
    Attached image
    Attached image
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Server lagging it self [Pay for fix]
    By mikelmao in forum Help
    Replies: 14
    Last Post: 07-24-2009, 07:17 AM
  2. Server Reboot Question
    By G R A P E D in forum Requests
    Replies: 1
    Last Post: 05-14-2009, 02:41 PM
  3. Server Reboot Question
    By G R A P E D in forum Help
    Replies: 2
    Last Post: 05-13-2009, 03:02 AM
  4. server port question
    By Name Invalid in forum Tutorials
    Replies: 5
    Last Post: 01-11-2009, 02:11 AM
  5. Why dose my server lag? "answer"
    By littleplop in forum Tutorials
    Replies: 31
    Last Post: 03-02-2008, 02:07 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •