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

Add methods for tracking memory allocations at a global level. #92206

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

Conversation

DarioSamo
Copy link
Contributor

@DarioSamo DarioSamo commented May 21, 2024

Currently the Memory class performs some form of allocation tracking but doesn't expose methods to query the counter. On top of that, we also lack a way to track which allocations were performed between different points of time, which hides pretty much any sign that there might be unnecessary allocations going on per frame.

I'm submitting this as a basic PR to use as my basis for reviewing any changes I make and tracking the impact with accurate numbers, as memory allocations are a heavy source of performance issues when they're in hot paths. For example, running the TPS demo and comparing the allocations reported by these indicators gives me about ~2000 per frame.

I'm leaving this as a draft since there's a bit of wiggle room in the design for this that we might want to discuss.

@rburing
Copy link
Member

rburing commented May 21, 2024

@Calinou
Copy link
Member

Calinou commented May 21, 2024

I suggest adding Performance monitors for this as well, so you can track this information in the Debugger > Monitors panel of the editor.

Also, is there a way of knowing the total size in bytes of the allocations performed in the last frame? This could also let us know the average size of allocations performed in the last frame by dividing this value with the number of allocations.

@DarioSamo
Copy link
Contributor Author

DarioSamo commented May 21, 2024

I suggest adding Performance monitors for this as well, so you can track this information in the Debugger > Monitors panel of the editor.

Sounds good to me.

Also, is there a way of knowing the total size in bytes of the allocations performed in the last frame? This could also let us know the average size of allocations performed in the last frame by dividing this value with the number of allocations.

Yes, we can add another atomic to track this, although the more we add the more I'm tempted to only enable them on debug builds to not add unnecessary costs. We could probably do that one with the current counter at the moment since it's never exposed, so nobody could actually have been using it so far.

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

Successfully merging this pull request may close these issues.

4 participants