TerraForged / tracker

Technical issue tracker
1 stars 0 forks source link

[1.16.5] Server lagging with Mowzies Mobs #189

Closed Diversion98 closed 2 years ago

Diversion98 commented 2 years ago

Hi,

My server/pack is very laggy somehow so i did a spark profiler. in that spark profiler u can see it is searching for a structure to spawn but terraforged is taking a long time.

I made an issue on Mowzies Mobs github as well: https://github.com/BobMowzie/MowziesMobs/issues/630

spark: https://spark.lucko.me/XibyR7L9dV

Won-Ton commented 2 years ago

Hi. Looks like their mod checks for the proximity of certain structures to determine whether certain mobs can spawn.

My guess would be that they're looking for a structure that TerraForged isn't able to generate, or is very rare, so the search function spends a long time looking for it without finding anything

Won-Ton commented 2 years ago

On TerraForged's side you could try set the "structure_search_timeout" option in TF's config to something much smaller (ie < 50?) so that it gives up searching quicker.

That doesn't solve the root problem (ie that the structure isn't being generated/found for whatever reason), or the fact that the spawner is doing a relatively expensive check every tick without (apparantly) caching results

Diversion98 commented 2 years ago

aight will change it in the config for now till the dev of mowzie's react! :D

Thanks for giving me a temp solution :)

Diversion98 commented 2 years ago

The dev of mowzies responded, i think u guys might need to chat with each other xd read the response on the mowzies github page (link in original msg)

BobMowzie commented 2 years ago

Hi! I hadn’t considered caching the results of the structure lookup; that could be worth a shot. But I haven’t seen any performance issues doing this without Terraforged. I suppose the way you guys generate structures is different than the vanilla game.

Won-Ton commented 2 years ago

There's a lot more variables to consider in a modded world-gen environment.

For example (and not saying this is the situation in this case): You might have a mob that is checking for a structure that only generates in deep-ocean biomes but the player is smack-bang in the middle of mahoosive continent that is generated by some custom overworld mod. The search for that structure could take a long time because the ocean is so far away. Deep oceans might be incredibly rare in this overworld due to the way the mod generating the overworld works, a datapack has altered something, or a user has configured something that affects the rarity.

The problem with using ChunkGenerator#findNearestMapFeature is that it is designed to keep searching until a structure is found. TerraForged specifically exits the search after a timeout because it can cause the game to lock-up for long periods if the structure never generates, and as alluded to above there could be many reasons why a structure never generates when mods/datapacks/users are factored in.

I don't know enough about mob spawning to suggest alternate approaches but hopefully some insight on the world-gen side gives some food for thought.

BobMowzie commented 2 years ago

I see. Thanks. As a quick improvement to specifically the case you describe, I could have the mobs check the structure placement registry to see if they’re in a biome the structure can spawn in first. Then only check for the nearest one if the biomes match.