From 95cc35b4e8e60d3b950bc2442b0ffaddd82499c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= Date: Wed, 28 Jun 2023 18:47:39 +0200 Subject: [PATCH] stress-tests: Improve stressing *hackbench* doesn't produce much load on a SMP system. A better way to stress the CPU is copying data from /dev/zero to /dev/null. Running *du* and *find* doesn't stress Linux very much. Most of it is optimised through caches. Better: run *dd* to copy the whole block device to /dev/null. To stress the network interface (but not your internet connection) send massive pings to the gateway. In a docker container this might be the system itself which wouldn't load the NIC. With the environment variable STRESS_SERVER you can set a different address. The tool *ip* used to find the gateway is in the package iproute2. --- stress-tests/Dockerfile | 2 +- stress-tests/stress-tests.sh | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/stress-tests/Dockerfile b/stress-tests/Dockerfile index cf7e717..19f8810 100644 --- a/stress-tests/Dockerfile +++ b/stress-tests/Dockerfile @@ -4,7 +4,7 @@ ARG IMAGE_TAG=2-bullseye FROM --platform=$IMAGE_ARCH torizon/debian:$IMAGE_TAG RUN apt update \ - && apt install -y --no-install-recommends iperf3 rt-tests iputils-ping \ + && apt install -y --no-install-recommends iperf3 rt-tests iputils-ping iproute2 \ && apt clean \ && rm -rf /var/lib/apt/lists/* diff --git a/stress-tests/stress-tests.sh b/stress-tests/stress-tests.sh index 3a5fe9b..2031bcb 100755 --- a/stress-tests/stress-tests.sh +++ b/stress-tests/stress-tests.sh @@ -3,11 +3,14 @@ echo "Setting up stress tests..." # CPU load -while true; do hackbench >/dev/null 2>&1; done & +for i in $(seq $(nproc)); do dd if=/dev/zero of=/dev/null bs=4M & done -# I/O load (eMMC read) -while true; do du /usr >/dev/null 2>&1; done & -while true; do find / -name a* >/dev/null 2>&1; done & +# I/O read load +for dev in /dev/mmcblk? /dev/sd?; do + test -b "$dev" || continue + + while true; do dd if="$dev" of=/dev/null bs=4M; done & +done # I/O load (USB read/write) if mount | grep /mnt/pendrive >/dev/null; then @@ -37,6 +40,9 @@ while true; do done done & +ping -A -f -t 3 -q -s 49152 \ + ${STRESS_SERVER:-$(ip route get 1.1.1.1 |sed '/.* via \([^ ]*\) .*/ s//\1/; q')} + echo "RT stress tests started successfully!" # Dont exit