godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Add an in-editor auditing tool for performance and correctness for Godot projects (similar to Lighthouse) #5068

Open timshannon opened 2 years ago

timshannon commented 2 years ago

Describe the project you are working on

A 3D FPS.

Describe the problem or limitation you are having in your project

PR https://github.com/godotengine/godot/pull/56490 recently got closed, and what was going to be a warning for a potential performance issue was changed to being simply handled in documentation. I completely agree with that choice, however it seems to me there is a gap between things that should be a warning (i.e. there is no need for it ever to be set this way) and something like the PR above where there may be legitimate scenarios where the setting is valid, but likely not.

See almost everything documented here: https://docs.godotengine.org/en/stable/tutorials/performance/index.html

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A similar situation arises with web development, and Google has a tool called lighthouse (https://github.com/GoogleChrome/lighthouse) which you can run against a webpage to spit out possible suggestions for improvements.

I propose a similar tool (or possibly incorporating it into the profiler) to identify possible incorrect, or poorly optimized implementations in a given scene.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I could see possibly adding another tab to the Debugger panel for "Optimization Audits": image

Combined with an editor setting that enables or disables Optimization Auditing.

When enabled it'll run a set of scripts that will check for specific issues and if found will add a line to a list on that tab with something along the lines of:

Finding Severity Reason Details
High Light Attenuation Low High attenuation values will negatively impact performance for 2 reasons: The light won't be culled as often. The light will cover more pixels, which have to be shaded individually. Scene: test.tscn Node: testNodeName

Ideally the Optimization Audit class could easily be extended so projects could add things to check for things within their own projects constraints.

Also it would be ideal if the constraints would taken into account the export targets. I.E. a mobile project would have a stricter set of optimizations compared to a desktop project.

If this enhancement will not be used often, can it be worked around with a few lines of script?

See next answer...

Is there a reason why this should be core and not an add-on in the asset library?

This could very easily be done in scripts or addons that get run either via the command line or as part of a one-off scene. However maintaining a set of high quality and accurate scripts, as well as deciding what range of values to use to get the most out of Godot may be better managed by the project as whole, where things like PRs and reviews could ensure the highest quality.

Calinou commented 2 years ago

I would probably name it to be a generic auditing panel, with several available categories (performance, accessibility, localization, …). Editor plugins should also be able to add their own diagnostics there.

There should also be a way to discard individual audits, e.g. by adding metadata to the specific node or resource in the form of a string array with the audit codes that should be ignored.

That said, I'm not sure if this new system is worth the added complexity. As an alternative, we could make it so node configuration warnings can be discarded using node metadata (using the aforementioned array of strings). This way, you can get rid of warnings you find annoying on specific nodes.