Skip to content

Commit

Permalink
Fix mini-benchmark
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robinnewhouse authored and LinuxJedi committed Mar 8, 2023
1 parent 2458bad commit acb6684
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
27 changes: 20 additions & 7 deletions support-files/mini-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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;
Expand Down

0 comments on commit acb6684

Please sign in to comment.