Electroblob's Wizardry

Electroblob's Wizardry

18M Downloads

Lag in LivingUpdateEvent

LemADEC opened this issue ยท 4 comments

commented

Minecraft version: 1.12.2
Wizardry version: 4.2.11
Environment: Server

Issue details:
Lag consistently reported with LagGoogle in LivingUpdateEvent handling
image
From the look of it, there's quite a few of such events in the mod and they're all updating entities every tick.
A simple workaround would be to only update every 20 ticks or so, since most of those don't need single tick reaction time.
For example, you can do a smooth and fast check like so:

if ((entity.ticksExisted & 0xF) != (entity..getEntityId() & 0xF)) {
    return;
}

Other mods involved: https://www.curseforge.com/minecraft/modpacks/fsg-arcania-craft/files/3020551

Link to crash report (if applicable): n/a

commented

Hm, interesting. I'll have a look through them and see where I can cut out some updates without causing problems.

commented

On a similar note, the PotionSlowtime.cleanUpEntities() could also be slowed down to run every 20 ticks or so, especially when considering it currently recreates an array of all entities every tick.

commented

I've gone through all receivers of LivingUpdateEvent and cut down the frequency wherever I can, however I think the main problem is how imbuements are handled in WizardData (currently it iterates through the inventory for each imbuement), so I'll rewrite that system and hopefully that will reduce the lag to an acceptable level.

commented

Hopefully the above commit will have gone some way to reducing this issue. I'm leaving it open as there is still the restructuring described above to be done (it requires more work than I originally thought, hence why it's not in the main 4.3 update).