try qrenderdoc python #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Debugging and Profiling Workflow for OpenKeeper | |
| # | |
| # This workflow automates graphics and performance profiling using RenderDoc and async-profiler. | |
| # | |
| # - RenderDoc is used to capture a frame after 20s, then postprocesses the .rdc for draw call analysis. | |
| # - async-profiler is used to capture CPU, memory, and file IO profiles, and generates flamegraphs. | |
| # | |
| # See: https://github.com/tonihele/OpenKeeper/wiki/Debugging-and-Profiling | |
| name: Debugging and Profiling | |
| on: | |
| workflow_dispatch: | |
| push: | |
| permissions: | |
| contents: read | |
| env: | |
| DK2_DEMO_URL: 'https://archive.org/download/DungeonKeeper2Demo/DungeonKeeper2Demo.exe' | |
| jobs: | |
| setup-dk2: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Cache DK2 Demo | |
| id: cache-dk2 | |
| uses: actions/cache@v4 | |
| with: | |
| key: dk2-demo | |
| lookup-only: true | |
| path: | | |
| DK2 | |
| openkeeper.properties | |
| /home/runner/.OpenKeeper/openkeeper.properties | |
| - name: Download | |
| if: steps.cache-dk2.outputs.cache-hit != 'true' | |
| run: | | |
| set -eux | |
| curl -sS -L -OJ "$DK2_DEMO_URL" | |
| sudo apt install -y 7zip unshield | |
| 7z x DungeonKeeper2Demo.exe | |
| unshield x disk1/data1.cab | |
| mv Program_Files DK2 | |
| echo "DungeonKeeperIIFolder(string)=$PWD/DK2/" > openkeeper.properties | |
| mkdir -p ~/.OpenKeeper | |
| echo -e "Width(int)=1280\nHeight(int)=720\nMusicEnabled(bool)=false\nVoiceEnabled(bool)=false\nSfxEnabled(bool)=false" > ~/.OpenKeeper/openkeeper.properties | |
| #- uses: mxschmitt/action-tmate@v3 | |
| # timeout-minutes: 15 | |
| renderdoc-capture: | |
| name: RenderDoc Capture and Analysis | |
| needs: setup-dk2 | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'graalvm' | |
| - uses: actions/cache/restore@v4 | |
| with: | |
| key: dk2-demo | |
| fail-on-cache-miss: true | |
| path: | | |
| DK2 | |
| openkeeper.properties | |
| /home/runner/.OpenKeeper/openkeeper.properties | |
| - name: Install dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y xvfb xdotool wget unzip libvulkan1 | |
| - name: Install RenderDoc | |
| run: | | |
| wget -nv https://renderdoc.org/stable/1.39/renderdoc_1.39.tar.gz -O renderdoc.tar.gz | |
| sudo tar xv --strip-components=1 -C /usr/local -f renderdoc.tar.gz | |
| #export PATH=$PWD/renderdoc_1.39/bin:$PATH | |
| ls /usr/local/** | |
| - name: Build | |
| run: ./gradlew shadowJar --no-daemon | |
| - name: Start Xvfb | |
| run: | | |
| Xvfb :99 -screen 0 1280x720x24 & | |
| echo "DISPLAY=:99" >> $GITHUB_ENV | |
| - name: Launch and capture | |
| run: | | |
| set -eux | |
| #renderdoccmd capture --wait-for-exit --opt-hook-children ./gradlew run --no-daemon --args="-debug -level Conquest" & | |
| renderdoccmd capture -w -d `pwd` --capture-file OpenKeeper java -jar build/libs/OpenKeeper-1.0.jar -debug -level Conquest & | |
| sleep 30 | |
| #pid=$(pgrep -f 'java.*OpenKeeper') | |
| #window_id=$(xdotool search --pid $pid | head -n1) | |
| #window_arg=${window_id:+--window $window_id} | |
| window_arg= | |
| xdotool key $window_arg F12 | |
| sleep 3 | |
| xdotool key $window_arg Print | |
| sleep 2 | |
| #kill $pid | |
| xdotool key $window_arg Escape | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: renderdoc-capture | |
| path: | | |
| *.rdc | |
| ~/.OpenKeeper/SCRSHOTS/*.png | |
| if-no-files-found: error | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.6' | |
| - name: Postprocess .rdc for draw call analysis | |
| run: | | |
| qrenderdoc --ui-python .github/scripts/renderdoc_drawcalls.py *.rdc | |
| export | |
| export PYTHONPATH="$PYTHONPATH:/usr/local/share/renderdoc/pylibs/lib/python3.6/ | |
| #python .github/scripts/renderdoc_drawcalls.py *.rdc | |
| shell: bash | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: renderdoc-drawcalls | |
| path: drawcalls.csv | |
| jfr-profiler: | |
| name: JFR Profiler | |
| runs-on: ubuntu-latest | |
| needs: setup-dk2 | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'graalvm' | |
| - uses: actions/cache/restore@v4 | |
| with: | |
| key: dk2-demo | |
| fail-on-cache-miss: true | |
| path: | | |
| DK2 | |
| openkeeper.properties | |
| /home/runner/.OpenKeeper/openkeeper.properties | |
| - name: Build | |
| run: ./gradlew shadowJar --no-daemon | |
| - name: Start Xvfb | |
| run: | | |
| Xvfb :99 -screen 0 1280x720x24 & | |
| echo "DISPLAY=:99" >> $GITHUB_ENV | |
| - name: Run and profile | |
| env: | |
| JDK_JAVA_OPTIONS: '-XX:+PreserveFramePointer -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:StartFlightRecording=delay=30s,maxsize=10M,disk=false,dumponexit=true,filename=recording.jfr,settings=profile,path-to-gc-roots=true' | |
| run: | | |
| set -eux | |
| sudo apt update | |
| sudo apt install -y xdotool | |
| #sudo apt install -y linux-modules-extra-$(uname -r) | |
| sudo modprobe --verbose snd-dummy || true | |
| sudo sysctl kernel.perf_event_paranoid=0 | |
| sudo sysctl kernel.kptr_restrict=0 | |
| #./gradlew run --no-daemon --args="-level Conquest" & | |
| java -jar build/libs/OpenKeeper-1.0.jar -level Conquest & | |
| sleep 60 | |
| pid=$(pgrep -f 'java.*OpenKeeper') | |
| window_id=$(xdotool search --pid $pid | head -n1) | |
| window_arg=${window_id:+--window $window_id} | |
| xdotool key $window_arg Escape | |
| #kill $pid | |
| sleep 3 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jfr-recording | |
| path: '*.jfr' | |
| if-no-files-found: error | |
| - name: Install jfrconv | |
| run: | | |
| wget -nv https://github.com/async-profiler/async-profiler/releases/download/v4.1/async-profiler-4.1-linux-x64.tar.gz -O async-profiler.tar.gz | |
| sudo tar xv --strip-components=1 -C /usr/local -f async-profiler.tar.gz | |
| - name: Postprocess JFR | |
| run: | | |
| jfrconv --threads --dot -X ".+glfwSwapBuffers|.+emitEvent" --total --simple --highlight "State[.$]|Control|System" --title 'Time spent' recording.jfr | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: jfr-postprocessed | |
| path: recording.html | |
| async-profiler: | |
| name: Async Profiler | |
| runs-on: ubuntu-latest | |
| needs: setup-dk2 | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'graalvm' | |
| - uses: actions/cache/restore@v4 | |
| with: | |
| key: dk2-demo | |
| fail-on-cache-miss: true | |
| path: | | |
| DK2 | |
| openkeeper.properties | |
| /home/runner/.OpenKeeper/openkeeper.properties | |
| - name: Build | |
| run: ./gradlew shadowJar --no-daemon | |
| - name: Setup async-profiler | |
| run: | | |
| set -eux | |
| wget -nv https://github.com/async-profiler/async-profiler/releases/download/v4.1/async-profiler-4.1-linux-x64.tar.gz -O async-profiler.tar.gz | |
| sudo tar xv --strip-components=1 -C /usr/local -f async-profiler.tar.gz | |
| sudo sysctl kernel.perf_event_paranoid=0 | |
| sudo sysctl kernel.kptr_restrict=0 | |
| sudo rm -f /etc/apt/sources.list.d/azure-cli.sources | |
| sudo sed -i "s/$(lsb_release -cs)/plucky/g; s/$(lsb_release -rs)/25.04/g" /etc/apt/sources.list.d/* | |
| sudo apt update && sudo apt install -y ubuntu-dbgsym-keyring | |
| printf "deb http://ddebs.ubuntu.com %s main restricted universe multiverse\n" plucky{,-updates,-proposed} | \ | |
| sudo tee -a /etc/apt/sources.list.d/ddebs.list | |
| sudo apt update && sudo apt install -y -f xdotool gdb mesa-utils # mesa-libgallium=25.0.7-0ubuntu0.25.04.2 mesa-libgallium-dbgsym | |
| - name: Start Xvfb | |
| run: | | |
| Xvfb :99 -screen 0 1280x720x24 & | |
| echo "DISPLAY=:99" >> $GITHUB_ENV | |
| - name: Run and profile | |
| run: | | |
| set -eux | |
| asprof --help | |
| export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com/" | |
| gdb -batch -ex "set debuginfod enabled on" -ex "set verbose on" -ex "r" -ex "quit" --args glxinfo -B | |
| ./gradlew run --no-daemon --args="-level Conquest" & | |
| sleep 10 # asset conversion | |
| pid=$(pgrep -f 'java.*openkeeper.Main') | |
| asprof -d 15 -e wall -t -f startup.html $pid | |
| asprof -d 30 -e cpu --simple -t --cstack vmx -f cpu.html $pid | |
| asprof -d 30 --all -f recording.jfr $pid | |
| #kill $pid | |
| #window_id=$(xdotool search --pid $pid | head -n1) | |
| #window_arg=${window_id:+--window $window_id} | |
| window_arg= | |
| xdotool key $window_arg Escape | |
| sleep 1 | |
| jfrconv --threads --dot -X ".+glfwSwapBuffers|.+emitEvent" --total --simple --highlight "State[.$]|Control|System" --title 'Time spent' recording.jfr | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: async-profiler-outputs | |
| path: | | |
| *.jfr | |
| *.html | |
| if-no-files-found: error |