vsg::Profiler development underway #1115
robertosfield
started this conversation in
Show and tell
Replies: 1 comment
-
While there is still more work to do, I am happy enough to the present status of vsg::Profiler to merge with VSG master and vsgExamples master: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
Over the past few days I have been working on a vsg::Profiler class that is an vsg::Instrumentation implementation that captures CPU and GPU timing zones to a vsg::ProfileLog while the application runs and is able to report the results at completion.
The new class is still in development, but is far enough along for others to have a look and perhaps test it, the work in the Profiler branch of the VSG and vsgExamples:
/~https://github.com/vsg-dev/VulkanSceneGraph/tree/Profiler
/~https://github.com/vsg-dev/vsgExamples/tree/Profiler
To test out the functionality I have added vsg::Profiler support to vsgviewer, vsganimation, vsgdynamicload, vsgshadow and a new vsginstrumentation testbed example that I used for the initial development of the vsg::Profiler.
To assign the vsg::Profiler to collect stats you do something similar to what I've done to the above examples:
The main loop requires no changes so will look something like:
What the vsg::Profiler will do is record CPU and GPU time stamps placing the results into std::vectorvsg::ProfileLog::Entry, each time zoned has an enter and leave Entry, and each of these paired Entry objects has a uint64_t reference value that points index position of the other member of the pair. Each entry has various details recorded that allow applications to compute both time since start of application and the duration of zones.
To get the results we call finish on instrumentation/profiler object so it can get any of it's outstanding GPU results and then write them out to a stream, such as simply writing to the console:
When running:
The typical frame of output from ProfileLog::report(..) looks something like:
As this stand the vsg::Profiler is mainly about recording time stamps, threading info and code location info to the vsg::ProfileLog and the ProfileLog::report(..) is mainly there right now for development purposes, my hope is that this just the very first way to interrogate a ProfileLog and as time goes on will add both statistical analysis of the results and interactive tools.
One approach would be to have an ImGui interface to show all the data off, something that could be part of vsgImGui. The data stored in ProfileLog is similar to what Tracy records so there is potentially quite a bit one could do with the data. My thought for the near term is something quite simple would still be very helpful for users - even the OSG's on screen stats are helpful and is far less fine grained than what vsg::Profiler/ProfileLog can provide so I'm sure something pretty useful could be done even without the depth of stats that Tracy provides.
Why not just use Tracy? vsg::Profiler handle Vulkan better than Tracy and we can record logs to file and browse them/search them by hand, record traces and compare multiple runs so utilize them for unit tests that require no GUI interaction.
The initial kick for me to develop vsg::Profiler is to help track performance changes when I start optimize the shadow support and other parts of the VSG, so being able to run a standard animation path with a standard model then iterate the implementation to see how things progress in a way see actual figures for the CPU and GPU costs of different changes.
My hope is that others in the community will be inspired by vsg::Profiler and come up with neat ways to analyze and present the results. I don't yet have proper ImGui/ImPlot usage under my belt so others may be far better place to create an interface to ProfileLog.
Over the next few days I'll start using vsg::Profiler with my work on shadows so I expect I'll gain insights on what is useful and what other features are required. Once the new functionality looks solid I'll merge with VSG and vsgExamples master, perhaps even by end of week.
Beta Was this translation helpful? Give feedback.
All reactions