Starlight (Fabric)

Starlight (Fabric)

17M Downloads

[1.17.1-1.0.0-RC3] Memory leak/consumption increase when ran with Ultra Amplified Dimension and Chunk Pregenerator

TelepathicGrunt opened this issue ยท 7 comments

commented

I am the developer for Ultra Amplified Dimension and another user found a super weird 3 way mod conflict. I was able to reproduce it myself in singleplayer but only when Starlight is on with my mod and I use Chunk Pregenerator to pregen 100 chunk radius.

The links to the mods:

Starlight 1.0.0-RC3: https://github.com/PaperMC/Starlight/releases/tag/1.0.0-RC3

Ultra Amplified Dimension: https://www.curseforge.com/minecraft/mc-mods/ultra-amplified-dimension-fabric
Source: https://github.com/TelepathicGrunt/UltraAmplifiedDimension-Fabric

Fabric Chunk pregenerator: https://www.curseforge.com/minecraft/mc-mods/chunk-pregenerator-fabric
Source: https://github.com/SuperCoder7979/fabric-chunkpregenerator

So the expected behavior is that as Chunk Pregenerator creates the chunks over time, the RAM usage stays consistent and it does for me. Around 2GB out of the 8GB I give it (out of habit). And this correct normal usage happens if I use any 2 combinations of the 3 mods. However, once all 3 are put on together at the same time, the RAM usage spikes like mad to near complete usage in UAD and a significant increase in just Overworld which is what the original player reported to me. Even when I pregenerated the Overworld instead of UAD's dimension.
In UAD dimension:
image

In Overworld:
image

Here's where it gets super weird and where I got stumped. The leak does not appear to happen if I fly around in the world for a long time. Only when I use the pregen command to create a ton of chunks. The other weird thing is I even filtered for UAD's classes and methods in VisualVM and nothing showed up. Meaning no UAD code was running. I even prefixed my mixins with "uad_" and searching for that seems to show no UAD mixin ran either.
image

I did reach out to the Chunk Pregenerator dev but they have no clue as to what is going on and a third dev was also confused. That's why I am reach out to you on this issue report. I'm hoping you might have an idea as to what the heck could be going on. If it something with my mod's code and you can find a clue as to which code, I can fix it. The current theory from the other dev is that something is causing chunks to not be unloaded as this is what they found:
image

Thank you for your time and I hope we can figure out what the cause is!

commented

So if I can not use Bukkit then my only option to pregen chunks and not have this issue is to pull Starlight while I gen chunks and then re-add it after?

commented

Yes. Although you should also forward this issue to the pregen mod author, as it's a bug in their mod - it's continuing to load chunks when the server is not able to keep up with unloading (although the TRUE blame lies on the chunk system, but unless you feel like asking Mojang to fix it...).

commented

If you can run your tests again but on commit 5e53c1f that would be helpful, I think that commit fixes the problem.

commented

I'm going to need a heapdump, I cannot produce this locally.

commented

Someone gave me a heapdump that looked similar to the issue here.

This looks like one of the many chunk system bugs fixed by paper or tuinity. Chunks are not unloading. That much is evident in your initial screenshot with ChunkHolder at 600 thousand instances. For reference, I don't even see servers running 200+ players with that many chunk holders. That is an absurd amount.

Starlight pushes chunk gen much harder because the light engine is no longer slowing the whole process down. This unfortunately puts pressure on many vulnerable spots on the chunk system. One the server starts stalling due to GC, it's basically over. This is why you will see this problem with Starlight.

Notably, here are a the problems which I think are causing your problem:

  • Chunk system requires the server to run at low MSPT to properly process chunk unloading (not an issue on paper/tuinity)
  • Chunk system has a bug with its unload future, it schedules a possibly delayed task (especially if not at perfect 20tps) and forces the unload to wait on it. Paper/tuinity fixes it
    And I'm forgetting many of the fixes I've had to apply to the system over the past couple of years.

Chunk pre-generators on bukkit hack around this problem by monitoring memory usage and halting chunk loads. Not the greatest idea, but it works since it's really hard to tell when a chunk has fully been unloaded.

The only fix I can apply is to slow down Starlight. Not happening. Neither I am touching the chunk system on fabric, it's bad enough dealing with plugins on the bukkit side of things.

commented

One of the things you can do is pre-generate your world on the bukkit side of things and just copy the world files over (please note that bukkit stores multiworld differently, due to... reasons), as this is very much a solved problem over there.

commented

It seems to still happen even after I build the latest commit and then do pregenning based on that. I did more rigorous testing and let it run longer. It seems to be that UAD isn't need at all. It's only some strange interaction between Fabric Chunk Pregenerator and Starlight. Here's my results and view of the memory usage over time using the same seed for a new world each time and pregenning overworld.
test