-
Bug
-
Resolution: Done
-
Minor
-
None
-
None
-
Windows 7
-
TrainCarts
After performing a server performance checkup using VisualVM Im noticing a very apparent performance drain on the server: Block.getRelative(). This is used a lot to 'walk' down blocks, or to simply get the block above or below. The problem is, that a call to getRelative redirects to a call to World.getBlockAt. This has the nasty side-effect that it looks up the chunk of the block again every single time its called.
This is a waste of cpu, because 100% of the time it will be the same chunk when y is 0, and in other cases when using getRelative with block faces it will be the same chunk 15/16 times. I would love it to be fixed, so I don't have to roll a hackish workaround myself.
The included logs are under a very simple test with only a few entities with the TrainCarts that are being updated. That function is being called a lot of times in more serious environments, trust me. It is presently 70% of the cpu usage TrainCarts is using, which I think is too much considering all the things TC updates every tick. getRelative really shouldn't be this slow.
Reason it is used a lot: walking down tracks (iterative).
I would love to see it fixed, at least for getRelative(BlockFace) because of the almost-guarantee the relative position is going to be sub-chunk.