####################################################
# MariaDB Foundation – Performance Regression Test Script
# MDEV-37992: select with large IN-list has excessive mutex contention
# https://jira.mariadb.org/browse/MDEV-37992
#
# This script is part of the MariaDB Foundation's reproducible
# performance regression testing framework. It automates running
# the MDEV-37992 workload across multiple MariaDB versions under
# deterministic CPU conditions using TAF.
#
# Purpose: Captures the TAF parameters for running the sysbench points-covered
# workload used to investigate the version-specific PK lookup regression in
# MDEV-37992. This test case exists thanks to Mark Callaghan, who identified
# the workload pattern and its cross-version performance impact.
#
# Modify the variables below to adapt paths or versions for your environment.
####################################################

#!/bin/bash

# Execute from TAF main directory: /home/jeb/taf-perl

PROP="/home/jeb/taf-perl/properties/mariadb/MDEV37992.properties"
OUT="mdev37992.out"
INSTALL_DIR="/home/jeb/taf-perl/database_software_installs"

# Deterministic CPU behavior
sudo cpupower frequency-set -g performance >/dev/null 2>&1
sudo cpupower frequency-set -d 2100MHz >/dev/null 2>&1
sudo cpupower frequency-set -u 2100MHz >/dev/null 2>&1
echo 0 | sudo tee /sys/devices/system/cpu/cpufreq/boost >/dev/null 2>&1

###############################################
# MariaDB 10.4.34
###############################################
perl taf.pl \
  --properties=$PROP \
  --test-case-tag=MDEV37992_10.4.34_CACHED \
  --db-software-install-dir=$INSTALL_DIR/mariadb-10.4.34-linux-systemd-x86_64 \
  > $OUT 2>&1
sleep 5

###############################################
# MariaDB 11.8.4
###############################################
perl taf.pl \
  --properties=$PROP \
  --test-case-tag=MDEV37992_11.8.4_CACHED \
  --db-software-install-dir=$INSTALL_DIR/mariadb-11.8.4 \
  >> $OUT 2>&1
sleep 5

###############################################
# MariaDB 0e4aec4058
###############################################
perl taf.pl \
  --properties=$PROP \
  --test-case-tag=MDEV37992_0e4aec4058_CACHED \
  --db-software-install-dir=$INSTALL_DIR/mariadb-0e4aec4058440075a00f41 \
  >> $OUT 2>&1
sleep 5

###############################################
# MariaDB 12.3.3
###############################################
perl taf.pl \
  --properties=$PROP \
  --test-case-tag=MDEV37992_12.3.3_CACHED \
  --db-software-install-dir=$INSTALL_DIR/mariadb-12.3.3-linux-systemd-x86_64 \
  >> $OUT 2>&1
sleep 5

###############################################
# MariaDB 13.0.2
###############################################
perl taf.pl \
  --properties=$PROP \
  --test-case-tag=MDEV37992_13.0.2_CACHED \
  --db-software-install-dir=$INSTALL_DIR/mariadb-13.0.2-linux-systemd-x86_64 \
  >> $OUT 2>&1
