Draco18s / ReasonableRealism

For 1.10!
Other
17 stars 8 forks source link

GC lag in EntityAIMilking.checkGrass #44

Open LemADEC opened 4 years ago

LemADEC commented 4 years ago

As of 1.12.1-Harderfarming-7.0.0a, we can see lots of memory allocation in the debug menu. Using VisualVM, we can see lots of BlockPos objects created every seconds: image

From a quick check in the related source code, here: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/farming/entities/ai/EntityAIMilking.java#L78

We can see a volume scan allocating BlockPos objects at every position. Consider using a MutableBlockPos to reduce the GC load. I didn't profile for Vec3d objects, but there's probably someway to recycle them here too.

Draco18s commented 4 years ago

Thanks for the input. I'm busy working on getting things on 1.14 and I think I'm going to completely overhaul how I'm dealing with animals as it is. There were a lot of factors that made the system wacky and overall unfun.