Crafters waste a lot of performance
twothe opened this issue ยท 2 comments
I am currently looking for an autocrafter mod and stumbled upon yours, however during performance testing I noticed that this mod uses a significant amount of server time, even while doing nothing!
This is the performance analysis done with LagGoggles, it shows the amount of microseconds each block is consuming. In this setup all crafters use 100+ uS even though they are idle.
I double-checked with a setup of 50 idle autocrafters (with a recipe set), and the server already spent .3 milliseconds just on processing those crafters that were not doing anything but sitting there.
(First number is without any crafters, 2+ numbers are with crafters setup, the 1.8 numbers below are after I deleted those crafers again)
In my modpack where I was planning to use this I would expect players to setup possibly hundreds of crafters per player, which would bring the server down ever if those crafters would just sit there, even worse if they would actually start doing something.
Latest version (beta for 1.16.5) has preformance improvements to limit the amount of activity that happens when idle significantly.
Items only shuffle/balance out when something was added / removed / crafted recently
if there's more performance issues this issue may be re-opened
My suggestion: the block doesn't need to do anything until a new item is inserted. So you could add a flag that is set whenever an item is inserted, and only then the update function checks is there is something to do.
Also checking recipes is a very costly operation and should be done only if absolutely necessary.