Add batch tests runner script 78/268978/7
authorAdam Michalski <a.michalski2@partner.samsung.com>
Wed, 5 Jan 2022 17:52:18 +0000 (18:52 +0100)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Fri, 21 Jan 2022 13:09:32 +0000 (14:09 +0100)
Change-Id: I3f809534cd71dfe906336f21db1ce403f924eca8

Makefile
benchmark/dbus-tools-batch-tests.sh [new file with mode: 0755]
packaging/dbus-tools.spec

index 786cf1362c0c74e8b414ac983129e25ccb7241f7..42d09a57381e51f70e84c5aee05a3cc798f3a9fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,3 +33,4 @@ install:
        cp benchmark/libdbus-p2p-server $(DESTDIR)/usr/bin/libdbus-p2p-server
        cp benchmark/libdbus-p2p-client $(DESTDIR)/usr/bin/libdbus-p2p-client
        cp benchmark/libdbus $(DESTDIR)/usr/bin/libdbus
+       cp benchmark/dbus-tools-batch-tests.sh $(DESTDIR)/usr/bin/dbus-tools-batch-tests.sh
diff --git a/benchmark/dbus-tools-batch-tests.sh b/benchmark/dbus-tools-batch-tests.sh
new file mode 100755 (executable)
index 0000000..f432689
--- /dev/null
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+# Large message size default arbitrarily set to 16 kB. Allows to get an idea of
+# how the latency values differ from the latencies for small message sizes.
+# Could easily be overriden with the `-l` option if necessary.
+LARGE_MSG_SIZE=16384
+
+# Small message size default arbitrarily set to 32 bytes. Assuming that D-Bus
+# header contains more information for the communication via the daemon than for
+# the peer to peer, 32 bytes seems to be the reasonable choice for a very small
+# message. However, the differences between 32, 64 and 128 byte messages are
+# negligible. Could be overriden with the `-s` option if necessary.
+SMALL_MSG_SIZE=32
+
+# Number of real tries. Should be at least 100000 if we want to make a
+# reasonable distribution graph of the latency values.
+REAL_TRIES=100000
+
+run_ipc_tests() {
+       if [ ! -d $1 ]; then
+               if mkdir $1; then
+                       echo "Subdirectory '$1' created" 1>&2
+               else
+                       echo "Cannot create '$1' subdirectory" 1>&2
+                       exit 1
+               fi
+       fi
+
+       p2p-gdbus -m $2 -l -r -t $3
+       gdbus -m $2 -l -r -t $3
+       libdbus -m $2 -l -r -t $3
+       libdbus-p2p-server -r &
+       # Give the server some time to run and start listening for a connection.
+       # Arbitrarily chosen 10 second delay seems to do the trick, even on
+       # a heavily loaded system.
+       sleep 10
+       LIBDBUS_P2P_TRY_COUNT=`expr $3 + 1000`
+       libdbus-p2p-client -m $2 -t $LIBDBUS_P2P_TRY_COUNT -d 50
+       pipe -m $2 -l -r -t $3
+       socket -m $2 -l -r -t $3
+       sharedmem -m $2 -l -r -t $3
+
+       mv p2pgdbus-latency.csv $1/
+       mv gdbus-latency.csv $1/
+       mv libdbus-latency.csv $1/
+       mv libdbus-p2p-latency.csv $1/
+       mv pipe-latency.csv $1/
+       mv socket-latency.csv $1/
+       mv sharedmem-latency.csv $1/
+}
+
+while [ $# -gt 0 ]
+do
+       case $1 in
+       -h)     printf "Usage: $0 [-l large_msg_size] [-s small_msg_size] [-r real_tries]\n"
+               exit 1
+               ;;
+       -l)     LARGE_MSG_SIZE=$2
+               shift
+               ;;
+       -s)     SMALL_MSG_SIZE=$2
+               shift
+               ;;
+       -r)     REAL_TRIES=$2
+               shift
+               ;;
+       -*)     printf "Wrong option: $1. Type \`$0 -h\` for help.\n" 1>&2
+               break
+               ;;
+       esac
+       shift
+done
+
+# tests without load
+run_ipc_tests no_load_small $SMALL_MSG_SIZE $REAL_TRIES
+run_ipc_tests no_load_large $LARGE_MSG_SIZE $REAL_TRIES
+
+# perfrom tests under load only when hackbench is present
+if [ ! -x /usr/bin/hackbench ]; then
+       echo "hackbench not installed. Cannot perform tests with load." 1>&2
+       exit 1
+fi
+
+# tests under heavy load
+
+# hackbench produces 40 processes times the value,
+# the resulting 560 processes is arbitrary but "a lot"
+readonly PROCESS_COUNT=14
+
+# enough messages to keep the rest of the system busy
+# throughout the entire dbus test
+readonly MESSAGE_COUNT=9900000
+
+hackbench --pipe --groups $PROCESS_COUNT --loops $MESSAGE_COUNT &
+HACKBENCH_PID=$!
+
+run_ipc_tests load_small $SMALL_MSG_SIZE $REAL_TRIES
+run_ipc_tests load_large $LARGE_MSG_SIZE $REAL_TRIES
+
+# since hackbench's managing process handles SIGTERM by broadcasting the signal
+# to every child process, it's enough to kill the main instance
+kill $HACKBENCH_PID
+
index 23d11eb6ec08448b7f4d053004ce98785b204f8a..1822d1150ef81c7b657f8482c946f2c35d3fe64e 100644 (file)
@@ -59,3 +59,4 @@ make
 %{_bindir}/libdbus-p2p-server
 %{_bindir}/libdbus-p2p-client
 %{_bindir}/p2p-gdbus
+%{_bindir}/dbus-tools-batch-tests.sh