From 12ccbe6f1200c5a8efcbf672ba73cdcc656ef475 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 24 Apr 2024 14:50:05 +0200 Subject: [PATCH] Amend profiling documentation --- doc/developing/misc.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/developing/misc.md b/doc/developing/misc.md index dfecd031d..1d3d8c941 100644 --- a/doc/developing/misc.md +++ b/doc/developing/misc.md @@ -4,7 +4,7 @@ We will be using a tool called "perf", which you can get by installing `perf` or `linux-perf` or `linux-tools-common`. -For best results build Minetest and Irrlicht with debug symbols +To get usable results you need to build Minetest with debug symbols (`-DCMAKE_BUILD_TYPE=RelWithDebInfo` or `-DCMAKE_BUILD_TYPE=Debug`). Run the client (or server) like this and do whatever you wanted to test: @@ -17,3 +17,22 @@ This will leave a file called "perf.data". You can open this file with perf built-in tools but much more interesting is the visualization using a GUI tool: **[Hotspot](https://github.com/KDAB/hotspot)**. It will give you flamegraphs, per-thread, per-function views and much more. + +### Remote Profiling + +Attach perf to your running server, press *^C* to stop: +```bash +perf record -z --call-graph dwarf -F 400 -p "$(pidof minetestserver)" +``` + +Collect a copy of the required libraries/executables: +```bash +perf buildid-list | grep -Eo '/[^ ]+(minetestserver|\.so)[^ ]*$' | \ + tar -cvahf debug.tgz --files-from=- --ignore-failed-read +``` + +Give both files to the developer and also provide: +* Linux distribution and version +* commit the source was built from and/or modified source code (if applicable) + +Hotspot will resolve symbols correctly when pointing the sysroot option at the collected libs.