Server lag with getMotherId and getFatherId
LemADEC opened this issue ยท 6 comments
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:
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.
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.
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.