Silent Gear

Silent Gear

19M Downloads

Huge TPS drop when some Silent Gear stuff is put into Cyclics uncrafter

noncom opened this issue ยท 4 comments

commented

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:

Additional links: general info on why streams should not be used where performance is critical:

Steps to Reproduce the Problem

  1. Install LL3
  2. Uncraft some Silent Gear in Cyclic uncrafter
  3. See TPS go down
commented

Wouldn't this be a Cyclic issue?

commented

Why? The 60% CPU consumption that shows on Cyclic is actually Cyclic asking SilentGear:

image

nothing further along the stack trace ever returns to Cyclic, the whole CPU consumption happens within SilentGear.

commented

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)

commented

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