Reborn Storage

Reborn Storage

41M Downloads

Reborn Storage Causes Server Hanging.

drunkripper opened this issue ยท 14 comments

commented

So we have a smallish little server and we have a custom modpack on it and decided to try RS, We really like it until we came across this issue. Now with Refined Storage the server hangs for 147,483 MSs while trying to calculate all the MAC's sizes.
https://i.imgur.com/H7jPLRI.png

commented

I'm with him on the same server, just thought I'd add a little bit since this wasn't very descriptive.

When the server starts, it hangs right before it allows players to join for a good minute or two. We ran VisualVM on the server and suspect it's probably related to some sort've multi-block crafter detection.
image

We currently have a max size multi-block crafter on the server which we suspect may be the culprit, there aren't any errors but it's really slow to start up.

@drunkripper suspects it may be due to the use of HashMaps being really slow, but we're kind've unsure.

commented

So we disassembled the giant (and I mean giant) multi-block crafter and it no longer hangs on startup. It's definitely related to how slow it is detecting if it's a valid crafter -- Perhaps this could be put on another thread that's not the main server thread?

commented

After further testing, We have found the issue was a 16x16x16 Multiblock Crafter. After removing there is no freeze. As @tenten8401 says i do suspect it to be the fact of HashMaps not being great at handling large amounts of blocks in my experience (a 16x16x16 crafter consists of 4096 blocks alone just for it and there are more on the server.)
I have 4 ideas on how to fix the problem:

  1. Put it onto a different thread
  2. Do it by chunk loading event instead of all on server startup so they get spaced out somewhat (This should still be done if possible to help with startup time)
  3. Change how the multi-block crafter math works to begin with. My idea would be to make the pattern storages and crafting cpu's being exponential. (1 crafting cpu is the same speed as 1 crafting cpu before, but 2 crafting cpus is 1^2, ETC and the amount of pages being the same way just so a 7x7x7 MultiBlock crafter max size would be sane enough.
  4. Will edit post when idea comes back to me RIP brain.

Edit:
4. Find an alternative to HashMaps.

commented
  1. The recipe look ups are not thread safe, this was tried and reverted (47bd7be)

  2. that could work, it would slow up chunk loading a bit but might save some server time.

  3. speed wise see #136

My idea is to buid the ICraftingPatternProvider once per stack and include it in the inv.

Current code:

.map(stack -> ((ICraftingPatternProvider) stack.getItem()).create(world, stack, node))

This would then only mean that the pattern is only created on world load/when you add a new pattern. Each time it rebuilds it can used the cached pattern for the stack.

@tenten8401 is there any chance you can send me that sample, and if possible a test world?

Some optimisations should also be possible to the multiblock logic (if its valid or not). Please let me know if you have any suggestions on my ideas.

commented

Yeah, that backup should be the one affected. We're running IndustrialBox which can be found on the ATLauncher and a server made using the "Create Server" button in the launcher.

The base in that backup should be located here: [world: world, location: 23596, 69, -51369]
you should see a giant crafting cube in the mountain. I'm pretty sure it's being chunkloaded on startup which is causing the hanging.

I'll see if I can get ahold of a VisualVM sample to look at.

commented

Thanks for that, I will see what I can do when I get a spare bit of time.

commented

I don't believe the issue here is pattern lookup, As it is just verifying that the multi block its self is good according to the thread. Uploading World Backup now. Guess we should clarify we are running a modpack. (IndustrialBox 0.7.16)

Edit: Backup uploaded.
https://drive.google.com/open?id=1e1FmEt1C0DEy-WR4-0MpvkI06GXDvCUi

commented

We got a snapshot of it happening, this should be able to be opened with VisualVM. I don't know if it'll be of any use but I figured it might be nice to have.
Reborn Storage.zip

image

commented

Ok, ive done some performance improvements. Now it will queue up the network rebuilds and only trigger it once per tick if needed. Before it was rebuilding the whole crafting network for every pattern storage block.

With my limited testing it seems a lot better. There is still room for improvement so if you dont mind testing the linked version that would be very grateful. (let me know if you want a version with a matching version as it should't be client compatible with the previous version.

https://jenkins.modmuss50.me/job/Team%20Reborn/job/RebornStorage/job/1.12/

Please let me know the results of this, and if possible send me some samples so I can make further improvements. (I still have ideas for slow pattern building)

commented

Will do. @tenten8401 or me will update it soon. I'm getting groceries ATM and will try out the issue soon.

commented

It is now very slow to load the patterns into the terminal or at all. Waited about 4 minutes so far and it's not loaded them in but it is connected to the network as a grid on the side of it works. I don't know how much of a pain this would be but, Maybe in the networks controller you make a Container class named RecipeStorage and the controller has a List where it adds it to it once it gets power from the network, and you can just List.add when a new pattern comes in or List.remove when a pattern is removed from the network instead of building the crafting manager every time there's an update.

commented

We updated the server & clients with Jenkins build 73. The smaller crafting cubes seem to work and there's no more hanging on startup, the big 16x16x16 says "rebuilding" when you connect it to the network, but no craftables appear in the RS terminal at all, even after waiting for a good 10 minutes or so.

If you have discord/IRC/something and some spare time I can get you access to the server for debugging purposes.

commented

http://discord.gg/teamreborn this will make things a bit easier ๐Ÿ‘

commented

Fixed, thanks for the help ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘