In Control!

In Control!

72M Downloads

Major tick lag with potentialspawns

Closed this issue ยท 9 comments

commented

Hi, so I was running the official version (Without my changes) to make sure I did not break something, but it seems like potentialspawns really brings the game to its knees when a lot of rules are being used, I will need to use a proper profiler to pinpoint exactly where its being slow but I figured I would open an issue regardless because its still something which needs attention.

This is what Lag Goggles says: https://i.imgur.com/PVoFJ08.png but its not very useful as it refers to potentialspawns which is just an event handler, It must be an issue somewhere in the rules checking.

Here is the potentialspawns rule file which was being used: https://paste.dimdev.org/olasajevic.json

If I manage to pinpoint the issue I will let you know / attempt a fix.

Thanks

commented

Did you check how many mobs are actually spawned? Couldn't it be that there are too many mobs caused by these rules?

commented

I just checked your rule file and you are using several pretty expensive tests. For example 'maxcount' is not cheap as it actually has to count the number of mobs. One tip that might help to make this more efficient is to add more lines like:

  "random":0.1,

To have every rule only work 1 in 10 times

commented

I killed all entities and checked the tick straight after, was still below 20 (12-15), I've also had thousands more entities than normal because of past mistakes and still no tick lag, so I assume the entities would have to reach a very stupid amount before they were a factor.

And I agree, there is some very expensive tests here, but since switching out to spawns.json and using another mod to spawn mobs I've had no issues as of yet.

commented

Removing the maxcount out of potentialspawn and using the random 0.1 (or whatever) trick would help too

commented

I will try that and let you know how things go, I believe we could optimize maxCount by having a global counter which increments and decrements each time an entity spawns / gets removed, storing to some sort of map instead of recounting each time what do you think?

Spawn: MobCounts.increment("minecraft:zombie");
Despawn: MobCounts.decrement("minecraft:zombie");

Check: checks.add((event, query) -> { int count = MobCounts.get(entityClass); return count < amount; });

commented

Not sure if that would work well. In Control cannot detect all possible ways that entities spawn. Mods can do manual spawnEntity without calling any event and we would never know. I think optimizing would be nice but I'm not sure that keeping a cache is the way to go here.

commented

We have 2 methods, we could using LivingEntityUpdate event I believe is what its called? Which should always run for each mob instance, and then add to map if not already, Or.. We could add in another boolean (When set true) it will use a cached count from the spawn events which InControl uses (Gives the user a potential optimization in the cases they don't use a custom mob spawner) I also don't mind adding individual support for counting mobs added by other mods upon user request.

commented

Hey, just wondering if this is still an issue as of the latest 1.12 version? Im wondering whether to use this mod or a different one for all my custom spawns

commented

This should be resolved by now. Sorry for not closing