Mekanism

Mekanism

111M Downloads

Thermal Evaporation plant: can only the controller be a TileEntity?

Ricket opened this issue ยท 4 comments

commented

In debugging an issue, I found that all of the ThermalEvaporationBlocks are tile entities. Is it possible to make that block just a basic block, and then only the ThermalEvaporationController (and valve, etc) would be a TileEntity? Since these towers can be quite large, it would greatly reduce the number of tile entities, which is obviously a good thing.

commented

TEs themselves shouldn't be an issue in and of itself; it's ticking TEs that are a problem. Once the controller is found, the Blocks won't really do much ticking.

commented

You're right, it hardly even registers while profiling. It's definitely a negligible impact in terms of memory usage, allocations/garbage, or cpu usage. The code looks fine. It's just that in this particular bug that I'm suffering, the larger the number of tile entities, the worse the bug. MinecraftForge/MinecraftForge#4238

Specifically, with List.removeAll being a O(n*m) operation, the number of tile entities increases the time til login exponentially.

It's not a big deal, not the root cause of that bug even (I'm hoping to find what mod is loading/unloading chunks repeatedly). Just coincidentally would probably improve that issue, maybe make it unnoticeable.

And I'm thinking for example of XNet, which does something like this. "The cables themselves are not even tile entities."

commented

Oh its certainly possible, but not an easy change.

Off the top of my head we could do any of the following:

  • Have the Controller do the checking, which would require a cascading neighbour change event when a block was removed
  • Maintain a separate list of lists which has to be properly GC
  • Have the block do a search every time it is placed or broken
commented

As of right now, I believe the current functionality is close to peak efficiency. I don't like the idea of performing a scan every time a block is placed or modified, and separate lists get funky with chunk management. I appreciate the suggestion though.