Sophisticated Core

Sophisticated Core

49M Downloads

High allocation rate when looking for recipe uses of Create blocks on a backpack with Crafting Upgrade

JonathanxD opened this issue ยท 2 comments

commented

I'll start pointing out that I'm not sure whether this issue belong here, to mezz/JustEnoughItems or Creators-of-Create/Create, but I'm assuming here is better because I can only reproduce using Sophisticated Backpacks and Sophisticated Storage.

I've came across an interesting issue, first you need to have chest or a backpack with the Crafting Upgrade and store a lot of blocks from Create, the more different types of blocks you have, worse it gets.

Here is how mine is looking like right now:

image

This is not enough to lag to same the extent that it did on my survival map, but it's enough to notice the problem.

Now you just need to open Recipe Uses of any Create block (must be a Create block) using the U shortcut (the default one) while the backpack or chest is also opened. Note that using the Recipe view (R shortcut) will not cause the problem, it must be the Recipe Uses.

Here you will be able to notice a massive TPS drop, and if your machine can't keep up with the Garbage Collection, a huge FPS drop as well (there's some additional overhead on the Render Thread logic regardless of this, so it will cause some lag anyway).

You can use /spark tps to se the avg history of the TPS, which can go as low as 1.

Below is the clip where I reproduce the issue:

sophisticatedcore-jei-and-create-lag.webm

And there is the spark profiles, captured with the laggy JEI UI (backpack open):

And a reference one captured with the JEI UI open, but no lag (backpack closed):

If you go to the mods view you will see that sophisticatedcore is the biggest offender, and you can track the problem down to this call.

It's not only allocating 50GB worth of data in just 30s, but it's also introducing a lot of overhead, both combined causes the CPU to spend a lot of time just on garbage collection (probably this is causing fps drop), and a lot of time on running this single call (which is the root cause of TPS drop).

Let me know if you need more information on this!

commented

I have just done some testing to compare this to doing the exact same in vanilla crafting table with the items in my inventory and I am getting very similar results (spark shows very similar percentages for vanilla crafting vs sophisticated crafting) which was to be expected because the code actually spends most of the time in JEI method that's used for both vanilla crafting table integration and for crafting in sophisticated inventories as well.
So you would want to follow up likely first with mezz on JEI as he may already have an idea what's going on there and if it can be improved.

I will leave this open just in case something comes up I may want to do to improve here, but very likely will just close given that this needs to be fixed somewhere else.

Also your second test to show uses without actually having any inventory isn't really valid as a comparison as I am pretty sure that JEI needs to continuously check for whether ingredients are present if the crafting table is large enough for the given recipe. And given that creative doesn't have any kind of crafting it just plain skips checking for ingredients and just tells you that you can't craft anything in that screen.

commented

I'll open an issue on JEI as soon as I get time update everything to the recent versions and re-test to make sure things haven't improved yet by themselves.

Apart from that, you can close the issue, it sounds reasonable to me. I would do it myself, but given that you brought up that you may not want to do it, I'll let you decide.

I'll just link it on JEI so I don't need to duplicate everything I already wrote, maybe I'll open one on Create as well so they can be aware of the problem.

Thanks!