Dubwise56 / Dubs-Performance-Analyzer

Dubs Performance Analyzer
22 stars 3 forks source link

Caller count of harmony patched methods #12

Closed pardeike closed 2 years ago

pardeike commented 2 years ago

Hi,

people complain about Achtung calling this method too much and it costing tps: https://imgur.com/a/ick1dcF

The thing is, some mod calls it a lot and Achtund does a tiny patch on it: https://github.com/pardeike/Achtung2/blob/02039ddec2ac0ffa73a21fcde7a898cef13b9fb5/Source/Main.cs#L184

My feature request is a way that the analzyer can report who is calling the patched method. Because as of now, nobody really knows which mod is abusing ForbidUtility.InAllowedArea or one of the methods higher up in the stacktrace.

Maybe have a way to right click such a line and to activate stacktrace mode where it counts all mods in the trace and lists mods by high->low count for the clicked method only.

Thanks Andreas "Brrainz" Pardeike

Dubwise56 commented 2 years ago

when i had that problem with one of my mods i wrote a little patch to scrape the stack trace and count everything every time the method was called, which worked i found a mod spamming something millions of times or something so i changed my patch to a different method which they weren't spamming which resulted in the same functionality, i could maybe make it a function in the analyzer under the dev options tab in a user friendly way, maybe wiri already wrote something to do it, hes always tinkering with adding new features, but for now you should just try write a basic one just in your existing patch to find what mod is causing it so you can find a workaround or just flag that mod up with a warning or put it in a pin or something

pardeike commented 2 years ago

I just did that but after running my custom Achtung version it revealed that the stacktraces containing mods were not the ones with the high numbers.

Unfortunately there are many vanilla methods that are indirectly triggered by mods and thus the source of the problem is not revealed.

I will now replicate the problem on my dev machine and maybe as a side effect find a better way to detect the cause of such method spam.

simplyWiri commented 2 years ago

Analyzer does in fact have this functionality. In both steam / my (slightly ahead) fork.\ img

Is a screenshot from the person. You can direct them to view the StackTrace panel after selecting a method, the GUI is slightly more modern in my fork, and uses some Harmony 2.0.4 features to annotate how many mods patch methods which are included in the stack trace.

new_ui

Worth noting that the bug I was trying to fix in harmony is why it thinks there are no involved mods ^^

pardeike commented 2 years ago

Yeah, time to close this issue. It’s like fighting windmills. Vanilla is inefficient or some mod triggers things and that results in a spam of certain methods. Not really easy to track down in a generic way.

I still think I would want a way to sum up “work per pawn” even if it’s not done in tick. Maybe find most common ways to burn cpu and a way to trace back that to a given pawn, then sum it up. That way we could at least find out which pawns burn most cpu in a given moment (in the above example, it’s starving animals and their jobs)