SpigotMC/Spigot — pull request #224 by wildex999 (2014-08-30 16:10:07+00:00)
Title: Chunk Unloading performance improvement

***This is originally a fix I wrote for Cauldron, targeted at Modded servers who are Tile Entity heavy.***
https://github.com/MinecraftPortCentral/Cauldron/pull/1664

This will most likely have less of a performance improvement on most Vanilla servers, but can be a great improvement for modded servers.
It can however still help smooth out lag spikes and improve the TPS somewhat on large loaded vanilla servers.

This fix in essence adds a limit to how many TileEntities can be unloaded per tick. On modded servers unloading TE is pretty expensive in an of itself, but both Vanilla and Modded servers have the ~O(m*n) performance cost of unloading Tile Entities.
```java
this.tileEntityList.removeAll(this.b);
```
m = Currently loaded Tile Entities
n = Tile Entities to unload this tick

Once it reached the set Tile Entity limit it will stop unloading more Chunks until the next tick. Thus spreading the load over more time.
Note it will still unload all the TE's up to the last chunk, so it can go over the limit.

There is an option to stop it from queuing too many chunks.
Both these have a config option.
It will also watch and print a warning whenever it queues chunks due to too many TE's, or if unloading Tile Entities takes too long. These too have config options to turn them off.

*Not sure if I did the patch part correctly, was it supposed to create a new patch?*