github.com/sagansystems/goofys-app@v0.19.1-0.20180410053237-b2302fdf5af9/bench/run_bench.sh (about)

     1  #!/bin/bash
     2  
     3  set -o errexit
     4  set -o nounset
     5  set -o pipefail
     6  
     7  : ${BUCKET:="goofys-bench"}
     8  : ${FAST:="false"}
     9  : ${CACHE:="false"}
    10  : ${ENDPOINT:="http://s3-us-west-2.amazonaws.com/"}
    11  
    12  if [ $# = 1 ]; then
    13      t=$1
    14  else
    15      t=
    16  fi
    17  
    18  dir=$(dirname $0)
    19  
    20  mkdir bench-mnt
    21  
    22  if [ ! -f ~/.passwd-riofs ]; then
    23      echo "RioFS password file ~/.passwd-riofs missing"
    24      exit 1;
    25  fi
    26  source ~/.passwd-riofs
    27  
    28  S3FS_CACHE="-ouse_cache=/tmp/cache"
    29  GOOFYS_CACHE="--cache /tmp/cache -o allow_other"
    30  
    31  if [ "$CACHE" == "false" ]; then
    32      S3FS_CACHE=""
    33      GOOFYS_CACHE=""
    34  fi
    35  
    36  S3FS_ENDPOINT="-ourl=$ENDPOINT"
    37  GOOFYS_ENDPOINT="--endpoint $ENDPOINT"
    38  
    39  if echo "${ENDPOINT}" | fgrep -q amazonaws.com; then
    40      S3FS_ENDPOINT="${S3FS_ENDPOINT} -oiam_role=auto"
    41  else
    42      echo "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" > /etc/passwd-s3fs
    43      chmod 0400 /etc/passwd-s3fs
    44      S3FS_ENDPOINT="${S3FS_ENDPOINT} -ouse_path_request_style -osigv2"
    45      # s3proxy is broken https://github.com/andrewgaul/s3proxy/issues/240
    46      GOOFYS_ENDPOINT="${GOOFYS_ENDPOINT} --cheap"
    47  fi
    48  
    49  export BUCKET
    50  export ENDPOINT
    51  perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' $dir/riofs.conf.xml
    52  
    53  S3FS="s3fs -f -ostat_cache_expire=1 ${S3FS_CACHE} ${S3FS_ENDPOINT} $BUCKET bench-mnt"
    54  RIOFS="riofs -f -c $dir/riofs.conf.xml $BUCKET bench-mnt"
    55  GOOFYS="goofys -f --stat-cache-ttl 1s --type-cache-ttl 1s ${GOOFYS_CACHE} ${GOOFYS_ENDPOINT} $BUCKET bench-mnt"
    56  LOCAL="cat"
    57  
    58  iter=10
    59  if [ "$FAST" != "false" ]; then
    60      iter=1
    61  fi
    62  
    63  for fs in riofs s3fs goofys; do
    64      case $fs in
    65          s3fs)
    66              FS=$S3FS
    67              CREATE_FS=$FS
    68              ;;
    69          riofs)
    70              FS=$RIOFS
    71              # riofs lies when they create files
    72              CREATE_FS=$GOOFYS
    73              ;;
    74          goofys)
    75              FS=$GOOFYS
    76              CREATE_FS=$FS
    77              ;;
    78          cat)
    79              FS=$LOCAL
    80              CREATE_FS=$FS
    81              ;;
    82      esac
    83      
    84  
    85      rm $dir/bench.$fs 2>/dev/null || true
    86  
    87      if [ "$t" = "" ]; then
    88          if [ "$CACHE" = "true" ]; then
    89              $dir/bench.sh "$FS" bench-mnt io |& tee -a $dir/bench.$fs
    90              $dir/bench.sh "$GOOFYS" bench-mnt cleanup |& tee -a $dir/bench.$fs
    91          else
    92              for tt in create create_parallel io; do
    93                  $dir/bench.sh "$FS" bench-mnt $tt |& tee -a $dir/bench.$fs
    94                  $dir/bench.sh "$GOOFYS" bench-mnt cleanup |& tee -a $dir/bench.$fs
    95              done
    96  
    97              $dir/bench.sh "$CREATE_FS"  bench-mnt ls_create
    98  
    99              for i in $(seq 1 $iter); do
   100                  $dir/bench.sh "$FS" bench-mnt ls_ls |& tee -a $dir/bench.$fs
   101              done
   102  
   103              $dir/bench.sh "$GOOFYS" bench-mnt ls_rm
   104  
   105              $dir/bench.sh "$CREATE_FS" bench-mnt find_create |& tee -a $dir/bench.$fs
   106              $dir/bench.sh "$FS" bench-mnt find_find |& tee -a $dir/bench.$fs
   107              $dir/bench.sh "$GOOFYS" bench-mnt cleanup |& tee -a $dir/bench.$fs
   108          fi
   109  
   110      else
   111          if [ "$t" = "find" ]; then
   112              $dir/bench.sh "$CREATE_FS" bench-mnt find_create |& tee -a $dir/bench.$fs
   113              $dir/bench.sh "$FS" bench-mnt find_find |& tee -a $dir/bench.$fs
   114              $dir/bench.sh "$GOOFYS" bench-mnt cleanup |& tee -a $dir/bench.$fs
   115          else
   116              $dir/bench.sh "$FS" bench-mnt $t |& tee $dir/bench.$fs
   117          fi
   118      fi
   119  done
   120  
   121  $dir/bench.sh cat bench-mnt $t |& tee $dir/bench.local
   122  
   123  $dir/bench_format.py <(paste $dir/bench.goofys $dir/bench.s3fs $dir/bench.riofs) > $dir/bench.data
   124  
   125  if [ "$CACHE" = "true" ]; then
   126      gnuplot $dir/bench_graph_cached.gnuplot && convert -rotate 90 $dir/bench.png $dir/bench.png
   127  else
   128      gnuplot $dir/bench_graph.gnuplot && convert -rotate 90 $dir/bench.png $dir/bench.png
   129  fi
   130  
   131  $GOOFYS >/dev/null &
   132  PID=$!
   133  
   134  sleep 5
   135  
   136  for f in $dir/bench.goofys $dir/bench.s3fs $dir/bench.riofs $dir/bench.data $dir/bench.png; do
   137      cp $f bench-mnt/
   138  done
   139  
   140  kill $PID
   141  fusermount -u bench-mnt || true
   142  sleep 1
   143  rmdir bench-mnt