Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-119686

Performance issue (unloading chunks)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • Minecraft 1.12
    • None
    • Unconfirmed

      Hey there,

      this is not a bug, but more sort of a performance issue I came across recently.

      I'm the author of LittleTiles, a mod which opens up more possibilities to build (you can add a lot more details to your world). As you can imagine performance is really important, but there was one huge lag spike I could not fix.

      Eventually I found out that it occurred during unloading chunks. Soon after I found these two suspicious looking lines:

      World.updateEntities();

      this.tickableTileEntities.removeAll(this.tileEntitiesToBeRemoved);
      this.loadedTileEntityList.removeAll(this.tileEntitiesToBeRemoved);
      

      In my example the game had to remove 3,000 tileentities out of a list with 20,000 in it, which is quite horrible performance wise (took rather long using the debugger).

      So I modified those two lists and changed them to a HashMap<ChunkPos, List<TileEntity>> (my code: https://github.com/CreativeMD/CreativeCore/blob/1.11/src/main/java/com/creativemd/creativecore/common/world/WorldChunkedTileEntityList.java). Once a chunk unloads it removes a key instead of iterating through the whole list for each tileentity. This solved the lag spike.

      Comparison video:
      https://www.youtube.com/watch?v=vTCJbp45pWM

      This issue must have existed for several years. Although it is most likely not noticeable if you play without any mods installed, it can definitely ruin your experience if you build a lot of machines or other kinds of stuff (blocks having a tileentity). In those cases it's a huge performance improvement. It affects the server in the same way as the client.

      I hope this explains it, if not feel free to ask me. I attached the world used in the video, so you can reproduce this issue yourself (CreativeCore v1.8+ fixes this issue if you want to reproduce that as well).

      In Regards
      CreativeMD

            Unassigned Unassigned
            CreativeMD Matthias H.
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: