github.com/dolthub/dolt/go@v0.40.5-0.20240520175717-68db7794bea6/performance/scripts/local_tpcc.sh (about)

     1  #!/bin/bash
     2  set -e
     3  set -o pipefail
     4  
     5  WORKING_DIR=`mktemp -d`
     6  PPROF=0
     7  PORT=3366
     8  
     9  # parse options
    10  # superuser.com/questions/186272/
    11  while test $# -gt 0
    12  do
    13      case "$1" in
    14  
    15          # benchmark with new NomsBinFmt
    16          --new-nbf) export DOLT_DEFAULT_BIN_FORMAT="__DOLT__"
    17              ;;
    18  
    19          --new-new) export DOLT_DEFAULT_BIN_FORMAT="__DOLT__" &&
    20              export ENABLE_ROW_ITER_2=true
    21              ;;
    22  
    23          --no-exchange) export SINGLE_THREAD_FEATURE_FLAG=true
    24              ;;
    25  
    26          # benchmark with pprof profiling
    27          --pprof) PPROF=1
    28              ;;
    29  
    30          # run dolt single threaded
    31          --single) export GOMAXPROCS=1
    32              ;;
    33  
    34      esac
    35      shift
    36  done
    37  
    38  if [ ! -d "./sysbench-tpcc" ]; then
    39    git clone https://github.com/Percona-Lab/sysbench-tpcc.git
    40  fi
    41  
    42  # collect custom sysbench scripts
    43  cp ./sysbench-tpcc/*.lua "$WORKING_DIR"
    44  cd "$WORKING_DIR"
    45  
    46  # make a sql-server config file
    47  cat <<YAML > dolt-config.yaml
    48  log_level: "debug"
    49  
    50  behavior:
    51    read_only: false
    52    autocommit: true
    53  
    54  user:
    55    name: "user"
    56    password: "pass"
    57  
    58  listener:
    59    host: "0.0.0.0"
    60    port: $PORT
    61    max_connections: 128
    62    read_timeout_millis: 28800000
    63    write_timeout_millis: 28800000
    64  
    65  databases:
    66    - name: "sbtest"
    67      path: "."
    68  YAML
    69  
    70  # start a server
    71  dolt init
    72  dolt sql-server --config="dolt-config.yaml" 2> prepare.log &
    73  SERVER_PID="$!"
    74  
    75  # stop it if it crashes
    76  cleanup() {
    77    kill -15 "$SERVER_PID"
    78  }
    79  trap cleanup EXIT
    80  
    81  # setup benchmark
    82  echo "benchmark TPC-C bootstrapping at $WORKING_DIR"
    83  
    84  sleep 1
    85  
    86  ./tpcc.lua --db-driver="mysql" --mysql-db="sbtest" --mysql-host="0.0.0.0" --mysql-port="$PORT" --mysql-user="user" --mysql-password="pass" --time=10 --report_interval=1 --threads=2 --tables=1 --scale=1 --trx_level="RR" prepare
    87  
    88  # restart server to isolate bench run
    89  kill -15 "$SERVER_PID"
    90  
    91  # maybe run with pprof
    92  if [ "$PPROF" -eq 1 ]; then
    93    dolt --prof cpu sql-server --config="dolt-config.yaml" 2> run.log &
    94  else
    95    dolt sql-server --config="dolt-config.yaml" 2> run.log &
    96  fi
    97  SERVER_PID="$!"
    98  sleep 1
    99  
   100  # run benchmark
   101  echo "benchmark $SYSBENCH_TEST starting at $WORKING_DIR"
   102  
   103  ./tpcc.lua --db-driver="mysql" --mysql-db="sbtest" --mysql-host="0.0.0.0" --mysql-port="$PORT" --mysql-user="user" --mysql-password="pass" --time=10 --report_interval=1 --threads=2 --tables=1 --scale=1 --trx_level="RR" run
   104  
   105  echo "benchmark TPC-C complete at $WORKING_DIR"
   106  echo "DOLT_DEFAULT_BIN_FORMAT='$DOLT_DEFAULT_BIN_FORMAT'"
   107  echo ""
   108  
   109  unset DOLT_DEFAULT_BIN_FORMAT
   110  unset ENABLE_ROW_ITER_2
   111  unset SINGLE_THREAD_FEATURE_FLAG
   112  unset GOMAXPROCS