Minecraft Comes Alive (MCA)

Minecraft Comes Alive (MCA)

13M Downloads

Server lag with getMotherId and getFatherId

LemADEC opened this issue ยท 6 comments

commented

We've noted that MCA entities are fairly laggy compared to other entity/mobs. When checking with a profiler, we've found that calls to getMotherId and getFatherId are very slow due to calls to java.lang.Integer.parseInt().
I would suggest to replace the data structure to use integer instead of String, so save a lot of CPU power.

Here's an extract from our 21mn sampling:
image
mca.entity.EntityHuman.onUpdate used 8.49% of the server CPU
out of which 4.71% are due those String to Integer conversion.
in other words, fixing this issue would double the AI execution speed.

commented

Nice catch - can't change the format of mother and father ID data at this point, but there's a couple of things I can do about this.

commented

In the readFromNBT() method, you can check if the old tag exist and convert it to the new format. This will progressively convert existing worlds to the new format.

commented

That will help, will make a couple more changes and probably publish this.

commented

I'm not willing to do that as it goes quite a bit deeper than that.

commented

Thanks!

commented

Published. Should work a lot better for you now. ๐Ÿ˜„