Wizardry icon indicating copy to clipboard operation
Wizardry copied to clipboard

Lag in LivingUpdateEvent

Open LemADEC opened this issue 3 years ago • 4 comments

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

LemADEC avatar Aug 02 '20 17:08 LemADEC

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

Electroblob77 avatar Aug 03 '20 21:08 Electroblob77

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.

LemADEC avatar Aug 09 '20 16:08 LemADEC

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.

Electroblob77 avatar Aug 27 '20 21:08 Electroblob77

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).

Electroblob77 avatar Nov 04 '20 00:11 Electroblob77