fsbench.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #! /bin/bash
  2. DEVICE="/dev/md1"
  3. WIDTH=32
  4. CHUNK=64
  5. FILE_SIZE=128 #1024
  6. FAST_SPEED=3650
  7. NUMA_CPU=4
  8. PYHST="/root/pyhst/pyhst.sh"
  9. PYHST_DATA="/home/csa/data/bench"
  10. FS_LIST="ext4 xfs ext2 jfs reiserfs btrfs"
  11. END_START=`expr $WIDTH '*' 2 - 2`
  12. END_END=`expr $WIDTH '*' 2`
  13. echo $DEVICE | grep "/dev/md" &> /dev/null
  14. if [ $? -eq 0 ]; then SUFFIX="p"; else SUFFIX=""; fi
  15. umount -l /mnt/slow &> /dev/null
  16. umount -l /mnt/fast &> /dev/null
  17. function partition {
  18. parted $DEVICE --script mklabel gpt
  19. parted $DEVICE --script rm 3 &> /dev/null
  20. parted $DEVICE --script rm 2 &> /dev/null
  21. parted $DEVICE --script rm 1 &> /dev/null
  22. parted $DEVICE --script mkpart primary 1GB 2TB
  23. parted $DEVICE --script mkpart primary ${END_START}TB ${END_END}TB
  24. parted $DEVICE --script mkpart primary 2TB 3TB
  25. }
  26. function format_ext4 {
  27. block=4 # in KB (4096)
  28. stride=`expr $CHUNK / $block`
  29. swidth=`expr $stride '*' $WIDTH`
  30. mkfs.ext4 -b 4096 -E stride=${stride},stripe-width=${swidth} $1 > /dev/null
  31. return 0
  32. }
  33. function format_ext2 {
  34. block=4 # in KB (4096)
  35. stride=`expr $CHUNK / $block`
  36. swidth=`expr $stride '*' $WIDTH`
  37. mkfs.ext2 -b 4096 -E stride=${stride},stripe-width=${swidth} $1 > /dev/null
  38. return 0
  39. }
  40. function format_xfs {
  41. mkfs.xfs -f -d su=${CHUNK}k,sw=${WIDTH} $1 > /dev/null
  42. mount -o noatime,allocsize=1GiB,largeio,swalloc $1 $2
  43. return 1
  44. }
  45. function format_xfsrt {
  46. mkfs.xfs -f -d su=${CHUNK}k,sw=${WIDTH} -r rtdev=$1,extsize=1g ${DEVICE}${SUFFIX}3 > /dev/null
  47. mount -o noatime,allocsize=1GiB,largeio,swalloc,rtdev=$1 ${DEVICE}${SUFFIX}3 $2
  48. return 1
  49. }
  50. function format_btrfs {
  51. sector=`expr $CHUNK '*' 1024`
  52. # mkfs.btrfs -s $sector -l $sector -n $sector $1 > /dev/null
  53. mkfs.btrfs $1 > /dev/null
  54. return 0
  55. }
  56. function format_jfs {
  57. mkfs.jfs -q $1 > /dev/null
  58. return 0
  59. }
  60. function format_reiserfs {
  61. mkfs.reiserfs -q $1 > /dev/null
  62. return 0
  63. }
  64. function bench_path {
  65. speed=$2
  66. res=`stdbuf -oL -eL ./fwbench.sh $1/testfile ${FILE_SIZE} $speed |tee /dev/stderr | tail -n 7 | sed -e ':a;N;$!ba;s/\n/@eol@/g'`
  67. echo $res | sed -e 's/@eol@/\n/g'
  68. res=`echo $res | sed -e 's/@eol@/\n/g' | tail -n 1 | cut -d ':' -f 2`
  69. if [ $res -gt 0 ]; then
  70. speed=$res
  71. fi
  72. stdbuf -oL -eL taskset -c $NUMA_CPU ./seqreader $1 | tee /dev/stderr | tail -n 5
  73. }
  74. function bench_device {
  75. speed=$2
  76. res=`stdbuf -oL -eL ./fwbench.sh $1 ${FILE_SIZE} $speed |tee /dev/stderr | tail -n 7 | sed -e ':a;N;$!ba;s/\n/@eol@/g'`
  77. echo $res | sed -e 's/@eol@/\n/g'
  78. res=`echo $res | sed -e 's/@eol@/\n/g' | tail -n 1 | cut -d ':' -f 2`
  79. if [ $res -gt 0 ]; then
  80. speed=$res
  81. fi
  82. stdbuf -oL -eL taskset -c $NUMA_CPU ./seqreader $1 ${FILE_SIZE} | tee /dev/stderr | tail -n 5
  83. }
  84. function bench_pyhst {
  85. data=$1/pyhst
  86. mkdir -p $data
  87. cat $PYHST_DATA/*.par | sed -e "s|@PATH@|$data|g" > $data/bench.par
  88. cp -r $PYHST_DATA/out_phase $data/
  89. echo 3 > /proc/sys/vm/drop_caches
  90. eval stdbuf -oL -eL $PYHST $data/bench.par 2>&1 | tee /dev/stderr | grep "Input/Output"
  91. }
  92. function test_fs {
  93. speed=`expr $FAST_SPEED + 50`
  94. formater="format_$1"
  95. eval $formater ${DEVICE}${SUFFIX}1 /mnt/fast
  96. if [ $? -eq 0 ]; then
  97. mount -o noatime ${DEVICE}${SUFFIX}1 /mnt/fast
  98. fi
  99. echo "Testing $1 (fast partition)"
  100. echo "=================================="
  101. bench_path /mnt/fast $speed
  102. echo
  103. echo "Testing $1 (PyHST)"
  104. echo "=================================="
  105. bench_pyhst /mnt/fast
  106. umount /mnt/fast
  107. echo
  108. eval $formater ${DEVICE}${SUFFIX}2 /mnt/slow
  109. if [ $? -eq 0 ]; then
  110. mount -o noatime ${DEVICE}${SUFFIX}2 /mnt/slow
  111. fi
  112. echo "Testing $1 (slow partition)"
  113. echo "=================================="
  114. bench_path /mnt/slow $speed
  115. umount /mnt/slow
  116. echo
  117. echo
  118. }
  119. function test_partition {
  120. speed=`expr $FAST_SPEED + 50`
  121. echo "Testing partition: $1"
  122. echo "=================================="
  123. bench_device $1 $speed
  124. echo
  125. }
  126. partition
  127. test_partition ${DEVICE}
  128. test_partition ${DEVICE}${SUFFIX}2
  129. for fs in $FS_LIST; do
  130. test_fs $fs
  131. done