CaffeineMC / lithium-fabric

A Fabric mod designed to improve the general performance of Minecraft without breaking things
GNU Lesser General Public License v3.0
1.94k stars 190 forks source link

feat: optimized preloading chunks by removing streams #471

Closed Crec0 closed 1 year ago

Crec0 commented 1 year ago

Overwrite chunk preloading method to not use streams. This gives a considerable server performance when large amount of entities are going through nether portals

Theoretical test

Average mspt with with 1024 repeating command blocks spawning items that go through portals to other dimension

Overworld -> Nether Nether -> Overworld
Without 76 425
With 62 147

Practical test

A stacking raid farm at 32mspt without optimization decreased to 24mspt with this optimization

2No2Name commented 1 year ago

Looks good to me. I might modify this to include a conceptual change: Instead of checking whether all sourrounding chunks were already preloaded, it might be faster to store that all necessary sourrounding chunks are preloaded for a given center chunk. However, this requires additional profiling to confirm that a significant amount of time is spent inside this function after your changes.

2No2Name commented 1 year ago

I noticed that you are excluding the top most chunk section of every chunk. I assume this is unintentional and change it, unless you give a reason for it.

2No2Name commented 1 year ago

Merged a modified version manually