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

JitCache: Software Profiling Restoration #12691

Merged
merged 5 commits into from Apr 12, 2024

Conversation

mitaclaw
Copy link
Contributor

@mitaclaw mitaclaw commented Apr 6, 2024

Software JIT profiling unceremoniously had its beginning in 2008, with a monolithic commit practically sneaking it in (ff0a613) and a follow-up commit to grant it life (0ba3948). Over the years, it was improved to support POSIX platforms (#1408) and followed the development of new JITs (#1224) (#1559) (#2429). Unfortunately, in the present day software JIT profiling has been left inaccessible on all fronts.

Profiling 5 0
MISSING: Software JIT profiling.
Last seen: June 29, 2018

In May 2015, an Android interface for software JIT profiling was added, but to my knowledge, was never used (#2394). In June 2018, DolphinWX was removed, leaving software JIT profiling inaccessible to desktop users (#6819). In April 2022, the code for software JIT profiling was repurposed for the Code Diff Tool (#8732). In March 2024, the Code Diff Tool was replaced by the Branch Watch Tool, leaving software JIT profiling once again unused (#12359).

I learned about software JIT profiling from my development of the aforementioned Branch Watch Tool and made it my mission to revive this dormant debugging feature of Dolphin's JITs. But I wasn't satisfied with simply hooking up old code with new code. With care, I have renovated software JIT profiling to use the chrono library to cut down on cross-platform complexity. From simple testing, there appears to be no discernible difference in performance between using std::chrono::steady_clock and using platform-native libraries such as QueryPerformanceCounter and clock_gettime. The MSVC STL steady_clock is even reportedly a wrapper for QueryPerformanceCounter. Still, if you would like to compare for yourself, simply change the following line to initialize the profile_blocks member as true and measure the max emulation speed before and after:

Software JIT profiling is a useful tool for understanding what parts of the JIT are eating up the most resources. It is true that the JITs support platform-specific profiling tools like Intel VTune and OProfile, but a built-in cross-platform alternative has its own merits. For that reason, I choose to rekindle this feature rather than extinguish it.

Profiling Qt
On Qt On Android

Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/JitInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/JitArm64/Jit.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/JitInterface.cpp Outdated Show resolved Hide resolved
Source/Android/app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
@mitaclaw mitaclaw force-pushed the jit-profiling-restoration branch 3 times, most recently from dcc402a to 599f3d0 Compare April 9, 2024 04:40
Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/Gekko.h Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/JitCommon/JitCache.h Show resolved Hide resolved
@mitaclaw
Copy link
Contributor Author

Just realized that, while it is possible to enable profiling without the debugging interface on desktop, it isn't possible to write the JIT block log dump in that situation. This limits profiling the JIT on desktop to just when other debugging features are also being put into recompiled code (mainly BranchWatch, but also some differences in JitAsm) . It might be worth looking into this limitation in the future.

@AdmiralCurtiss AdmiralCurtiss merged commit 0c1a763 into dolphin-emu:master Apr 12, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants