-
Bug
-
Resolution: Fixed
-
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.