What game mechanics in Minecraft cause lag?

Solution 1:

Other than the typical solutions such as installing optifine, you can also dive deeper into the game mechanics and modify those to improve performance.

Vanilla achieves 'random' growth by selecting several thousand blocks each server tick, checking if they can grow or decay, and if they can, applying the growth or decay. This is the 2nd biggest drain on CPU, behind entities.

Seeing as its a farm... there's going to be a lot of calculations going on.

You can of course reduce this number of blocks per tick by installing Spigot and changing the config there, at the cost of slower growth of your crops on your farm.

There are various options you change to be checked at slower intervals, just a few are:

  • Snow form
  • Ice melt
  • Reducing number of mobs that spawn (those in caves under your farm still use up resources)
  • Leaf decay

Of course, upgrading your hardware is probably the most effective solution. It is most likely that the CPU will be your bottleneck, but RAM may also be the issue. Use F3 to check the RAM usage in-game.

Solution 2:

Redstone circuits require a lot of calculations, as do flowing water and lava when it is changing the path if its flow. Those are the two things most often responsible for lag in Minecraft. If you have constantly-changing flows and many redstone circuits, that will bring the world to its knees.

Hoppers are the unknown element here. They're so new that their performance behaviour and code is not well known, so there's very little received wisdom about them. However, being a new feature, it's very likely that they're not efficiently programmed yet – having thousands of them might be significantly contributing to lag. If you reduce or eliminate excess moving fluids and redstone circuits and still have significant lag, this is where I'd look.

Solution 3:

Hoppers definitely can introduce lag. I had a large drop-collecting area without about 1k hoppers that I replaced with a hoppercart (which is able to pull though full blocks). Still creates server-side lag, but not nearly as much as a huge field of hoppers.

Not sure why iZanoVic suggested furnaces to cap hoppers-- I'd assume that any block would "cap" a hopper and make it stop searching for items to slurp up. I've noticed lag improvements (as measured by number of 'cannot keep up' messages in the bukkit log) simply by putting cobble blocks on top of long hopper ducts.

Solution 4:

Minecarts, Item frames, and paintings are all entities and large causes of lag. Consider using mob heads and blocks to mark things (I'm assuming that's what they are for, I could be wrong).

Any redstone is not only requiring a lot of calculations, but also emitting a lot of particles, and as particles are entities, they cause a lot of lag. The same goes for hoppers and dispensers.

You can also improve performance by reducing the number of chunks loaded from 'infinite' to some lower number, but depending on the size of your farm that may decrease output.

Source: Watching way too much HermitCraft