Fairy Lights

Fairy Lights

34M Downloads

ServerEventHandler.onGetCollisionBoxes() has MASSIVE performance issues with particles

Builderb0y opened this issue · 6 comments

commented


Half a stack of netherrack fires was enough to bring my client down to less than 2 FPS. Similar issues also occur with most other particle sources (including modded ones), since most of the particles they spawn call super.onUpdate().

Using version 2.0.0 for MC 1.10.2

commented

Doing my own testing shows perfectly fine performance, 4% for onGetCollisionBoxes:
snapshot
I tested with this setup:
setup

I'll need your world save so I can test your exact circumstances.

commented

I've replicated the issue in a fresh super flat world, so the world itself doesn't seem to be important. I'll test it again with nothing but fairy lights installed, and if the issue vanishes, then I'll try re-adding mods until it shows up again.

Ok so this is very strange, I can no longer reproduce the issue even in the same world I was using when I first reported it (and by extension, the same mod pack/config files too). To make things weirder, I've looked at the code for that method and all it seems to be doing is checking for nearby ladders. However, there were no ladders in any of the worlds I used while testing this issue.

I guess I'll re-add fairy lights to my server and let you know if it happens again.

AND… it's back. This is either an issue with dedicated servers, or something related to the roots mod (as that's also mentioned in visual VM). Time for more testing!

Neither roots, nor dedicated servers have made this issue any more reproducible, which means there's something in my current server world that seems to be breaking ALL particles. Copy/pasting my server world into my SP saves folder confirms this. Additionally, it persists until the client is restarted, and does not fix itself when joining a different world.

commented

Several hours of testing later, and I finally found the cause: advanced rocketry's rockets seem to cause particles to lag horribly with fairy lights installed. The issue starts when a rocket entity is spawned on the client, and persists until the client is restarted.

@zmaster587 Any ideas why this might be happening? I know entities can collide with rockets just like they do with boats, but that alone shouldn't cause issues like this. After all, I was able to spawn at least 100 boats without any issues.

commented
commented

I've determined the cause of this issue. There is a value World.MAX_ENTITY_RADIUS, which controls the search size for finding entities within AABBs, by default it is 2. The rocket entity from Advanced Rocketry sets this value to 100 in its onUpdate method, seen here.

I imagine it does this so that the entity can get away with being large, but changing World.MAX_ENTITY_RADIUS to 100 is not the correct solution.

It results in at least 144, derived from (⌊100 ÷ 16⌋ × 2)2, chunks needing to be searched for entities any time the client needs to find entities within bounding boxes.

This issue is very apparent with Fairy Lights and many particles because I use an event provided by Forge to make the steps of my step-ladder walkable. It is very easy to produce a lot of particles so for particles it is very apparent but having many of different vanilla things could make the same rocket inefficiency visible.

Looking at my code for the step-ladder collision I should be making the collision only active for entities like how normal entity collision is, e.g. boats have hard collision. So, I can resolve this occurrence of the issue by doing so, but @zmaster587 should alter rocket collision to not increase World.MAX_ENTITY_RADIUS to the insane amount to improve overall performance.

commented

I've released 2.0.1 which resolves particles causing lag once a rocket has been in the game.