[IU] Industrial Upgrade

[IU] Industrial Upgrade

368k Downloads

Severe Server Lag in Industrial Upgrade (1.21.1-3.3.1.13) Due to Inefficient TileEntityCable Chunk Unload Logic

FortyTwoCn opened this issue · 2 comments

commented

Description
Our Minecraft NeoForge server (version 1.21.1) is experiencing critical performance issues, unplayable lag spikes and delayed player actions. Using the Spark performance profiling tool, we’ve pinpointed the root cause to the chunk unloading process in the Industrial Upgrade mod, specifically the inefficient handling of TileEntityCable (cable block entities) when chunks are unloaded.

Performance Profiling Evidence (Spark Call Stack)

Spark logs confirm that nearly 75% of the ’s CPU time is consumed by chunk unloading operations (), and ~28% of this total CPU load is directly traced to ’s unload logic. The critical call path is as follows:Server threadChunkMap.processUnloads()TileEntityCable

Server thread (100.00%)
└─ net.minecraft.server.level.ChunkMap.processUnloads() (74.35%)
   └─ net.minecraft.server.level.ServerLevel.unload() (43.33%)
      └─ net.minecraft.world.level.chunk.LevelChunk.clearAllBlockEntities() (43.32%)
         └─ com.denfop.tiles.transport.tiles.TileEntityCable.onUnloaded() (27.96%)  // Industrial Upgrade's cable class
            └─ com.denfop.tiles.transport.tiles.TileEntityCable.updateConnectivity() (27.94%)
               └─ com.denfop.tiles.transport.tiles.TileEntityMultiCable.setConnectivity() (27.94%)
                  └─ net.minecraft.world.level.Level.getChunk() (22.96%)  // Cross-chunk access during unload

Core Problem: Cross-Chunk Operations During Chunk Unloading
The critical flaw occurs in : when a chunk containing Industrial Upgrade cables is unloaded, the method triggers → , which unnecessarily calls Level.getChunk() and Level.setBlock(). This creates a destructive loop:TileEntityCable.onUnloaded()updateConnectivity()setConnectivity()

The server initiates chunk unloading to free resources.
TileEntityCable attempts to read/write data from other active chunks (not the one being unloaded).
This cross-chunk access blocks the (as chunk data fetching is synchronous) and cascades into 100% CPU usage.Server thread

commented

fixed

Can you release a version that fixes this issue? I urgently need it, as this problem is making my game very laggy

commented

fixed