TheCodex6824 / ThaumicAugmentation

A Thaumcraft addon for Minecraft 1.12 that tries to add new content that would fit in with the base mod.
https://minecraft.curseforge.com/projects/thaumic-augmentation
GNU Lesser General Public License v3.0
40 stars 31 forks source link

Small but suspicious TPS lag on `WardEventHandler.onWorldTick` #356

Closed Krutoy242 closed 9 months ago

Krutoy242 commented 1 year ago

My E2E-E server run with 9 people.

I noticed ~3% TPS caused by Thaumic Augmentation when profiling with Spark:

image

https://spark.lucko.me/dgYOuB47ke

debug.zip

As far as i get from source code, this part of TA somehow handling warding or something.

TheCodex6824 commented 1 year ago

That event handler is for stopping scheduled ticks on warded blocks. The intention behind blocking them is so that they don't change themselves into something else or otherwise react to their environment. As an example, this is how you can ward something like a redstone repeater and have its output not stop. To directly answer your questions:

Krutoy242 commented 1 year ago

Thank you for answer!

As far as I know disableWardFocus would completely disable whole warding mechanics? Can you make configurable option to just disable this "scheduled tick" mechanic?

TheCodex6824 commented 11 months ago

Thank you for answer!

As far as I know disableWardFocus would completely disable whole warding mechanics? Can you make configurable option to just disable this "scheduled tick" mechanic?

A bit late, but the answer is yes. I added a config option that disables what are IMO the biggest potential offenders for performance, since I think some may be worse than others depending on the modpack. They are:

Would that be ok with you?

Krutoy242 commented 11 months ago

Probably would be good.

ParzivalWolfram commented 10 months ago

I would request that you release this fix, as it's eating my in-progress modpack alive on a fairly beefy CPU. It comes and goes, but when it appears, it eats upwards of 60 milliseconds on its own.

TheCodex6824 commented 10 months ago

I would request that you release this fix, as it's eating my in-progress modpack alive on a fairly beefy CPU. It comes and goes, but when it appears, it eats upwards of 60 milliseconds on its own.

Do you mind sharing a trace of when that happens? If you don't want to share details about your modpack, just the relevant section is fine. 60ms is very much in "fix ASAP" territory. I might just have to do the more difficult optimization I mentioned before now.

ParzivalWolfram commented 10 months ago

I would request that you release this fix, as it's eating my in-progress modpack alive on a fairly beefy CPU. It comes and goes, but when it appears, it eats upwards of 60 milliseconds on its own.

Do you mind sharing a trace of when that happens? If you don't want to share details about your modpack, just the relevant section is fine. 60ms is very much in "fix ASAP" territory. I might just have to do the more difficult optimization I mentioned before now.

Upon testing the modpack in a server setting, the issue seems to go up exponentially per player, ~60ms worst case for singleplayer, ~145ms for two, and ~320ms(!!) for three, even if they're in the same location. The only logged symptoms are that the game takes 30 minutes or more to stop the aura threads after saving and exiting (the map is saved before this, so it's safe to kill the game/server at this point) and just generally not being able to keep up. I'm not near my machine at current, I'll post a trace the next chance I get.

TheCodex6824 commented 10 months ago

I would request that you release this fix, as it's eating my in-progress modpack alive on a fairly beefy CPU. It comes and goes, but when it appears, it eats upwards of 60 milliseconds on its own.

Do you mind sharing a trace of when that happens? If you don't want to share details about your modpack, just the relevant section is fine. 60ms is very much in "fix ASAP" territory. I might just have to do the more difficult optimization I mentioned before now.

Upon testing the modpack in a server setting, the issue seems to go up exponentially per player, ~60ms worst case for singleplayer, ~145ms for two, and ~320ms(!!) for three, even if they're in the same location. The only logged symptoms are that the game takes 30 minutes or more to stop the aura threads after saving and exiting (the map is saved before this, so it's safe to kill the game/server at this point) and just generally not being able to keep up. I'm not near my machine at current, I'll post a trace the next chance I get.

I'm still interested in that profiler trace, but are you sure it's the same issue? I'll fix it regardless, but I wouldn't expect this tick handler to grow based on player count like that unless they were all separated.

ParzivalWolfram commented 10 months ago

While waiting on my small group of testers to be available for proper traces, i've noticed that (in singleplayer at minimum,) once the ward effect is unlocked and the save is reloaded, the problem disappears, but removing the research with the thaumcraft debug commands and reloading again makes it reoccur. Looking at relevant source, I have no idea why that's happening, but my understanding of Java is limited at best. I will provide traces once I can coordinate a test that can properly show the issue with multiple people.

TheCodex6824 commented 9 months ago

The config option itself was released in the latest update (check the beta files on CurseForge). Optimization is planned for the future after I complete some other coremod infrastructure work. @ParzivalWolfram, if you ever get that trace feel free to open another issue, as it sounds different from this one.

Krutoy242 commented 9 months ago

Thanks!

P.S. CF beta file have wrong changelogs.

TheCodex6824 commented 9 months ago

Thanks!

P.S. CF beta file have wrong changelogs.

Which part of the changelog is wrong? It looks ok to me - are you looking at the right file? Since this is a beta update, you have to go down to the file list and select it, since the big suggested file at the top will only ever be releases updates. Here's the direct link.

Krutoy242 commented 9 months ago

Oh, my bad. You right, I checked wrong file. Sorry.

Krutoy242 commented 8 months ago

The CF launcher is what confused me Overwolf_5byhENgsgS