Slimefun-Addon-Community / Supreme

An addon for slimefun
GNU General Public License v3.0
6 stars 20 forks source link

Optimization solve the timings problem in TechGenerator and TechMutation #36

Closed RelativoBR closed 1 year ago

RelativoBR commented 1 year ago

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

JustAHuman-xD commented 1 year ago

I'll take a look

RelativoBR commented 1 year ago

@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

https://github.com/Slimefun-Addon-Community/Supreme/pull/37

SchnTgaiSpock commented 1 year ago

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

RelativoBR commented 1 year ago

this makes sense

JustAHuman-xD commented 1 year ago

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

JustAHuman-xD commented 1 year ago

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.

RelativoBR commented 1 year ago

@JustAHuman-xD https://spark.lucko.me/jh1ONSzc3r

JustAHuman-xD commented 1 year ago

The main lag is coming from cloning the slimefun item stack

JustAHuman-xD commented 1 year ago

https://github.com/Slimefun-Addon-Community/Supreme/blob/d1ff1144752f4cfe4a7f1b57131037f374a2c0fc/src/main/java/com/github/relativobr/supreme/machine/tech/TechMutation.java#L258

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.

JustAHuman-xD commented 1 year ago

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

RelativoBR commented 1 year ago

ok, i will adjust