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

Added a Perfetto python dump #382

Open
alecazam opened this issue Nov 6, 2023 · 6 comments
Open

Added a Perfetto python dump #382

alecazam opened this issue Nov 6, 2023 · 6 comments

Comments

@alecazam
Copy link

alecazam commented Nov 6, 2023

This uses the Catapult flame chart json format for timings. This can then be imported into Perfetto.

Allocations are displayed in tracks just like in the png, but with names, and the values can be zoomed in-out and scrolled through. Perfetto seems to keep trying to kill off this json, without offering an alternative, but it works okay for this.

Timestamp is the offset, and duration correspond to size. These are all displayed as timings (either ns or ms), but should all be drawn with rect corresponding to the sizes. Perfetto still doesn't have hover over the values to expand name/duration, but that would help here.

https://github.com/alecazam/kram/blob/main/scripts/GpuMemDumpPerfetto.py

Here's a screenshot of Perfetto with the default dump. "M" indicates free blocks, since empty string seems to break Perfetto. And I can't specify colors either. But unique names each get pseudo-colored in a block track.

image
@alecazam
Copy link
Author

alecazam commented Nov 6, 2023

Here's the output from the Sample.json file. This can be dropped onto the trace viewer at perfetto.dev.

GpuMemDumpSample.trace.zip

@alecazam
Copy link
Author

alecazam commented Nov 6, 2023

In Perfetto, hit ctrl+shift+P, set_timestamp_format to seconds. Then the seconds represent MB, and have vertical lines. Reading the values in seconds provides MB values when blocks are selected. This works great when all allocations have names, but this Sample.json barely has any. It's not a real example of a game capture which would have these details present.

@adam-sawicki-a
Copy link
Contributor

This is an interesting development. Thank you for sharing this. Although, one could say that using a profiler like this to visualize memory allocations, with allocation sizes faked into time units, is a bit hacky.

@alecazam
Copy link
Author

alecazam commented Nov 6, 2023

It's really no less of a hack than using a static png image to display what should be an interactive display that leaves out the blocks names of a heap. There's AMD Memory Visualizer and it curiously skips importing dump files from VMA. So that would be the next target I would say for a real UI.

Also Perfetto has a generic trace event api, but there's no Python API to it. But a C++ app could be built to call and build events that way. There is a heap profiler that feeds into Perfetto, so it's not just timings.

Also I think tagging aliasing in blocks would be useful for this (could skip) or draw them differently. Also for the MemVis to png.

@adam-sawicki-a
Copy link
Contributor

Yes, I agree, it would be best to develop an interactive GUI tools for browsing VMA JSON dumps.

Radeon Memory Visualizer is a completely different tool with different purpose and has nothing to do with VMA. It captures memory allocation events as made by DX12/Vulkan app on low level, directly from AMD graphics driver.

@alecazam
Copy link
Author

alecazam commented Nov 7, 2023

Sure, but RMV has many of the same visualizers. I will say that seeing unnamed blocks in the PNG was useful, but being able to see allocation names and sizes is a game changer. We used to just draw all this stuff in games using the gpu, and could bring it up in any game. There are apps like Tracy, Superluminal, etc that do this. But the code is pretty easy to write so long as it's not written using Vulkan.

image

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

No branches or pull requests

2 participants