OreCruncher / DynamicSurroundings

Dynamic Surroundings mod for Minecraft 1.10.x+
MIT License
120 stars 35 forks source link

Extreme Lag in the Nether #510

Closed Santclare closed 4 years ago

Santclare commented 4 years ago

Mod Version:

3.5.5.0

Forge Version:

The actual Forge version - "latest" does not count.

1.12.2-forge1.12.2-14.23.5.2847

Description of the problem. In the case of crashes, it is good to know things like the following:

Entering the Nether causes an unplayable amount of lag. I have taken down all other mods besides this one and it still has the same issue. If I go in any direction away from the Nether portal my fps will drop to a whopping 0/0.

I have tried Disabling: B:"Auroras in all Biomes"=false B:"No Nether Weather"=true B:"Enable Biomes Sounds"=false B:"Enable FireJetEffect Jets"=false

OreCruncher commented 4 years ago

Can you post your client side log? Also, you can enable trace logging in the config, and hit F3 when getting into the Nether. With tracing on and F3 a bunch of DS data will be displayed. Once in the nether wait about 15 seconds or so and take a screenshot.

Santclare commented 4 years ago

latest.log DS Nether F3 info DS overworld F3 Info I did have the other mods in my madpack loaded at the same time as the test. I hope that wasn't an issue. If so I can redo the test.

OreCruncher commented 4 years ago

Yeah, need it squeaky clean. Forge plus DS and OreLib. There are some mods in your pack that are doing interesting things and may be conflicting. If you look at the screenshot of the nether state you can see my state handler taking 214 msecs (about a quarter of a second) to run. That is what is causing the lag. And that routine essentially looks up and caches frequently used data from the client side world object and player. It's pretty straight forward stuff.

EDIT: Also can you post a mod list? I see some short names for mods I am not familiar with.

Santclare commented 4 years ago

I'm not getting the lag with just DS now.. latest.log 2019-10-29_13 53 15

AutoRegLib B3M BetterFoliage betternether BiomesOPlenty CubicChunks CubicDynamicTreesAddon CubicWorldGen divincisvessels DynamicTrees DynamicTreesBOP EnhancedVisuals EpicSiegeMod FancyBlockParticles Farseek foodfunk Forgelin FutureVersions gravestone Inventory Tweaks Just Enough Items journeymap Just Another Rotten Flesh to Leather Mod KleeSlabs LetSleepingDogsLie llibrary lostquiver malisiscore movingworld Mowziemobs MultiMine Neat+ preview_Optifine_1.12.2_HD_U_F4 Quark-r1.6-177 SereneSeasons SoundFilters Streams tektopia ToughAsNails TravellersBackpack worleycaves wumpleutil coroutil zombie_players

OreCruncher commented 4 years ago

Yep. So what we have here is a mod conflict. Fun part is figuring which one. General approach is to add one mod at a time until it breaks. I would start with CubicChunks and CubicWorldGeneration, and then Better Nether since it involves the nether.

OreCruncher commented 4 years ago

When you get it to duplicate, replace OreLib with this version here: https://github.com/OreCruncher/OreLib/releases/tag/1.12.2-3.6.0.0. I made a slight tweak that may help.

Santclare commented 4 years ago

Ok so this is where i'm at. I was messing around with the modpack, starting off with just the DS and Orelib. I couldn't seem to recreate the fault in any new world. So I went ahead and created a back up of an existing world and worked with those. I got all the way down to just DS & CC and their dependence with the issue persisting. I removed CC and the problem went away. I started adding mods back on, like CC and better nether, and the Issue seemed to stay gone.. I also tried the new Orelib with no change when the issue is happening.

OreCruncher commented 4 years ago

Could have been a residual with CC. I have had on and off conflicts with CC because of how it works. So for the moment you are lag free? At least where DS and CC is concerned. Better nether has world gen challenges. :)

Santclare commented 4 years ago

That's a negative. I load a copy of an existing world with just the two and the problem is still present.

OreCruncher commented 4 years ago

Can you load DS, CC, Better Nether, and the world that is giving problems, and still have the lag?

Santclare commented 4 years ago

Yes, but if I load them in one at a time in a new world in that order they do not lag.

OreCruncher commented 4 years ago

No, I mean add those three all at once with the lag world - not incrementally. Reason is that if it lags out, my next question would be to zip the nether up for me so I can drop into my dev environment. :)

Santclare commented 4 years ago

Yes the lag still present when i load in the world with those 3 mods

OreCruncher commented 4 years ago

Good! Can you zip up your nether save and link? I want to see what the issue is before I cut my next release.

Santclare commented 4 years ago

no problem at all. DIM-1.zip hope I can help.

OreCruncher commented 4 years ago

I was able to see the problem. Best I can determine it is a cubic chunk bug. During my ticking I have some code that tries to determine if a player is inside or outside by looking at some blocks around them. Specifically for a given X,Z it calls getTopSolidOrLiquidBlock() to find out where the block is above. For some reason this takes a long time for CC to process in with your Nether world. I don't know why. I used MultiMC to setup a world using only DS, OreLib, CC, and Better Nether. I dropped your Nether into my world, created a gate, walked through, and bam. I recommend opening an issue on their issue tracker and point them to this issue.

For their reference: Here is my call: https://github.com/OreCruncher/DynamicSurroundings/blob/master/src/main/java/org/orecruncher/dsurround/client/handlers/scanners/CeilingCoverage.java#L114

The implementation: https://github.com/OreCruncher/OreLib/blob/master/src/main/java/org/orecruncher/lib/chunk/PassThroughChunkCache.java#L174

Santclare commented 4 years ago

I appreciate you taking the time to explain it all. I will be sure to send them the thread! Thanks for your time and I hope we can get this resolved.

Barteks2x commented 4 years ago

I appreciate the work you are doing to figure it out, but there really isn't much I can do from my side to fix this. It can either remain a known incompatibility, or changed on this mod side.

getTopSolidOrLisqidBlock will never work in a useful and fast way with CubicChunks. It's only there for some degree of compatibility with some vanilla code and some mods when using compatibility generator. It's also not very fast in vanilla either, it's just not "your fps drops to 1" slow. I can't make it "do the right thing" for this particular context as that would break other uses of it.

And since all you care about is whether the difference in height is < 3, it should be trivial to implement it way more efficiently yourself with getHeight(BlockPos) or getPrecipitationHeight(BlockPos) (which are cached by MC and very efficient) and a few block checks.

Update: I analyzed the code again, and I think I can make it more efficient. Even if I don't consider this method to be any useful in the nether... I didn't consider just how stupid the logic is if I take together all the implementations of methods used along the way.

Update2: when trying to test my changes, I found that the version from curse (which doesn't use mixin) loads SoundCategory class from within class transformer, and uses func_187950_a on it, leading to NoSuchMethodError in dev because the mod's transformers are excluded for FML can't deobfuscate that call. It's also not even a class transformer.

Update3: I can't get latest version from github to run at all because of weird issues with orelib dependency

Barteks2x commented 4 years ago

Using latest dynamic surroundings build from github together with the text orelib build linked here, I was able to confirm that my change fixes this issue.

OreCruncher commented 4 years ago

Nice. I was getting ready to take a look at getPrecipitationHeight() to do something similar.

EDIT: The < 3 thing in my code is kinda strange. It took me a bit to remember how this piece of code works. In general, the more points it scores, the more the logic thinks the player is outside. What this line of code is saying is if the top most block is at the players head or beneath them, score it as outside. I am sure there is an optimization in this routine somewhere. I just can't wrap my head around it due to lack of caffeine. :)