From: Mathieu Desnoyers Date: Tue, 30 Mar 2021 20:33:26 +0000 (-0400) Subject: tests: improve benchmark script X-Git-Tag: v2.12.2~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=57aff1c0cf6029088ea77d69ee7d5c83527c4cf1;p=lttng-ust.git tests: improve benchmark script Kill session daemon after script, conditionally drop caches if root (else it is forbidden to do so), handle cleanup on trap, use snapshot (flight recorder) tracing to benchmark ring buffer, output the result in nanoseconds, removing trailing numbers after dot. Before this, the test was pretty much always resulting in an output of "0s" extra overhead due to truncation of significant numbers in the output. Signed-off-by: Mathieu Desnoyers Change-Id: Ia7844f3a52821da972b24bf9f39158c24329f63a --- diff --git a/tests/benchmark/test_benchmark b/tests/benchmark/test_benchmark index c55e3027..9cffcbc3 100755 --- a/tests/benchmark/test_benchmark +++ b/tests/benchmark/test_benchmark @@ -15,28 +15,46 @@ plan_tests 1 : ${PROG_NOTRACING:="./$CURDIR/bench1 $NR_CPUS $NR_EVENTS"} : ${PROG_TRACING:="./$CURDIR/bench2 $NR_CPUS $NR_EVENTS"} +function signal_cleanup () +{ + killall lttng-sessiond +} + +trap signal_cleanup SIGTERM SIGINT + CMD_NOTRACING="$TIME '$PROG_NOTRACING >/dev/null 2>&1'" CMD_TRACING="$TIME '$PROG_TRACING >/dev/null 2>&1'" time_notrace=0 for i in $(seq $ITERS); do - echo 3 >/proc/sys/vm/drop_caches + if [[ $EUID -eq 0 ]]; then + echo 3 >/proc/sys/vm/drop_caches + fi time_notrace="$time_notrace+$(sh -c "$CMD_NOTRACING")" done + lttng-sessiond -d --no-kernel -lttng -q create +lttng -q create --snapshot lttng -q enable-event -u -a lttng -q start time_trace=0 for i in $(seq $ITERS); do - echo 3 >/proc/sys/vm/drop_caches + if [[ $EUID -eq 0 ]]; then + echo 3 >/proc/sys/vm/drop_caches + fi time_trace="$time_trace+$(sh -c "$CMD_TRACING")" done lttng -q stop lttng -q destroy +killall lttng-sessiond pass "Trace benchmark" -diag "Average tracing overhead per event is $(echo "scale=6;( ($time_trace) - ($time_notrace) ) / $ITERS / $NR_EVENTS" | bc -l)s" +S_PER_EVENT=$(echo "( ($time_trace) - ($time_notrace) ) / $ITERS / $NR_EVENTS" | bc -l) +NS_PER_EVENT=$(echo "$S_PER_EVENT * 1000000000" | bc -l) +# Remove fractions +NS_PER_EVENT=${NS_PER_EVENT%%.*} + +diag "Average tracing overhead per event is ${NS_PER_EVENT}ns"