Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[very rough draft] feat(dbg_function_profiler): add widget function profiler #3004

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

salinecitrine
Copy link
Collaborator

@salinecitrine salinecitrine commented May 11, 2024

Does something pretty similar to widget profiler, but more detailed, and focused on only the widgets that are explicitly profiled.

Using this at the same time as widget profiler will cause issues. Also make sure to unprofile or disable this widget before disabling a widget it's profiling.


Usage:

/profilewidget <widgetname>
instruments all functions in a widget

/unprofilewidget <widgetname>
uninstruments all functions in a widget

/profilereset
resets all stats and timers. it's recommended to use this whenever you change what kind of activity you're looking at, since without this, averages are over the whole time the function profiler has been enabled.

Screenshot 2024-05-11 082546

I'm mostly putting this in a PR so it's easier to share and discuss; I'm not in a rush to merge it, though that is something I am interested in eventually.

usage:

/profilewidget <widgetname>
instruments all functions in a widget
/unprofilewidget <widgetname>
uninstruments all functions in a widget
/profilereset
resets all stats and timers
@p2004a
Copy link
Collaborator

p2004a commented May 11, 2024

You are aware of profiling widgets with Tracy, correct?

@salinecitrine
Copy link
Collaborator Author

salinecitrine commented May 11, 2024

You are aware of profiling widgets with Tracy, correct?

I don't have much experience with that; when I tried out Tracy I had some trouble getting it capturing things properly.

Does profiling widgets always require switching to a custom engine?

I'm assuming Tracy would be a better choice in a lot of ways; the overhead from profiling with this widget is pretty heavy.

(this was a bit more something I was playing around with than a serious attempt at making a perfect profiler)

@p2004a
Copy link
Collaborator

p2004a commented May 11, 2024

I had some trouble getting it capturing things properly

You will need to be more specific, because maybe it was just user error ;). I believe Beherith used Tracy quite a bunch for Lua and I've not heard he had any issues.

Does profiling widgets always require switching to a custom engine?

Yes, using Tracy requires picking engine build with tracing enabled from https://engine-builds.beyondallreason.dev/, just because it might have some overhead (currently there isn't any I was able to measure) it's not on in production build. If that's a major inconvenience to BAR game dev, we consider making it more convenient by adding it as option to the launcher.

The game loading code is also entirely striping calls to Tracy instrumentation from Lua, so there is 0 impact on end players even with some tracing in place in Lua permanently.

And then Tracy also allows for different level of tracing, e.g. tracing memory allocations across engine is pretty heavy, so it's not enabled in the default profiling builds.

@salinecitrine
Copy link
Collaborator Author

Thanks for the explanation! I'll give it another try.

You will need to be more specific, because maybe it was just user error ;). I believe Beherith used Tracy quite a bunch for Lua and I've not heard he had any issues.

I'm pretty confident it was user error :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants