You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virglrenderer/perf-testing/Docker/run_traces.sh

120 lines
2.8 KiB

perf: add scripts to build docker image and run perfetto trace analysis Most of the work of this MR was done by Tomeu. Changes: - update the Dockerfile to use the new virglrenderer tracing option - use command line parsing to pass the parameters when running a trace - move some files and rename scripts v2: - unify gfx-pps build (Tomeu) and use to suggested branch (Fahien) - use upstream tagged version for igt-gpu-tools (Tomeu) - add parameters to set benchmark loop count (Louis-Francis) - add parameter to set perfetto loop count or loopless run v3: - compile virglrenderer against minigbm (Rohan) - compile minigbm with driver i915 (Rohan) v4: Don't build mesa-gbm (instead of deleting the library and header later) v5: add option to run script whether to wait after each frame v6: correct gfx-pps version and add gdb v7: fix tag for gfx-pps v8: - when building the container use the user ID and group id of the user who runs the container build - rework passing command line parameters - add a command line parameter to record per-frame images - Use debugoptimized build for gfx-pps (Tomeu) v9: disable buffer storage, there seems to be a bug in context handling triggered by this v10: move to upstream kernel 5.9.12 v11: - remove writing txt version of host trace - add debug flagto enable tracing EGL - don't force-remove libgbm1 it is no longer a problem to have it v12: update kernel to 5.20.5 v13: refactor trace merge (Rohan) v14: - Fix refactoring (Rohan) - Add license infro to perfetto merge script Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Reviewed-By: Rohan Garg <rohan.garg@collabora.com>
4 years ago
# This script is to be run on the KVM guest
set -ex
mkdir /waffle
mount -t virtiofs waffle-tag /waffle
mkdir /apitrace
mount -t virtiofs apitrace-tag /apitrace
mkdir /traces-db
mount -t virtiofs traces-db-tag /traces-db
mkdir /perfetto
mount -t virtiofs perfetto-tag /perfetto
echo 3 > /proc/sys/kernel/printk
export PATH="/apitrace/build:$PATH"
export PATH="/waffle/build/bin:$PATH"
export LD_LIBRARY_PATH="/waffle/build/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export EGL_PLATFORM="surfaceless"
export WAFFLE_PLATFORM="surfaceless_egl"
export MESA_GL_VERSION_OVERRIDE="4.5"
export DISPLAY=
# Comment out any other sources, so it only syncs to the host via PTP
sed -i '/pool/s/^/#/' /etc/chrony/chrony.conf
echo refclock PHC /dev/ptp0 poll 1 dpoll -2 offset 0 >> /etc/chrony/chrony.conf
echo cmdport 0 >> /etc/chrony/chrony.conf
echo bindcmdaddress / >> /etc/chrony/chrony.conf
time chronyd -q # Initial synchronization, will take some time
chronyd # Keep clocks in sync
# Get trace cached
trace_base=$(cat /traces-db/current_trace)
if [ "x$trace_base" = "x" ]; then
echo "No trace given, bailing out"
exit 1
fi
command=$(cat /traces-db/command)
echo command=$command
WAIT=
RECORD=
benchmark_loops=0
perfetto_loops=10
for c in $command; do
val=(${c//=/ })
case "${val[0]}" in
benchmark)
benchmark_loops=${val[1]}
;;
perfetto)
perfetto_loops=${val[1]}
;;
wait-after-frame)
WAIT="--wait-after-frame"
;;
record-frame)
RECORD="--snapshot"
;;
esac
done
if [ -e /traces-db/wait_after_frame ]; then
WAIT=-wait-after-frame
fi
trace="/traces-db/${trace_base}.trace"
datadir="/traces-db/${trace_base}-out"
guest_perf="$datadir/${trace_base}-guest.perfetto"
cat "$trace" > /dev/null
# To keep Perfetto happy
echo 0 > /sys/kernel/debug/tracing/tracing_on
echo nop > /sys/kernel/debug/tracing/current_tracer
echo "Guest:"
wflinfo --platform surfaceless_egl --api gles2 -v
/perfetto/out/dist/traced &
/perfetto/out/dist/traced_probes &
sleep 1
/perfetto/out/dist/perfetto --txt -c /usr/local/perfetto-guest.cfg -o "$guest_perf" --detach=mykey
sleep 1
# The first virtio-gpu event has to be captured in the guest, so we correlate correctly to the host event
echo "Replaying for Perfetto:"
LOOP=
if [ "x$perfetto_loops" != "x" -a "x$perfetto_loops" != "x0" ]; then
LOOP="--loop=$perfetto_loops"
fi
eglretrace --benchmark --singlethread $LOOP $WAIT --headless "$trace"
sleep 1
/perfetto/out/dist/perfetto --attach=mykey --stop
chmod a+rw "$guest_perf"
if [ "x$benchmark_loops" != "x0" ]; then
echo "Measuring rendering times:"
eglretrace --benchmark --loop=$benchmark_loops --headless "$trace"
fi
if [ "x$RECORD" != "x" ]; then
eglretrace --snapshot frame --snapshot-prefix=${datadir}/ --headless "$trace"
fi