
Abysmal performance of configurable AI-task null checks
Tommsy64 opened this issue ยท 2 comments
Commit cc36f9e leaves me nonplussed.
replaceNPEAttackTargetTasks(EntityLiving)
is called every single tick for every single entity. replaceNPEAttackTargetTasks(EntityLiving)
duplicates the entire taskEntries
LinkedHashSet into a freshly allocated array. This copy is then iterated, calling badNullTargetHandling(EntityAIBase)
for each element. All of this is happens again for another EntityAITasks
object.
This isn't too big of a problem; however, the worst of it is in badNullTargetHandling(EntityAIBase)
, which runs a customized (not sure why) regex split on a config string, allocating many String objects. Recall that this happens every single tick for just about every single entity, TWICE.
A test modded server with a single player and ~50 EntityLiving
's was crawling at ~10 TPS.
(See further conversation in the related PR post: #102)