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

Chunk Generation Performance Regressed by 20-30%

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 1.9
    • Fix Version/s: Minecraft 16w15b
    • Labels:
      None
    • Confirmation Status:
      Community Consensus

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ProfMobius [Mojang] ProfMobius (Thomas Guimbretiere)
                Reporter:
                md_5 [Mod] md_5
              • Votes:
                86 Vote for this issue
                Watchers:
                46 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: