Open SettingDust opened 3 weeks ago
I'm not quite sure why is it happened. The DF value should be calculated when generating noise. Why is it slow with formations. Is Formations loading chunks when finding the space?
The
tectonic
has complex ridges that will make the generation longer.
I am not sure what 'the tectonic' is. Is it a world generation type or something?
The DF value should be calculated when generating noise.
What is 'DF value'?
With formations' stuffs Time elapsed: 144271 ms
Also, what exactly does this time represent and how would I get those numbers? (So I can test with it)
Overall not sure why the center of the world would matter for generating structures. Perhaps I am checking the wrong coordinates somewhere or something
I am not sure what 'the tectonic' is. Is it a world generation type or something?
Tectonic is the data pack mentioned above
What is 'DF value'?
DF is Density Function. The value should be calculated when noise chunk status.
Also, what exactly does this time represent and how would I get those numbers? (So I can test with it)
The number will be output after generated the level to console
Overall not sure why the center of the world would matter for generating structures. Perhaps I am checking the wrong coordinates somewhere or something
Isn't related to the center of the world. It's chunks at the center. My description is confusing. I think the reason is finding the ground height is re-calculating the DFs. Which is expensive.
at net.minecraft.world.gen.noise.NoiseRouter.apply(NoiseRouter.java:62)
at net.minecraft.world.gen.chunk.ChunkNoiseSampler.<init>(ChunkNoiseSampler.java:159)
at net.minecraft.world.gen.chunk.NoiseChunkGenerator.sampleHeightmap(NoiseChunkGenerator.java:200)
at net.minecraft.world.gen.chunk.NoiseChunkGenerator.getHeight(NoiseChunkGenerator.java:128)
at net.minecraft.world.gen.chunk.ChunkGenerator.getHeightInGround(ChunkGenerator.java:663)
at com.supermartijn642.formations.structure.StructurePlacement.lambda$findFromTop$33(StructurePlacement.java:371)
at com.supermartijn642.formations.structure.StructurePlacement$$Lambda$7635/0x00000008010d0218.apply(Unknown Source:-1)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at com.supermartijn642.formations.structure.StructurePlacement.findFromTop(StructurePlacement.java:371)
at com.supermartijn642.formations.structure.StructurePlacement.lambda$static$0(StructurePlacement.java:29)
at com.supermartijn642.formations.structure.StructurePlacement$$Lambda$3662/0x0000000800bb10a0.apply(Unknown Source:-1)
at com.supermartijn642.formations.structure.StructurePlacement.findHeight(StructurePlacement.java:351)
at com.supermartijn642.formations.structure.PiecedStructure.getStructurePosition(PiecedStructure.java:73)
One structure will take 30s to find a point XD
A chunk took 5 min to generate, lul
After some profiling, nearly all the time it takes to generate Formations' structures comes from ChunkGenerator#getFirstOccupiedHeight
.
So when attempting to generate a structure, Formations checks the WORLD_SURFACE_WG
heightmap at 5 positions through ChunkGenerator#getFirstOccupiedHeight
. This is the same vanilla does, although for most structures at 4 positions rather than 5.
I did some testing (with Tectonic, The Abyss, and the seed you gave) and confirmed that:
ChunkGenerator#getFirstOccupiedHeight
5 times.ChunkGenerator#getFirstOccupiedHeight
are indeed within the chunk the structure is told to find a generation point in.With these confirmed, it seems Formations is doing nothing special compared to vanilla in terms of finding a generation point.
I then tested with and without Tectonic (in addition to The Abyss ofc).
ChunkGenerator#getFirstOccupiedHeight
takes around 0.1 - 0.15 seconds, with the entire generation attempt taking around 0.5 - 0.7 seconds.ChunkGenerator#getFirstOccupiedHeight
takes around 0.0032 - 0.0046 seconds, with the entire generation attempt taking around 0.017 - 0.025 seconds.That means there's a 20 to 30 times increase in the time it takes to simply query the height at a certain position. As I am doing the same as vanilla and have no control over ChunkGenerator#getFirstOccupiedHeight
, there's not much I can do about this.
I also tested with the mods Towns and Towers, Explorify - Dungeons & Structures, and Philip's Ruins (in addition to Tectonic and The Abyss and the seed you gave). Towns and Towers seems to have no impact on the time it takes to create the world. Philip's Ruins seems to increase the world creation time only slightly. Explorify - Dungeons & Structures does seem to increase the world creation time such that it is noticeable. None of these three mods seem to have an impact quite as significant as Formations Overworld.
I also tried to log every structure generation attempt (without Towns and Towers, Explorify - Dungeons & Structures, Philip's Ruins). It seems vanilla tries to find a generation point for every structure in a structure set until one succeeds. As none of the structures from Formations Overworld can spawn on the void, this seems to mean vanilla tries finding a generation point for every structure in the set for every chunk it tries to generate in.
It seems this effect isn't as noticeable with vanilla as there are just far less structures. When testing Philip's Ruins, I noticed their structures simply generating on the void rather than failing, hence there's no noticeable impact from that mod. I am not sure why Explorify - Dungeons & Structures doesn't have as large an impact as Formations Overworld. Perhaps simply because it has fewer structures, maybe its structures generate further apart, who knows 🤷♂️
Overall, the only real options to mitigate this I can think of are to either separate structures into more structures sets, however this has the effect that structures may spawn overtop each other, or to increase the distance between structures, however the average distance is already set to 15 chunks apart with a minimum of 8 chunks spacing between attempts which I feel is what I want for my structures.
As far as I can tell, all this seems to mostly be a Tectonic issue. Without Tectonic, it takes ~9 seconds with only The Abyss installed and around ~10 to ~11 seconds with The Abyss and Formation Overworld to create a world with the seed you gave. With Tectonic, it already takes ~27 to ~30 seconds to generate the world with just The Abyss installed.
Of course it could be something else in Formations causing this or there could be some other way to mitigate it. If anyone knows, let me know of course. But, as far as I can tell, there's not much I can do about it on my side.
That means there's a 20 to 30 times increase in the time it takes to simply query the height at a certain position. As I am doing the same as vanilla and have no control over ChunkGenerator#getFirstOccupiedHeight, there's not much I can do about this.
I'll look into the Minecraft code to find out if there is a way to optimize it. Thanks for your detail diagnosis.
As far as I can tell, all this seems to mostly be a Tectonic issue.
Ya, the tectonic is complex.
Message from Apollo (the Developer of Tectonic)
oh yeah Tectonic is not good for performance in general it's an issue I've been aware about but haven't addressed yet
Version Info
What mod loader are you using?: Fabric/Forge/NeoForge/Quilt Fabric Description of the Bug When the world center is void. Formation is trying to find out where to place structure which causing freezing for long time
Steps to Reproduce https://modrinth.com/mod/the-abyss-runtime https://modrinth.com/datapack/tectonic
The
tectonic
has complex ridges that will make the generation longer. So the effect from this mod is clearer.Seed: 5913989575094854072 With formations' stuffs
Time elapsed: 144271 ms
With only the-abyss + tectonic
Time elapsed: 38159 ms
formations' took more than 100 seconds.