Jump to content

Mod to identify slow mods?


Fwiffo

Recommended Posts

Has anyone taken a shot at a "profiling" mod for KSP to help track down slow or even buggy mods?  I'm thinking one might measure total time spent in functions owned by each mod (particularly during scene changes), and even intercept exceptions out of them to roughly track each mod's peak error rate.  I know this is a fairly advanced topic, but considering some of the crazy stuff other mods here have achieved (e.g. AssemblyReloader) I'm wondering if it's feasible and/or if anyone's tried.  And I'm thinking there must be some profiling scaffolding built into mono (to avoid having to go and manually hook each function).

Also what existing tools do you use to track this stuff down?  (e.g. Are there mono tools that would help?)

Edited by Fwiffo
Link to comment
Share on other sites

When 5.2 came out, we finally got access to Unity's profiler. If you've followed the plugin debugging guide (at least insofar as creating the PlayerConnectionConfigFile and using a dev version of the player) then you're already set up, just start up Unity, open the profiler window, make sure it's connected to the right thing and it'll work. This is very handy for both locating GC problems as well as performance bottlenecks. My only addition to that process is a little tool that inserts Profiler.BeginSample/EndSample into every method on a target assembly to find GC issues more easily.

With 5.4, there's an actual memory profiler + API available. I've been working on getting it to work but no luck so far

There's also a low-level API available in mono. I tried to make this work but all the timing and GC-watching code would have to exist in a native plugin, and with 5.2 being right around the corner at the time I ultimately abandoned that project

Link to comment
Share on other sites

Cool!  It's great to know the tooling and infrastructure are there.  It would be phenomenal for someone to release a mod that wraps all this up in a shiny, easy-to-use interface (or even plaintext log file) that makes it really easy to pinpoint slow or misbehaving mods at a glance ("ModStats...").

Going totally pie-in-the-sky, one could even normalize and crowdsource that data to create a global mod performance ranking list (thus gaming the system and subtly incentivizing developers to compete for high performance and stability rankings - or more realistically, helping them detect trends in their mods' performance and stability over time as codechanges are made).  Yeah, I know... way easier said than done :-).

This is above my head but I wonder if MemGraph already has some of the GC-watching code you mentioned.  Er, on second thought nevermind that last bit, I just noticed you said native plugin.

Edited by Fwiffo
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...