Bukkit: long ticks and lag

Discussion in 'Plugin Development' started by Double0negative, Jul 28, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Double0negative

    So, first off, I wasn't entirely sure where to put this, but this seemed like the best spot because this part of the forum probably contains the most technical users and it has some code to it. If mods thing it should go in another section, feel free to move it.

    Now, the main issue I am having is long ticks happening quite often (ticks lasting longer then 50ms) on vanilla bukkit. The odd thing about it is they are almost always 101ms. I tried disabling all plugins to ensure that it was no a plugin causing the issue, and it still happened the same. I tried it locally with similar results to the server (both are i7 cpus with plenty of ram so the hardware is not an issue)

    some sample output from my test.

    03:25:04 [INFO] Last tick was 101ms. Tick: 28787 Avg: 51 Total: 1470168
    03:25:04 [INFO] Last tick was 101ms. Tick: 28790 Avg: 51 Total: 1470318
    03:25:06 [INFO] Last tick was 1633ms. Tick: 28802 Avg: 51 Total: 1470919
    03:25:07 [INFO] Last tick was 101ms. Tick: 28848 Avg: 51 Total: 1473218
    03:25:08 [INFO] Last tick was 154ms. Tick: 28863 Avg: 51 Total: 1473968
    03:25:09 [INFO] Last tick was 101ms. Tick: 28891 Avg: 51 Total: 1475368
    03:25:11 [INFO] Last tick was 101ms. Tick: 28921 Avg: 51 Total: 1476868
    03:25:11 [INFO] Last tick was 101ms. Tick: 28930 Avg: 51 Total: 1477318
    03:25:12 [INFO] Last tick was 101ms. Tick: 28955 Avg: 51 Total: 1478568
    03:25:13 [INFO] Last tick was 164ms. Tick: 28967 Avg: 51 Total: 1479168
    03:25:13 [INFO] Last tick was 101ms. Tick: 28975 Avg: 51 Total: 1479568

    Now the 101ms times wouldn't be such of an issue, but as you can see it jumps up every few seconds to rather large times.

    the code I used to test this is

    Code:
        private long lasttick = new Date().getTime();
        private long totaltime =0;
        private long tickno = 1;
      
            Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                public void run(){
                    long time = new Date().getTime();
                    if(time - lasttick >100){
                        System.out.println("Last tick was "+(time - lasttick)+"ms. Tick: "+tickno+" Avg: "+(totaltime / tickno)+" Total: "+totaltime);
                    }
                    totaltime = totaltime + (time - lasttick);
    
                    lasttick = time;
    
                    tickno++;
                }
            }, 0, 1L);
           
    
    Any ideas on what this could be?
     
  2. Offline

    azazad

    Garbage collection lag? Have the scheduled task print the value of Runtime.getRuntime().freeMemory() every tick. If free memory increases significantly after each lag spike, you need to save some memory somewhere.
     
  3. Offline

    Double0negative

    I dont think so, The server was running on 12 GB of ram with just me on it.
     
  4. Offline

    azazad

    I don't have a clue then. :D
     
  5. Offline

    r0306

Thread Status:
Not open for further replies.

Share This Page