From 20d2c9038aa6e1582d9f76ba866b250438887208 Mon Sep 17 00:00:00 2001 From: Robin Newhouse Date: Wed, 8 Feb 2023 19:49:47 +0000 Subject: [PATCH] Fix mini-benchmark The mini-benchmark.sh script failed to run in the latest Fedora distributions in GitLab CI. It requires `lscpu` resolved by installing util-linux. Additionally, executing the benchmark inside a Docker container had failed because of increased Docker security in recent updates. In particular the `renice` and `taskset` operations are not permitted. Neither are the required `perf` operations. https://docs.docker.com/engine/security/seccomp/ Allow these operations to fail gracefully, and test then skip `perf`, allowing the remaining benchmark activities to proceed. Other minor changes to the CI are included such as allowing sanitizer jobs to fail and using "needs" in the mini-benchmark pipeline. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- .gitlab-ci.yml | 5 ++++- support-files/mini-benchmark.sh | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2639fc579d7..8c2b4ae363d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -331,6 +331,7 @@ mysql-test-run-asan: needs: - "fedora-sanitizer: [-DWITH_ASAN=YES]" <<: *mysql-test-run-def + allow_failure: true artifacts: when: always # Also show results when tests fail reports: @@ -489,6 +490,8 @@ mini-benchmark: stage: test dependencies: - fedora + needs: + - fedora script: - ls -la rpm; rm -vf rpm/*.el?.* # Delete artifacts from Centos builds # Don't use cracklib, otherwise the Sysbench user password will be rejected @@ -503,7 +506,7 @@ mini-benchmark: - | mariadb --skip-column-names -e "SELECT @@version, @@version_comment" | tee /tmp/version grep $MARIADB_MAJOR_VERSION /tmp/version || echo "MariaDB didn't install properly" - - yum install -y sysbench procps-ng perf || yum install -y https://kojipkgs.fedoraproject.org//packages/luajit/2.0.4/3.el7/x86_64/luajit-2.0.4-3.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/sysbench/1.0.17/2.el7/x86_64/sysbench-1.0.17-2.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/ck/0.5.2/2.el7/x86_64/ck-0.5.2-2.el7.x86_64.rpm + - yum install -y sysbench procps-ng perf util-linux || yum install -y https://kojipkgs.fedoraproject.org//packages/luajit/2.0.4/3.el7/x86_64/luajit-2.0.4-3.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/sysbench/1.0.17/2.el7/x86_64/sysbench-1.0.17-2.el7.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/ck/0.5.2/2.el7/x86_64/ck-0.5.2-2.el7.x86_64.rpm - /usr/share/mysql/mini-benchmark - cp -av */sysbench-run-*.log */metrics.txt .. # Move files one level down so they can be saved as artifacts artifacts: diff --git a/support-files/mini-benchmark.sh b/support-files/mini-benchmark.sh index d5dd194bc3f..18de6dbec51 100755 --- a/support-files/mini-benchmark.sh +++ b/support-files/mini-benchmark.sh @@ -106,16 +106,29 @@ then done | sort -u > mariadbd-dependencies.txt # shellcheck disable=SC2046 debuginfo-install -y mariadb-server $(cat mariadbd-dependencies.txt) - - echo "Using 'perf' to record performance counters in perf.data files" - PERF="perf record -g --freq=99 --output=perf.data --timestamp-filename --pid=$MARIADB_SERVER_PID --" + + if [ ! $(perf record echo "testing perf" > /dev/null 2>&1) ] + then + echo "perf does not have permission to run on this system. Skipping." + PERF="" + else + echo "Using 'perf' to record performance counters in perf.data files" + PERF="perf record -g --freq=99 --output=perf.data --timestamp-filename --pid=$MARIADB_SERVER_PID --" + fi elif [ -e /usr/bin/perf ] then # If flamegraphs were not requested, log normal perf counters if possible - echo "Using 'perf' to log basic performance counters for benchmark" + + if [ ! $(perf stat echo "testing perf" > /dev/null 2>&1) ] + then + echo "perf does not have permission to run on this system. Skipping." + PERF="" + else + echo "Using 'perf' to log basic performance counters for benchmark" + PERF="perf stat -p $MARIADB_SERVER_PID --" + fi fi - PERF="perf stat -p $MARIADB_SERVER_PID --" # Run sysbench on another CPU if system has more than one available if [ "$(nproc)" -gt 1 ] @@ -133,10 +146,10 @@ uname -a echo echo "Set highest priority for MariaDB Server process ID $MARIADB_SERVER_PID" -renice --priority -20 --pid "$MARIADB_SERVER_PID" +renice --priority -20 --pid "$MARIADB_SERVER_PID" || echo "renice failed. Not setting priority." echo "Set CPU affinity 0 for MariaDB Server process ID $MARIADB_SERVER_PID" -taskset -cp 0 "$MARIADB_SERVER_PID" +taskset -cp 0 "$MARIADB_SERVER_PID" || echo "taskset failed. Not setting cpu affinity." mariadb -e " CREATE DATABASE IF NOT EXISTS sbtest;