Botania

Botania

133M Downloads

Poor spark performance

anonymous123-code opened this issue ยท 5 comments

commented

Mod Loader

Fabric (actually Quilt but template didnt let me select me + see additional information)

Minecraft Version

1.19.2

Botania version

1.19.2-439-FABRIC

Modloader version

Quilt Loader 0.19.0-beta.13; QFAPI v4.0.0-beta.30 (FAPI 0.76.0 compatible)

Modpack info

https://github.com/HexxyCraft/modpack

The latest.log file

https://mclo.gs/HkNGE7M

Issue description

Sparks cache transfers, to which they try to transfer every tick (except when empty). However, they also check on the validity of those every tick and thus needlessly iterate through them, even if they wouldn't be able to transfer there because they're empty.

Both recessive and dominant mana sparks search for nearby sparks (and iterate them) each tick, even if they wouldn't need to because they're empty (or full respectively). Dominant sparks then notify one of the other sparks to transfer to them (each tick, this only makes them ramp up in speed initially, after that its instant, so why is this even needed?), recessive sparks always try initiate a transfer to all other valid sparks in reach.
Because the transfer data is cached this searching gets needless once all sparks have been added as transfers, unless any of the sparks changes, or gets added

Steps to reproduce

Setup a large spark-based mana storage, preferably with lots of connected recessive and dominant sparks
For the profiles I used mana pools, 6 recessive pools, and 6 dominant pools, and 242 normal ones, all within range of each other
With all of them empty: https://spark.lucko.me/CPNYkwU8Pw
With the recessive pools being filled by gaia mana spreaders: https://spark.lucko.me/Fwhsy9qU54

Other information

Note that while I only tested on the version provided, the code I refer to is still live in the xplat source set on 1.19.x. It should hold regardless of the plattform.

Such a high performance hit is unexpected when nothing visible is happening (everything is empty or filled up.

There also is #2428 which has been closed by stalebot.

commented

thanks, if you have a botania only world you can send here that would help verify the fix much more easily, thanks

commented

This world contains a simple example 100 default sparks:
SparkLagSampleWorld.zip
Also Ive been working on implementing the proposed changes in https://github.com/anonymous123-code/Botania/tree/spark-improvements
Ill open a PR soon (Although Ive been unable to test as of b5aad58 so Ive been working based on 2682442 )

commented

Related: Now particles are the most expensive part of running sparks. It might be worth it to add a config option so that particles from invisible sparks only show up sometimes (like every 10th time), so that players have the option to optimize their setups even more. Is this the right place to discuss stuff like this?

commented
commented

It's not about the particles themselves, it's about the server notifying the client that particles should spawn (The networking code). And that is done server-side. Since it is useful to know what the server is actually doing, it generally is sensible to keep this stuff server side though imo, which is why I came up with optionally reducing the particle count server-side. I can PR my solution if you want.