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 profiling support through Tracy Profiler #1787

Merged

Conversation

fredizzimo
Copy link
Member

@fredizzimo fredizzimo commented Mar 5, 2023

This add profiling support through the Tracy Profiler

To use the profiler you can use the profiling or gpu_profiling feature, for example

cargo 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.

Screenshot_20230305_020932

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.

@fredizzimo
Copy link
Member Author

I made some clippy fixes for when the profiling is enabled.

@fredizzimo fredizzimo force-pushed the fsundvik/add-profiling-support branch from d347cad to 1d65af1 Compare April 15, 2023 21:23
Cargo.toml Outdated Show resolved Hide resolved
@last-partizan last-partizan requested a review from Kethku June 5, 2023 18:37
Sometimes, when allocating the GpuCtx, the array can be created on the stack,
causing a stack overflow, so use a Vec instead.
Basically release with debug symbols
@fredizzimo fredizzimo force-pushed the fsundvik/add-profiling-support branch from 045e4fe to 7c0b4de Compare June 5, 2023 19:04
@last-partizan last-partizan merged commit 13f6f8f into neovide:main Jun 7, 2023
2 checks passed
falcucci pushed a commit to falcucci/neovide that referenced this pull request Jun 7, 2023
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