Huge TPS drop when some Silent Gear stuff is put into Cyclics uncrafter
noncom opened this issue ยท 4 comments
Versions
- Silent Gear: SilentGear-1.16.3-2.3.5+170
- Silent's Gems: SilentGems-1.16.3-3.7.3+106
- Silent Lib: SilentLib-1.16.3-4.9.0+63
- Forge: 35.0.18
- Modpack: Limitless 3 v1.7.4
- Optifine Installed: No
Expected Behavior
Processing Silent Gear in Cyclic uncrafter should not impact server TPS
Actual Behavior
Server TPS drops to around 4-6.
Probably something in the code is taking too long to compute. It's not clear what could that exactly be for such a simple task as finding ingredients of a tool, had no time to look at the code itself. But also the Spark report stack trace reveals that a major part of the performance hit comes from extensive use of Java streams which are known to be dead slow (e.g. see the additional links in the links section) . Probably rewriting the code to not use streams would make a huge difference in performance.
Links/Images
Bug-related:
- Spark report: https://spark.lucko.me/#IVrTXz5CJ2
Additional links: general info on why streams should not be used where performance is critical:
- https://jaxenter.com/java-performance-tutorial-how-fast-are-the-java-8-streams-118830.html
- https://medium.com/@milan.mimica/slow-like-a-stream-fast-like-a-loop-524f70391182
- https://blog.jooq.org/2015/12/08/3-reasons-why-you-shouldnt-replace-your-for-loops-by-stream-foreach/
Steps to Reproduce the Problem
- Install LL3
- Uncraft some Silent Gear in Cyclic uncrafter
- See TPS go down
I do agree that I should change the getRecipeOutput
(func_77571_b
) method in this case, if possible. Caching the example item should be easy. I am aware that streams are not very efficient. I have tried to avoid them wherever code is called frequently. This is a case I could not have expected.
But if Cyclic is using the getRecipeOutput
method, then the uncrafter likely does not even produce a valid result, right? (although I don't actually know how it works)
Cool! I am sure you can think of a good solution for this that suits SilentGear, caching sounds great!
Well, one of our players had a sulfur -> blaze powder -> blaze rod
factory. I don't know the details of the design, but he's saying that it was working and producing the output. It was bugging us for a couple of days before the admin came and found the reason.
And yeah I understand, streams are very appealing :) Also, honestly, all this stuff is much more comfortable and generally faster in Kotlin, so as an absolutely personal bit of advice, I'd really just think about moving to Kotlin some day, there's almost no reason to stay with pure Java these days, unless you use it for something specific :P