1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

does GarbageCollector clear some lag

Discussion in 'Help' started by Levi, Jun 22, 2018.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Yeah, it can.

    Suppose you teleport yourself to (x=1000, z=1000). PocketMine will load the chunk at (chunkX=1000 >> 4, chunkZ=1000 >> 4) and also the chunks surrounding that chunk depending on your server's view-distance. Pretty logical, right?

    Now teleport yourself far away, let's say (x=0, z=0). The chunks at (x=1000, z=1000) now don't contain any chunk loaders. A chunk loader is anything that keeps the chunk loaded. In pocketmine, players are a type of chunk loader.

    So what happens when there are no chunk loaders present in a chunk?
    The chunk unloads. Duh! Except, it doesn't unload instantly as the chunk is outside your view-distance. Rather, the chunk unloads when the NEXT chunk garbage collection get triggered. Until then, all the entities, tiles, tickable blocks etc present in that chunk will be ticking.
    When you run /gc, you'll force the server to run a chunk garbage collection which will unload all the chunks with no chunk loaders.
    [citation needed]
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Is running /gc everytime a player teleport places bad
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Maybe.
    Garbage collection takes a decent amount of time. But by the frequency you'll be executing it, I think you should be fine.
    See how it goes for you.
     
  5. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    incorrect. They queued for unloading once no loaders have been using that chunk for 30 seconds. However the unloading is throttled to 96/tick in order to not slow the server down. Unloading chunks can be an expensive process.

    As soon as a chunk has zero loaders, it stops ticking immediately, so this is factually incorrect to state that unloading them will increase performance.
    There's a very good reason why GC is only run every 30 minutes by default. Collecting garbage can be a very intensive process. Google "gc pause" to see what I mean.
     
  6. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Is unloading chunks takes very intensive process too?
     
  7. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Like not /gc but unloadChunks from plugin
     
  8. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    why do you think it's done the way it is?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.