Slimefun-Addon-Community/Supreme

Optimization solve the timings problem in TechGenerator and TechMutation

RelativoBR opened this issue · 11 comments

User Report: Identified a high consumption of server resources by some addon machines, requested an optimization so that the machines can use less resources.

Info: TechGenerator 3.29% and TechMutation 3.09%

Images:

image

image

I'll take a look

@JustAHuman-xD Could you check this PR? User who reported asked to include a limiter of 10 machines per chuck, I included this customization option, but with a default value of 100

#37

looks like TechGenerator/TechMutation.validRecipeItem might be an issue? it is iterating over all the recipes per tick, and the inputs probably wont be changing so often so saving the recipe in a cache might be a better option

this makes sense

Can you send the entire timings report
Also is this machine async or not?

looks like TechGenerator/TechMutation.validRecipeItem might be an issue? it is iterating over all the recipes per tick, and the inputs probably wont be changing so often so saving the recipe in a cache might be a better option

I feel like this isn't the problem as every AContainer machine does this and they don't appear on timings this bad.

The main lag is coming from cloning the slimefun item stack

ItemStack input1 = produce.getInput1().clone();

Is there any reason that you are calling .clone() for both of these here? I don't think its necessary and that is what is lagging it. I would try removing the clone call and doing some testing.

Looks like you also do this in some other blocks, I would recommend removing it from them aswell.

ok, i will adjust