Add profiling support through Tracy Profiler #1787
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This add profiling support through the Tracy Profiler
To use the profiler you can use the
profiling
orgpu_profiling
feature, for examplecargo run --features gpu_profiling
, just remember to launch Tracy first and wait for the connection. It's also helpful to add--noidle
to better stress the system, and in some cases to disable vsync with--novsync
I have also added a few profiling events, that covers most of the basic frame loop.
Below is a sample, with my screen refresh rate set to 60, matching the default 60 FPS that Neovide tries to maintain. On the surface it looks good, all frames are close to 16.66 ms. But if you look closely it's constantly missing the vsync (over 17ms), followed by a shorter frame to catch up. This will be fixed later, I just have to do some final cleanup for that pull request. Also note that there's almost no load on my system, when it's showing a static screen, you have to zoom in to see something else than
swap_buffers
, which is just a wait.This pull request also adds a
--profiling
build profile, which is basically release with debug symbols. This helps a bit with the sampling profiler part of tracy, but I haven't really used that. I did use the profiler of Visual Studio though, which works properly if you use this build profile.To run that you can do for example
cargo run --profile profiling --features profiling -- --noidle
NOTE: I decided to write my own integration, rather than the one provided by the
tracy-client
library, that one copies some strings, allocates and has extra overhead. I also wanted everything to get completely optimized out when the profiling is disabled.Regarding the enabling of the GPU profiling, for OpenGL, and this integration there's not much overhead, but I also have a Direct3D implementation, and for that there's some extra overhead, mostly because I can't modify Skia, so that's why it's good to be able to disable it, when you don't need the GPU part.
The Direct3D implementation will come in a later pull request, where I enable Direct3D support for Windows, that was required to get butter smooth frame rates there. The OpenGL support for Windows, especially in Windowed mode is sadly lacking, and it would just drop frames, for now apparent reason randomly, sometimes for almost 100ms.