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

Profiler: Add Tracy backend #4300

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

neobrain
Copy link
Member

@neobrain neobrain commented Jan 23, 2025

Overview

The existing GPUVis backend isn't suitable for live-profiling and carries heavy overhead per traced event (a memory allocation and a system call). This makes gathering accurate data for quantitative analysis impossible.

This PR adds a new backend for FEX's profiler interface based on Tracy, a nanosecond resolution profiler with support for live tracing and a rich feature set. Notably, statistics and histograms are generated from profiled zones out-of-the-box.

To use this backend, one of the environment variables FEX_PROFILE_TARGET_NAME
or FEX_PROFILE_TARGET_PATH must be defined to select the application under
profile by name or by path suffix.

Here's an example screenshot of the profiler view while running God of War (a very JIT-time heavy title). I'll post more screenshots as comments below.

20250123_fex_tracy_general

Usage

  1. Build FEX with ENABLE_FEXCORE_PROFILER=ON and FEXCORE_PROFILER_BACKEND=tracy
  2. Build the Tracy profiler in External/tracy/profiler using CMake and run using tracy-profiler -a ::
  3. Launch a game using FEX_PROFILE_TARGET_NAME=Celeste.bin.x86_64 (matches app name) or FEX_PROFILE_TARGET_PATH=amd64/SuperMeatBoy (matches a path suffix)
    • Using a game's Steam launch options for these is a good way to automatically profile when using a profile-enabled FEX build

Future work

Plotting data

Tracy supports plotting data and creating pretty graphs out of it, which is easy to implement but will need new Profiler interfaces.

Frame markers

Integration with GL/Vulkan library forwarding allows us to detect where frames end, which is useful to recognize stuttering in a recorded profile.

@neobrain
Copy link
Member Author

neobrain commented Jan 23, 2025

Statistics for events like triggered SMC handling can be computed over any selected time range. This shows how many events happened (102) and plots a histogram of the various durations of each event instance.
20250123_fex_tracy_smc

@neobrain
Copy link
Member Author

neobrain commented Jan 23, 2025

Gameplay stuttering can be highlighted by detecting frame ends. Here's a screenshot showing an outlier frame that takes more than 16 ms due to JIT compilation:

2025_01_23_fex_tracy_frames

(This required integration with libGL/Vulkan forwarding, so it's not included in this PR.)

@neobrain neobrain force-pushed the feature_profiler_tracy branch from fe94fe0 to 7698229 Compare January 23, 2025 21:24
This differs from the existing GPUVis backend in a number of ways:
* Tracy is optimized for minimal overhead and nanosecond-resolution profiling
* Tracy supports live tracing (in addition to capture-based operation)
* Tracy has a richer feature set and a more polished UI (notably, statistics and histograms are generated out-of-the-box)
* GPUVis supports tracing multiple processes, whereas Tracy is single-process only

To use this backend, one of the environment variables FEX_PROFILE_TARGET_NAME
or FEX_PROFILE_TARGET_PATH must be defined to select the application under
profile by name or by path suffix.
@neobrain neobrain force-pushed the feature_profiler_tracy branch from 7698229 to 7650aef Compare January 23, 2025 21:27
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.

1 participant