Samsuik / IonSpigot

26 stars 8 forks source link

Features Suggestions #3

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, i think this list of suggestions would help in the performance a lot

Entity collisions cache TNT calculation cache

Samsuik commented 3 years ago

Sorry for the rather late reply,

I'm not sure about caching explosion calculations as there's very little to gain there. Most of the entities an explosion will iterate over will be out of range, and the entities that are within range are likely to be behind a wall and dealt with by the existing cache, where you'd gain from it is from the result of the sqrt call which can be expensive when called enough times.

What do you mean by an entity collision cache, could you be more specific with that? There may currently have a movement cache implemented which may be what you're referring to or at least very similar, which caches movement taking place at a location so it only needs to process it once.

ghost commented 3 years ago

For entity collisions cache i mean for this thing:

Spawn 1000 creepers in a single block and tps will drop to 17, 15, 13, 7, 3 and finally, 0 due to massive entity collisions and other things

ghost commented 3 years ago

collide(Entity entity) method from Entity doesn't have a cache, that's why is too laggy

Samsuik commented 3 years ago

From sampling with spark and testing in-game, most of the lag is caused by getting nearby entities because it has to get every entity nearby, not just the required entities.

These are my results from spawning 1200 creepers within a 1x1 hole, when tested with collisions set to the default in spigot the tps settles at 13 and with collisions set to -2, which completely stops applying collisions but still allows entities to be retrieved, it increased the tps to 15, it isn't the cause of the lag.

It should be resolved in be76d9a now it'll only get the required entities.

ghost commented 3 years ago

That's a good improvement, thanks