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

Chunk Generation Performance Regressed by 20-30%


    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 16w15b
    • Minecraft 1.9
    • None
    • Community Consensus

      Since Minecraft 1.9, chunk generation performance has regressed by a substantial magnitude. This has been verified by both close inspection with a profiler, and also simply testing world generation with a fixed seed, whereby spawn initial spawn generation time increased from 4.19 seconds to 5.987 seconds between 1.8.8 and 1.9 (Vanilla). Using mc-dev names, but Vanilla code, the issue is as follows:

      In 1.8, IChunkProvider, implemented by ChunkProviderServer contained two methods to get a Chunk. We call these getChunkAt and getOrCreateChunk. The names are a bit misleading since they both create a chunk if it does not exist, but essentially the main difference is the latter method did not remove a requested chunk from the unload queue. In 15w37a and subsequently 1.9, this method was removed. As a result of this, the World.getChunkAt method, called by the getBlock/setBlock methods had to be changed to use the getChunkAt (from the original getOrCreateChunk) method, which dropped any requested chunks from the unload queue.

      Dropping these chunks from the unload queue is a very costly operation (ConcurrentHashMap.remove(....) called thousands of times a second), and the cause of this slowdown. To overcome this I have created a method called getOrCreateChunkFast that skips this unload queue drop. After verifying this change with a profiler it appears the issue is solved.

      Patch: https://gist.github.com/md-5/13c4c0bd55fb00ee6eb1

            ProfMobius ProfMobius (Thomas Guimbretiere)
            md_5 [Mod] md_5
            86 Vote for this issue
            46 Start watching this issue