Applied Energistics 2

Applied Energistics 2

137M Downloads

Fluix cable lag when placing new cables connected to ME network

idkw opened this issue ยท 1 comments

commented

Describe the bug
I have a single ME network made of the following parts :

image

image

When I try to add new fluix or covered cable to extend the network and connect some additional machines, the server freezes for a noticeable time, sometimes up to a few seconds for every the cable that I try to place.

I tried to profile it with Jprofiler to see what was causing the lag, you'll find the results below.

To Reproduce

I don't know is the issue happens for every ME network when it reached a certain size, but I certainly noticed the lag becoming more and more noticeable as we upgraded the ME network up to its current state.

You can find the FTB server attached here, I removed all unnecessary chunks from the world file to keep it to a minimum for you to download : https://drive.google.com/open?id=1eCQ7M4MwSs74SKhiUpok1h4fIW_w8Opw
The server can be started by running the ServerStart.sh script (or .bat on Windows).
The base coordinates in the video are at : X=-82 Y=89 Z=1007

Expected behavior
There shouldn't be such a lag when placing new ME cable. I understand that a new or removed cable somehow triggers a reconstruction of the topology of the network but I bet it could be somehow optimized to avoid incuring that cost for every cable.

Additional context

Here you'l find the video of placing the cable during the JProfiler capture : https://youtu.be/trBdobBDvYc?t=220 (the Jprofiler capture starts at 3:40 and ends when the client disconnects)
I used intrumentation to capture all call to appeng package. The strain was so heavy that I had to disable the server watchdog so that the server doen't crash but the client still disconnected at the end. JProfiler Instrumentation made the lag much worse but this was expected.

This is a screenshot of JProfiler hot spots tree view :

image

The culprit seem to be the appeng.util.item.AESharedItemStack.compareTo(appeng.util.item.AESharedItemStack) which seems to be called millions of times for every new cable that I place. This methods, in turns, calls other methods that manipulate lists and update other stuff. There seems to be a cascade of things triggered by a single cable placement. It goes exponentially worse when the ME network gets bigger and bigger (although my network is not particularly big I think).

This is the video of what lag actually lag looks like when not profiling the server with instrumentation on : https://youtu.be/XcULIYgPgyE
On the first part I show what happens when placing cables not connected to the big network : no visible lag occurs. On the second part I show connecting additional cables on the current big network: very heavy lag that freezes all server operations happens.

Environment

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:        18.10
Codename:       cosmic

$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.10.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

$ ls mods | grep applied
appliedenergistics2-rv6-stable-6.jar

$ ls mods
 1.12.2                                            RedstoneFlux-1.12-2.1.0.6-universal.jar
'Advanced Machines-61.0.1.jar'                     Reliquary-1.12.2-1.3.4.786.jar
'Advanced Solar Panels-4.3.0.jar'                  ResourceLoader-MC1.12.1-1.5.3.jar
 AppleSkin-mc1.12-1.0.9.jar                        Retro-Exchange-1.12.2-1.0.7.jar
 Aroma1997Core-1.12.2-2.0.0.2.jar                  Silverfish-1.12.2-0.0.19-universal.jar
 Aroma1997s-Dimensional-World-1.12.2-2.0.0.2.jar   SimpleCorn1.12-1.12-2.5.10.jar
 AutoRegLib-1.3-32.jar                             SmoothFont-mc1.12.2-2.1.jar
 Baubles-1.12-1.5.2.jar                            SoulShardsRespawn-1.12.2-1.1.1-13.jar
 BetterAdvancements-1.12.2-0.1.0.77.jar            SplashAnimation-0.2.1.jar
'BiblioCraft[v2.4.5][MC1.12.2].jar'                StevesCarts-1.12.2-2.4.31.135.jar
 CTM-MC1.12.2-0.3.3.22.jar                         TechReborn-1.12.2-2.23.1.1003-universal.jar
 Charset-Crafting-0.5.6.0.jar                      Thaumcraft-1.12.2-6.1.BETA26.jar
 Charset-Lib-0.5.6.2.jar                           ThaumicInventoryScanning_1.12.2-2.0.10.jar
 Chisel-MC1.12.2-0.2.1.35.jar                      ThaumicJEI-1.12.2-1.6.0-27.jar
 CoFHCore-1.12.2-4.6.3.27-universal.jar            TheFramework-1.12.2-1.0.1-build-T23.jar
 CoFHWorld-1.12.2-1.3.1.7-universal.jar            ThermalDynamics-1.12.2-2.5.5.21-universal.jar
 CodeChickenLib-1.12.2-3.2.2.353-universal.jar     ThermalExpansion-1.12.2-5.5.4.43-universal.jar
 CompactSolars-1.12.2-5.0.18.341-universal.jar     ThermalFoundation-1.12.2-2.6.3.27-universal.jar
 Computronics-1.12.2-1.6.6.jar                     TipTheScales-1.12.2-1.0.4.jar
 Controlling-3.0.7.jar                            'Toast Control-1.12.2-1.8.1.jar'
 CraftTweaker2-1.12-4.1.19.jar                     Traverse-1.12.2-1.6.0-69.jar
 CraftingTweaks_1.12.2-8.1.9.jar                   UniDict-1.12.2-2.9.2.jar
 CustomMainMenu-MC1.12.2-2.0.9.jar                 WR-CBE-1.12.2-2.3.1.30-universal.jar
 DefaultOptions_1.12.2-9.2.8.jar                   WanionLib-1.12.2-2.2.jar
 EnderStorage-1.12.2-2.4.5.135-universal.jar       WorldControl-1.0.31.jar
 ExtraPlanets-1.12.2-0.5.5.jar                     XaerosWorldMap_1.4.3_Forge_1.12.jar
 FTBLib-5.4.3.129.jar                              Xaeros_Minimap_1.17.4_Forge_1.12.jar
 FTBUtilities-5.4.0.100.jar                        YABBA-1.1.2.53.jar
 FTBUtilitiesBackups-1.0.0.4.jar                   ae2stuff-0.7.0.4-mc1.12.2.jar
'Fancy Fluid Storage-1.12.2-2.2.5.jar'             appliedenergistics2-rv6-stable-6.jar
 FastWorkbench-1.12.2-1.7.2.jar                    bdlib-1.14.3.12-mc1.12.2.jar
 ForgeMultipart-1.12.2-2.6.1.81-universal.jar      binnie-mods-1.12.2-2.5.1.188.jar
 Forgelin-1.8.3.jar                                blockcraftery-1.12.2-1.3.1.jar
 Galacticraft-Planets-1.12.2-4.0.2.230.jar         buildcraft-all-7.99.24.1.jar
 GalacticraftCore-1.12.2-4.0.2.230.jar             cc-tweaked-1.12.2-1.83.1.jar
'Gravitation Suite-3.1.1.jar'                      chiselsandbits-14.33.jar
 GravityGun-1.12.2-7.0.1.jar                       diethopper-1.1.jar
 Guide-API-1.12-2.1.8-63.jar                       energyconverters_1.12.2-1.3.0.15.jar
 Harvest-1.12-1.2.7-20.jar                         flatcoloredblocks-mc1.12-6.8.jar
 ImmersiveCables-1.12.2-1.3.2.jar                  foamfix-0.10.5-1.12.2.jar
 ImmersiveEngineering-0.12-89.jar                  forestry_1.12.2-5.8.2.387.jar
 IntegrationForegoing-1.12.2-1.9.jar               iChunUtil-1.12.2-7.2.1.jar
 InventoryTweaks-1.63.jar                          industrialcraft-2-2.8.170-ex112.jar
 JustEnoughEnergistics-1.12.2-1.0.7.jar            industrialforegoing-1.12.2-1.12.13-237.jar
 MCMultiPart-2.5.3.jar                             ironchest-1.12.2-7.0.71.846.jar
 MFFS-1.12.2-4.0.1.0_1.12_cc3a5aa.jar              jei_1.12.2-4.15.0.268.jar
 MJRLegendsLib-1.12.2-1.1.8.jar                    jeibees-0.9.0.5-mc1.12.2.jar
 MTLib-3.0.6.jar                                   jeiintegration_1.12.2-1.5.1.36.jar
 MagicBees-1.12.2-3.1.10.jar                       longfallboots-1.2.1b.jar
 MicdoodleCore-1.12.2-4.0.2.230.jar                memory_repo
 ModularPowersuits-1.12.2-1.0.46.jar               minetogether-1.10.2-2.1.3.jar
 Morph-o-Tool-1.2-21.jar                           modnametooltip_1.12.2-1.10.1.jar
 Morpheus-1.12.2-3.5.106.jar                       modtweaker-4.0.17.jar
 MouseTweaks-2.10-mc1.12.2.jar                     modular-routers-1.12.2-3.2.2.jar
 MrTJPCore-1.12.2-2.1.4.43-universal.jar           moreoverlays-1.15.1-mc1.12.2.jar
 Netherending-Ores-1.12.2-1.3.jar                  mysticallib-1.12.2-1.3.1.jar
 Numina-1.12.2-1.0.38.jar                          playerplates-1.12.2-1.3.1.1.jar
 PeripheralsPlusOne-1.12.2-1.1-build-T58.jar       plethora-1.12.2-1.2.2.jar
 Placebo-1.12.2-1.6.0.jar                          railcraft
 PortalGun-1.12.2-7.1.0.jar                        railcraft-12.0.0.jar
 ProjectRed-1.12.2-4.9.4.120-Base.jar              randompatches-1.12.2-1.17.2.1.jar
 ProjectRed-1.12.2-4.9.4.120-compat.jar            reauth-3.6.0.jar
 ProjectRed-1.12.2-4.9.4.120-fabrication.jar       tesla-core-lib-1.12.2-1.0.15.jar
 ProjectRed-1.12.2-4.9.4.120-integration.jar       thaumicenergistics-2.2.2.jar
 ProjectRed-1.12.2-4.9.4.120-lighting.jar          thaumictinkerer-1.12.2-5.0-353c71c.jar
 ProjectRed-1.12.2-4.9.4.120-mechanical.jar        theoneprobe-1.12-1.4.28.jar
 ProjectRed-1.12.2-4.9.4.120-world.jar             topaddons-1.12.2-1.11.0.jar
 ProjectX-1.12.2-2.2.7-universal.jar               torchmaster_1.12.2-1.7.1.74.jar
 RebornCore-1.12.2-3.14.1.457-universal.jar        twilightforest-1.12.2-3.8.689-universal.jar
  • Minecraft Version:
  • AE2 Version: rv6-stable-6
  • Forge Version: 1.12.2-14.23.5.2838

Please tell me if you need any additional information to help you investigate the issue I'm faced with

commented

That is a side effect of disabling channels. In this case the whole network needs to be rebuild instead of just the changed parts (if at all).

Either enable them, use way smaller networks, or simply deal with it.