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

     1  #!/bin/bash
     2  set -e
     3  set -o pipefail
     4  
     5  SYSBENCH_TEST="oltp_point_select"
     6  WORKING_DIR=`mktemp -d`
     7  PPROF=0
     8  PORT=3366
     9  
    10  # parse options
    11  # superuser.com/questions/186272/
    12  while test $# -gt 0
    13  do
    14      case "$1" in
    15  
    16          --new-new) export DOLT_DEFAULT_BIN_FORMAT="__DOLT__" &&
    17              export ENABLE_ROW_ITER_2=true
    18              ;;
    19  
    20          --no-exchange) export SINGLE_THREAD_FEATURE_FLAG=true
    21              ;;
    22  
    23          # benchmark with pprof profiling
    24          --pprof) PPROF=1
    25              ;;
    26  
    27          # run dolt single threaded
    28          --single) export GOMAXPROCS=1
    29              ;;
    30  
    31          --row2) export ENABLE_ROW_ITER_2=true
    32              ;;
    33  
    34          --journal) export DOLT_ENABLE_CHUNK_JOURNAL=true
    35              ;;
    36  
    37          # specify sysbench benchmark
    38          *) SYSBENCH_TEST="$1"
    39              ;;
    40  
    41      esac
    42      shift
    43  done
    44  
    45  if [ ! -d "./sysbench-lua-scripts" ]; then
    46    git clone https://github.com/dolthub/sysbench-lua-scripts.git
    47  fi
    48  
    49  # collect custom sysbench scripts
    50  cp ./sysbench-lua-scripts/*.lua "$WORKING_DIR"
    51  cd "$WORKING_DIR"
    52  
    53  # make a sql-server config file
    54  cat <<YAML > dolt-config.yaml
    55  log_level: "info"
    56  
    57  behavior:
    58    read_only: false
    59    autocommit: true
    60  
    61  user:
    62    name: "user"
    63    password: "pass"
    64  
    65  listener:
    66    host: "0.0.0.0"
    67    port: $PORT
    68    max_connections: 128
    69    read_timeout_millis: 28800000
    70    write_timeout_millis: 28800000
    71  
    72  data_dir: .
    73  YAML
    74  
    75  # start a server
    76  mkdir sbtest
    77  cd sbtest
    78  dolt init
    79  cd ..
    80  dolt sql-server --config="dolt-config.yaml" 2> prepare.log &
    81  SERVER_PID="$!"
    82  
    83  # stop it if it crashes
    84  cleanup() {
    85    kill -15 "$SERVER_PID"
    86  }
    87  trap cleanup EXIT
    88  
    89  # setup benchmark
    90  echo "benchmark $SYSBENCH_TEST bootstrapping at $WORKING_DIR"
    91  
    92  sleep 1
    93  sysbench \
    94    --db-driver="mysql" \
    95    --mysql-host="0.0.0.0" \
    96    --mysql-port="$PORT" \
    97    --mysql-user="user" \
    98    --mysql-password="pass" \
    99    "$SYSBENCH_TEST" prepare
   100  
   101  # restart server to isolate bench run
   102  kill -15 "$SERVER_PID"
   103  
   104  # maybe run with pprof
   105  if [ "$PPROF" -eq 1 ]; then
   106    dolt --prof cpu sql-server --config="dolt-config.yaml" 2> run.log &
   107  else
   108    dolt sql-server --config="dolt-config.yaml" 2> run.log &
   109  fi
   110  SERVER_PID="$!"
   111  sleep 1
   112  
   113  
   114  # run benchmark
   115  echo "benchmark $SYSBENCH_TEST starting at $WORKING_DIR"
   116  
   117  sysbench \
   118    --db-driver="mysql" \
   119    --mysql-host="0.0.0.0" \
   120    --mysql-port="$PORT" \
   121    --mysql-user="user" \
   122    --mysql-password="pass" \
   123    --db-ps-mode=disable \
   124    --time=30 \
   125    --db-ps-mode=disable \
   126    "$SYSBENCH_TEST" run
   127  
   128  unset DOLT_ENABLE_CHUNK_JOURNAL
   129  unset DOLT_DEFAULT_BIN_FORMAT
   130  unset ENABLE_ROW_ITER_2
   131  unset SINGLE_THREAD_FEATURE_FLAG
   132  unset GOMAXPROCS
   133  
   134  echo "benchmark $SYSBENCH_TEST complete at $WORKING_DIR"
   135  if [ "$PPROF" -eq 1 ]; then
   136    # parse run.log to output the profile location
   137    head -n1 "$WORKING_DIR/run.log" | cut -d ":" -f 4
   138  fi
   139  echo ""