Refined Storage

Refined Storage

77M Downloads

[1.2-beta1] Performance issue with processing patterns and ItemStackList

RealGrep opened this issue ยท 11 comments

commented

Issue description:

Something in the way it manages adding items to machines using processing patterns is just hammering the server.

What happens:

Looking at the machines, including a Mekanism crusher and smelter (both elite and doing 7 at a time, and with 4 speed upgrades, set to auto-sort), and the solderer, while crafting two 64k storage disks, the progress arrows are jerky and the machines are running at far less than the speed they should be. The client is fine, but the server is reporting "Can't keep up!" messages. They ceased once the crafting operation was completed. If I manually insert a stack of iron into the solderer when no autocrafting is happening, it runs smoothly and without jerking.

So I, of course, ran some profiling with Sampler, and loaded up the .nps file in VisualVM. I see a few things taking a lot of processing time on the server. For example, ItemStackList.add(), ItemStackList.copy(), TileController.func_73660_a(), CraftingTask.update(). There's others like Comparer.isEqual() and isEqualNoQuant() that also might be taking up more time than desirable.

The .nps file can be found here: https://www.dropbox.com/s/3biafjq8kv6qlts/rs-beta-profile.nps?dl=0

You know, on the good side, it completed and never jammed up once! :D

What you expected to happen:

For it to not result in jerky, slow processing, and for it to be kind to the server.

Steps to reproduce:

  1. Set up processing for 64k storage disks. I used a Mekanism crusher and smelter, but other machines should have the same result (as the solderer seemed also affected).
  2. Request two 64k storage disks.
  3. Observe the machines and notice they are operating in a jerky fashion, and the server is being hammered.

Should still happen with other types of items and patterns, but this is the one I used to test, since that would often jam up with previous versions (and I needed more storage space, anyway).

Version (Make sure you are on the latest version before reporting):

  • Minecraft: 1.10.2
  • Forge: 12.18.2.2107
  • Refined Storage: 1.2-beta1

Does this issue occur on a server? [yes/no] Yes

If a (crash)log is relevant for this issue, link it here:

No crash or crash log, but see profiler file above.

commented

Let me send you another build @RealGrep...

commented

Please try this one :)

refinedstorage-1.2-beta2-test.zip

commented

Wow, you two are fast! Giving it a try now, thanks. :)

commented

It's definitely improved a bit, but still an issue. Server is spitting out "Can't keep up!" messages, still. Sampler says TileController.func_73660_a(), CraftingTask.update() and ItemStackList.copy() are still taking up a fair bit.

The .nps file: https://www.dropbox.com/s/kdvdn8eglcmloe7/rs-beta-profile2.nps?dl=0

Can verify I'm using the test version on both sides: b230b930fa93b8fe0abe52941428fa60 mods/refinedstorage-1.2-beta2-test.jar

commented

Call tree leading to it seems to be:
TileController.func_73660_a()->CraftingTask.update()->CraftingStep.canStartProcessing()->ItemStackList.copy()

Probably, it's this in CraftingStep, I think:

public boolean canStartProcessing(IItemStackList items, IFluidStackList fluids) {
    items = items.copy(); // So we can edit the list

EDIT: I should mention the copy in CraftingStepCraft.canStartProcessing() also seems to suffer the same issue.

commented

Yeah, the issue is with the copy of an items stack. As that list gets big it seems to be really slow.

commented

Just so you know, though I didn't get the extremely recent disk drive rendering code, I built it from Github to see if the performance changes helped. Everything is smooth as butter, and ancient legends say the server isn't spewing "Can't keep up!" messages either. So looks like you nailed it. Good job, way2muchnoise. :)

commented

Awh, cool, you are a man to my heart @RealGrep. Very detailed bug report WITH profiling and you even tested from GH yourself. Thanks!

commented

hehe No prob. I've been a professional developer for a rather long time now. I know how to make good bug reports, at least. lol

Though I don't know much about MC modding, it'd be nice to learn. Was thinking this project would be a nice one to be involved in, but my lack of knowledge about MC modding is boundless. We shall see. Being able to build it from source is a good first step, though. Anyway, my numerous bug reports to many projects is one way I can contribute. :)

Thanks to you both, and the other people who have contributed!

commented

Thx @RealGrep the profiling really helps out. And the issues it had where just me being stupid :D

commented

I can't recall a single bug ever that I have had, then found and fixed, where I didn't think: "Wow, that was stupid of me." lol