Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions hammerdb/hammerdb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ log_mount=""
pcp=""
pdir=""
script_dir=$(realpath $(dirname $0))
export script_dir
hmd_dir=${script_dir}/hammerdb-tpcc/Hammerdb
mkdir -p $hmd_dir
export hmd_dir

curdir=`pwd`
if [[ $0 == "./"* ]]; then
Expand Down Expand Up @@ -129,6 +133,7 @@ usage()

${TOOLS_BIN}/gather_data ${curdir}
source ${TOOLS_BIN}/general_setup "$@"
export to_pkg_tool_flags
export to_no_pkg_install

unset DISPLAY
Expand Down Expand Up @@ -289,7 +294,7 @@ if [[ $to_tuned_setting != "none" ]]; then
tuned_original=`tuned-adm active | cut -d' ' -f4`
tuned-adm profile $to_tuned_setting
fi
pushd /usr/local > /dev/null
pushd $hmd_dir > /dev/null
rm -rf $test
popd > /dev/null
cpdir=""
Expand All @@ -303,25 +308,16 @@ echo ./run_hammerdb -m /perf1 -t ${test} ${users_to_run} ${warehouses} ${log_mou
chmod 755 run_this
./run_this

cd /usr/local
mv HammerDB $test

${TOOLS_BIN}/move_data $curdir $test
pushd $test
files=`ls test*out`
if [ $? -ne 0 ]; then
echo Failed >> test_results_report
else
echo Ran >> test_results_report
fi

#pwd
#echo $hmd_dir $test
rm -rf $test
mv $hmd_dir $test
cp /tmp/hammerdb.out .
popd

tmp_file=`mktemp /tmp/hammer_data.XXXXX`
find -L $test -type f -exec grep -Iq . {} \; -print > $tmp_file
#echo "/usr/local/${test}/results_hammerdb_*.csv" >> $tmp_file
egrep "out|csv|report" $tmp_file | egrep -v "Hammerdb" | grep -v tcl | tar cf /tmp/results_hammerdb_${test}_${to_tuned_setting}.tar --files-from=/dev/stdin
grep -E "out|csv|report" $tmp_file | grep -v "Hammerdb" | grep -v tcl | tar cf /tmp/results_hammerdb_${test}_${to_tuned_setting}.tar --files-from=/dev/stdin
csv_file=`grep "csv" $tmp_file | grep -v "Hammerdb"`
${TOOLS_BIN}/csv_to_json $to_json_flags --csv_file $csv_file --output_file results_hammer.json
$TOOLS_BIN/verify_results $to_verify_flags --schema_file $script_dir/results_schema.py --class_name Hammerdb_Results --file results_hammer.json
Expand Down
1 change: 1 addition & 0 deletions hammerdb/hammerdb.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"bc",
"git",
"unzip",
"wget",
"zip"
],
"pip": [
Expand Down
15 changes: 15 additions & 0 deletions hammerdb/hammerdb_mssql.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dependencies": {
"rhel": [
"mssql-server",
"unixODBC-devel",
"gdb",
"cyrus-sasl",
"libatomic",
"lsof"
],
"pip": [
"typing-extensions"
]
}
}
25 changes: 25 additions & 0 deletions hammerdb/hammerdb_scripts/mariadb/build_mariadb.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/tclsh
#

puts "SETTING CONFIGURATION"

global complete
proc wait_to_complete {} {
global complete
set complete [vucomplete]
if {!$complete} {after 5000 wait_to_complete} else { exit }
}


dbset db mysql
diset connection mysql_host 127.0.0.1
diset connection mysql_port 3306
diset tpcc mysql_count_ware 500
diset tpcc mysql_partition true
diset tpcc mysql_num_vu 50
diset tpcc mysql_pass mysql
diset tpcc mysql_storage_engine innodb
print dict
buildschema
wait_to_complete
vwait forever
Comment thread
dvalinrh marked this conversation as resolved.
Binary file not shown.
69 changes: 69 additions & 0 deletions hammerdb/hammerdb_scripts/mariadb/my.cnf
Comment thread
dvalinrh marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[mysqld]
#large-pages
skip-log-bin
datadir=/perf1/mysql/data
port=3306
skip-networking=0
skip-bind-address
skip-grant-tables

# general
max_connections=4000
table_open_cache=8000
#table_open_cache_instances=16
back_log=1500
#default_password_lifetime=0
ssl=0
performance_schema=OFF
max_prepared_stmt_count=128000
skip_log_bin=1
character_set_server=latin1
collation_server=latin1_swedish_ci
transaction_isolation=REPEATABLE-READ

# files
innodb_file_per_table
innodb_log_file_size=1024M
innodb_log_files_in_group=32
innodb_open_files=4000

# buffers
innodb_buffer_pool_size=16384M
innodb_buffer_pool_instances=16
innodb_log_buffer_size=64M

# tune
innodb_doublewrite=0
innodb_thread_concurrency=0
innodb_flush_log_at_trx_commit=0
innodb_max_dirty_pages_pct=90
#innodb_max_dirty_pages_pct_lwm=10

join_buffer_size=32K
sort_buffer_size=32K
innodb_use_native_aio=1
#innodb_stats_persistent=1
innodb_spin_wait_delay=6

#innodb_max_purge_lag_delay=300000
#innodb_max_purge_lag=0
innodb_flush_method=O_DIRECT
#innodb_checksum_algorithm=none
#innodb_io_capacity=4000
#innodb_io_capacity_max=20000
#innodb_lru_scan_depth=9000
innodb_change_buffering=none
#innodb_read_only=0
#innodb_page_cleaners=4
#innodb_undo_log_truncate=off

# perf special
innodb_adaptive_flushing=1
#innodb_flush_neighbors=0
innodb_read_io_threads=16
innodb_write_io_threads=16
innodb_purge_threads=4
innodb_adaptive_hash_index=0

# monitoring
#innodb_monitor_enable='%'
111 changes: 111 additions & 0 deletions hammerdb/hammerdb_scripts/mariadb/run_mariadb_tpcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/sh
export PATH=$PATH:.:

LD_LIBRARY_PATH=/lib64/mariadb:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

## Set variables for the run
storagetype="Storage not specified"
Usercount="10 20 40 80 100"
whc="500"
DBRESTARTUP="n"
Testname="HDB_tpcc_mariadb"

usage()
{
echo "Usage:
run_mssql_tpcc.sh [-h] [-u users] [-t runlength] [-w warehouse count] [-s storage type]

Usage:
-h help
-u # of users (Default - "10 20 40 80 100")
-t runlength in minutes (Default - 15 minuteS)
-w warehouse count (Default - 500 )
-s storage type ( Default - "Storage not speficied" )

Examples:
run_mariadb_tpcc.sh -u "10 20 30"
Do runs with 10, 20 and 30 users
run_mariadb_tpcc.sh -s "nvme"
Do a 10 user, 500 warehouse, 15 minute run with storage type as "nvme"
run_mariadb_tpcc.sh -w 1000 -u "10 20 40 80 100" -s "iscsi"
Do a 1000 warehouse run with 10 20 40 80 and 100 users and storage type specified as iscsi
"
}

while [ $# -gt 0 ]
do
case $1 in
-h) usage;
exit;
;;
-w) whc=$2
shift 2
;;
-u) Usercount=$2
shift 2
;;
-s) storagetype=$2
shift 2
;;
-t) RUNLENGTH=$2
shift 2
;;
*) usage;
exit;
;;
esac
done

mkdir -p results

if [ -z "${benchmark_results_dir}" ]
then
benchmark_results_dir=`pwd`"/results"
fi

if [ -z "${benchmark_run_dir}" ]
then
benchmark_run_dir=`pwd`"/results"
fi

#echo ${storagetype}
#echo ${Usercount}
#echo ${benchmark_results_dir}
#echo ${whc}


## Collecting system information
benchmark_name="Hammerdb-tpcc"
benchmark_ver="HammerDB-3.2"
hostnm=`hostname -f`
hostip=`hostname -i`
numcpu=`nproc`
totmem=`cat /proc/meminfo |grep "MemTotal:" | awk '{print $2}'`
krel=`uname -r` ## Kernel


# Set Host IP and Warehouse Count in the tcl file
sed -i "s/^diset tpcc mysql_count_ware.*/diset tpcc mysql_count_ware ${whc}/" runtest_mariadb.tcl

echo "StartTime,EndTime,Hostname,Kernel,Database,DBVer,Cpus,Memory,StorageType,Users,Tpm" > user-benchmark-result.csv
mariaver=`mysql -V |awk '{print $5}' | sed -e 's/,//'`


for uc in ${Usercount}
do
echo "Restarting Database before each run"
systemctl restart mariadb.service
Comment thread
dvalinrh marked this conversation as resolved.
starttime=`date +%Y.%m.%d.%T`
echo "Run with ${uc} users"
sed -i "s/^vuset.*/vuset vu ${uc}/" runtest_mariadb.tcl
./hammerdbcli auto runtest_mariadb.tcl > test_mariadb_${Testname}_${uc}.out 2>&1
endtime=`date +%Y.%m.%d.%T`
grep RESULT test_mariadb_${Testname}_${uc}.out
tpm=`grep TPM test_mariadb_${Testname}_${uc}.out | awk '{print $7}'`
echo "\"${starttime}\",\"${endtime}\",\"${hostnm}\",\"${krel}\",\"Mariadb\",\"${mariaver}\",\"${numcpu}\",\"${totmem}\",\"${storagetype}\",\"${uc}\",\"${tpm}\"" >> user-benchmark-result.csv
cp user-benchmark-result.csv $benchmark_results_dir
cp /etc/my.cnf $benchmark_results_dir
cp test_mariadb_${Testname}_${uc}.out $benchmark_results_dir
done
systemctl stop mariadb.service
28 changes: 28 additions & 0 deletions hammerdb/hammerdb_scripts/mariadb/runtest_mariadb.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/tclsh
#

puts "SETTING CONFIGURATION"

global complete
proc wait_to_complete {} {
global complete
set complete [vucomplete]
if {!$complete} {after 5000 wait_to_complete} else { exit }
}

dbset db mysql
dbset bm TPC-C
diset connection mysql_host 127.0.0.1
diset connection mysql_port 3306
diset tpcc mysql_pass mysql
diset tpcc mysql_count_ware 500
diset tpcc mysql_driver timed
diset tpcc mysql_rampup 2
diset tpcc mysql_duration 15
loadscript
vuset vu 10
vucreate
vurun

wait_to_complete
vwait forever
23 changes: 23 additions & 0 deletions hammerdb/hammerdb_scripts/mssql/build_mssql.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/tclsh
#

puts "SETTING CONFIGURATION"

global complete
proc wait_to_complete {} {
global complete
set complete [vucomplete]
if {!$complete} {after 5000 wait_to_complete} else { exit }
}


dbset db mssqls
dbset bm TPC-C
diset connection mssqls_linux_server 127.0.0.1
diset connection mssqls_pass abcdefgh
diset tpcc mssqls_count_ware 500
diset tpcc mssqls_num_vu 40

buildschema
wait_to_complete
vwait forever
25 changes: 25 additions & 0 deletions hammerdb/hammerdb_scripts/mssql/createdb_mssql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Create database files
/opt/mssql-tools/bin/sqlcmd -U sa -P abcdefgh <<!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Hardcoded SA password spans multiple scripts. The password abcdefgh is hardcoded in createdb_mssql.sh, createdb_mssql_mnt.sh, and build_mssql.tcl. This creates a critical security vulnerability as anyone with repository access knows the admin credentials for all MSSQL instances. The shared root cause is the lack of a secure credential management strategy. Consider using environment variables (e.g., ${MSSQL_SA_PASSWORD}), a credential store, or integrated authentication across all three scripts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hammerdb/hammerdb_scripts/mssql/createdb_mssql.sh` at line 2, Replace the
hardcoded SA password used in the sqlcmd invocation (the line starting with
"/opt/mssql-tools/bin/sqlcmd -U sa -P abcdefgh") with a secure retrieval from an
environment variable (e.g., ${MSSQL_SA_PASSWORD}) in createdb_mssql.sh and make
the same change in createdb_mssql_mnt.sh and build_mssql.tcl; additionally, add
a guard that fails fast with a clear error if MSSQL_SA_PASSWORD is not set, and
consider switching to a credential store or integrated authentication where
available instead of embedding secrets in scripts.

drop database tpcc
go
Comment on lines +3 to +4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

DROP DATABASE fails if database doesn't exist.

The unconditional DROP DATABASE tpcc will fail on first run or if the database doesn't exist, causing the entire SQL batch to abort. Use DROP DATABASE IF EXISTS tpcc (supported in MSSQL 2016+) or wrap in error handling.

🔧 Suggested fix
-drop database tpcc
+IF EXISTS (SELECT name FROM sys.databases WHERE name = 'tpcc')
+BEGIN
+    DROP DATABASE tpcc
+END
 go
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
drop database tpcc
go
IF EXISTS (SELECT name FROM sys.databases WHERE name = 'tpcc')
BEGIN
DROP DATABASE tpcc
END
go
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hammerdb/hammerdb_scripts/mssql/createdb_mssql.sh` around lines 3 - 4, The
script currently runs an unconditional "DROP DATABASE tpcc" which will error if
the database does not exist; change this to use the idempotent form "DROP
DATABASE IF EXISTS tpcc" (or wrap the drop in TRY/CATCH) so the batch does not
abort on first run—update the statement in createdb_mssql.sh (the "DROP DATABASE
tpcc" line) to the IF EXISTS variant or add proper error handling around the
DROP DATABASE call.

CREATE DATABASE tpcc
ON PRIMARY
( NAME = MSSQL_data_1,
FILENAME = '/perf1/mssql_data/data/MSSQL_tpcc_Data_1.mdf',
SIZE = 32768MB,
FILEGROWTH = 20)
LOG ON
( NAME = MSSQL_tpcc_Log,
FILENAME = '/perf1/mssql_data/data/tpcc_Log.ldf',
SIZE = 20480MB,
FILEGROWTH = 500MB,
MAXSIZE = 270000MB)
go

ALTER DATABASE tpcc ADD FILE
( NAME = MSSQL_data_2, FILENAME = '/perf1/mssql_data/data/MSSQL_tpcc_Data_2.mdf', SIZE = 32768)
GO

exit
!
Comment on lines +1 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add shebang and error handling.

The script lacks both a shebang line and error handling. If the sqlcmd operation fails (e.g., due to MSSQL not running, permission issues, or disk space), the failure goes undetected and the wrapper proceeds as if database creation succeeded.

🔧 Suggested fix
+#!/bin/bash
+set -e
+
 # Create database files

The set -e will cause the script to exit on the first error, allowing the wrapper to detect the failure.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Create database files
/opt/mssql-tools/bin/sqlcmd -U sa -P abcdefgh <<!
drop database tpcc
go
CREATE DATABASE tpcc
ON PRIMARY
( NAME = MSSQL_data_1,
FILENAME = '/perf1/mssql_data/data/MSSQL_tpcc_Data_1.mdf',
SIZE = 32768MB,
FILEGROWTH = 20)
LOG ON
( NAME = MSSQL_tpcc_Log,
FILENAME = '/perf1/mssql_data/data/tpcc_Log.ldf',
SIZE = 20480MB,
FILEGROWTH = 500MB,
MAXSIZE = 270000MB)
go
ALTER DATABASE tpcc ADD FILE
( NAME = MSSQL_data_2, FILENAME = '/perf1/mssql_data/data/MSSQL_tpcc_Data_2.mdf', SIZE = 32768)
GO
exit
!
#!/bin/bash
set -e
# Create database files
/opt/mssql-tools/bin/sqlcmd -U sa -P abcdefgh <<!
drop database tpcc
go
CREATE DATABASE tpcc
ON PRIMARY
( NAME = MSSQL_data_1,
FILENAME = '/perf1/mssql_data/data/MSSQL_tpcc_Data_1.mdf',
SIZE = 32768MB,
FILEGROWTH = 20)
LOG ON
( NAME = MSSQL_tpcc_Log,
FILENAME = '/perf1/mssql_data/data/tpcc_Log.ldf',
SIZE = 20480MB,
FILEGROWTH = 500MB,
MAXSIZE = 270000MB)
go
ALTER DATABASE tpcc ADD FILE
( NAME = MSSQL_data_2, FILENAME = '/perf1/mssql_data/data/MSSQL_tpcc_Data_2.mdf', SIZE = 32768)
GO
exit
!
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hammerdb/hammerdb_scripts/mssql/createdb_mssql.sh` around lines 1 - 24, Add a
shebang (e.g., #!/bin/bash) at the top and enable strict error handling (use set
-euo pipefail) so the script exits on failure; ensure the block that invokes
/opt/mssql-tools/bin/sqlcmd is run with error checking and propagate non-zero
exit codes instead of silently continuing (refer to the sqlcmd invocation and
the existing exit marker in the here-doc), and optionally capture sqlcmd errors
to stderr before exiting so the caller/wrapper can detect and log failures.


Loading
Loading