Samsuik / IonSpigot

25 stars 8 forks source link

Bad performance #21

Open andreasdc opened 2 years ago

andreasdc commented 2 years ago

In what scenario is this better? In my tests this is worse about 70% than original code. https://github.com/SuicidalKids/IonSpigot/blob/master/TacoSpigot-Server-Patches/0035-Optimise-Entity-Collisions.patch

Samsuik commented 2 years ago

It caps the amount of entities getEntities can collect per section. For 1000 entities within a block with the original implementation it would add all 1000 entities to the list, only for the amount specified in the spigot config to actually be used. This would skip a lot of unnecessary calculations and list resizing when entities are packed together. The significant performance regression you're experiencing is likely due to the bad implementation of what I had in mind.

andreasdc commented 2 years ago

It caps the amount of entities getEntities can collect per section. For 1000 entities within a block with the original implementation it would add all 1000 entities to the list, only for the amount specified in the spigot config to actually be used. This would skip a lot of unnecessary calculations and list resizing when entities are packed together. The significant performance regression you're experiencing is likely due to the bad implementation of what I had in mind.

Yes, but even without it original code is faster. I added limit to original code and it's way faster.

Ok, I understand. :)