repro 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #!/bin/bash
  2. # Reproduce the Duoram experiments from our paper:
  3. # Sajin Sasy, Adithya Vadapalli, Ian Goldberg. PRAC: Round-Efficient
  4. # 3-Party MPC for Dynamic Data Structures
  5. # cd into the directory containing this script (from the bash faq 028)
  6. if [[ $BASH_SOURCE = */* ]]; then
  7. cd -- "${BASH_SOURCE%/*}/" || exit
  8. fi
  9. # If the PRAC NUMA commands are set, use them for Duoram
  10. if [ "$PRAC_NUMA_P0" != "" ]; then
  11. export DUORAM_NUMA_P0="$PRAC_NUMA_P0"
  12. fi
  13. if [ "$PRAC_NUMA_P1" != "" ]; then
  14. export DUORAM_NUMA_P1="$PRAC_NUMA_P1"
  15. fi
  16. if [ "$PRAC_NUMA_P2" != "" ]; then
  17. export DUORAM_NUMA_P2="$PRAC_NUMA_P2"
  18. fi
  19. # If the PRAC memory usage is set, use it for Duoram. In Duoram, P2 uses
  20. # twice the memory of P0 or P1 for preprocessing, so if P0 and P2 are on
  21. # the same NUMA node, set the total RAM available to 4/3 of the RAM
  22. # available for that node.
  23. if [ "$PRAC_P0_MAXGB" != "" ]; then
  24. export DUORAM_MAXGB=$((2*PRAC_P0_MAXGB))
  25. elif [ "$PRAC_P02_MAXGB" != "" ]; then
  26. export DUORAM_MAXGB=$((4*PRAC_P02_MAXGB/3))
  27. elif [ "$PRAC_MAXGB" != "" ]; then
  28. export DUORAM_MAXGB=$PRAC_MAXGB
  29. fi
  30. # Allow running only subsets of the experiment suite. Valid values are
  31. # "test", "fig6", "all", "none". ("none" is useful if you just want to
  32. # re-parse the output of existing logs.) You can also say "single"
  33. # followed by all the arguments to "run" (below) to run a single
  34. # experiment; for example:
  35. # ./repro single readwrite 20 1us 100gbit 128
  36. if [ "$1" = "" ]; then
  37. whichexps="test"
  38. else
  39. whichexps="$1"
  40. fi
  41. # The number of iterations per run; the graphs in the paper use 3
  42. if [ "$whichexps" = "single" -o "$2" = "" ]; then
  43. # If there's an explicit experiment on the command line, don't read
  44. # the next argument as the number of operations. $numiters will be
  45. # ignored, anyway, since it will be specified as part of the
  46. # command.
  47. numiters=3
  48. else
  49. numiters="$2"
  50. fi
  51. # The maximum amount of memory to use (in GB). Set the environment
  52. # variable DUORAM_MAXGB to increase it beyond 16 (don't set it lower
  53. # than 16).
  54. if [ "$DUORAM_MAXGB" = "" ]; then
  55. maxgb=16
  56. elif [ "$DUORAM_MAXGB" -gt 16 ]; then
  57. maxgb=$DUORAM_MAXGB
  58. else
  59. maxgb=16
  60. fi
  61. # Run one experiment
  62. # Arguments:
  63. # $1: mode (read, write, readwrite)
  64. # $2: depth (the ORAM has 2^depth elements)
  65. # $3: latency (e.g., 30ms)
  66. # $4: bandwidth (e.g., 100mbit)
  67. # $5: number of operations (e.g., 128)
  68. # $6: phase (preproc or online)
  69. # $7: number of parties (3P or 2P)
  70. runone() {
  71. now=`date`
  72. echo "$now: Running $1 $2 $3 $4 $5 $6 $7 ..."
  73. logfile="${1}_${3}_${4}_${5}_${6}_${7}.out${LOGSUFFIX}"
  74. ./set-networking $3 $4
  75. echo "Max GB: $maxgb" >> $logfile
  76. echo "Network setup: $3 $4" >> $logfile
  77. ./run-experiment $1 $2 $5 $6 $7 $maxgb >> $logfile
  78. }
  79. # Run one set of Duoram experiments: 2P and 3P, read and write,
  80. # preprocessing and online
  81. # Arguments:
  82. # $1: depth (the ORAM has 2^depth elements)
  83. # $2: latency (e.g., 30ms)
  84. # $3: bandwidth (e.g., 100mbit)
  85. # $4: number of operations (e.g., 128)
  86. run() {
  87. # The 3P preprocessing protocol is identical for reads and writes,
  88. # so we just do it once, and count it twice for readwrite.
  89. runone read $1 $2 $3 $4 preproc 3P
  90. # The 3P online protocols do reads, writes, and readwrites in a
  91. # single run.
  92. runone readwrite $1 $2 $3 $4 online 3P
  93. # Clean up any preprocessed DPFs
  94. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p0 bash -c "rm -f *" &
  95. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p1 bash -c "rm -f *" &
  96. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p2 bash -c "rm -f *" &
  97. wait
  98. }
  99. # Parse the output logs. We run this in the docker in case you don't
  100. # have perl installed on the host.
  101. # Arguments: a list of logfiles
  102. parse() {
  103. if [ "$DUORAM_PARSE_HOST" = "1" ]; then
  104. ./parse_logs $*
  105. else
  106. cat $* | docker exec -w /root/duoram/Docker -i duoram_p0 ./parse_logs
  107. fi
  108. }
  109. # A very small kick-the-tires test to ensure everything compiled and
  110. # built properly
  111. if [ "$whichexps" = "test" ]; then
  112. echo "Running test experiment..."
  113. run 16 1us 100gbit 2
  114. echo
  115. echo "# Test output"
  116. echo
  117. parse \
  118. read_1us_100gbit_2_preproc_3P.out${LOGSUFFIX} \
  119. readwrite_1us_100gbit_2_online_3P.out${LOGSUFFIX} \
  120. | egrep '(Onln|Totl).*readwrite' | sort
  121. echo
  122. echo "# End test output"
  123. echo
  124. exit
  125. fi
  126. # Be able to run a single experiment specified on the command line
  127. if [ "$whichexps" = "single" ]; then
  128. echo "Running single experiment..."
  129. shift
  130. runone $*
  131. exit
  132. fi
  133. now=`date`
  134. echo "$now: Starting experiments"
  135. if [ "$whichexps" = "fig6" -o "$whichexps" = "all" ]; then
  136. echo "Running Figure 6 experiments..."
  137. for i in $(seq 1 $numiters); do
  138. # Figure 6(a)
  139. for nops in 16 32 64 128 256 512 1024 2048; do
  140. run 20 30ms 100mbit $nops
  141. done
  142. if [ "$maxgb" -gt 164 ]; then
  143. large_exps="28 30"
  144. elif [ "$maxgb" -gt 41 ]; then
  145. large_exps="28"
  146. else
  147. large_exps=""
  148. fi
  149. # Figures 6(b), 6(c)
  150. for size in 16 18 20 22 24 26 ${large_exps}; do
  151. run $size 30ms 100mbit 10
  152. done
  153. done
  154. fi
  155. now=`date`
  156. echo "$now: Experiments complete"
  157. # If you specified a custom log suffix, you're going to be parsing the
  158. # outputs differently.
  159. if [ "$LOGSUFFIX" = "" ]; then
  160. parse *_{online,preproc}_3P.out > duoram.dat
  161. echo
  162. echo "# Figure 6(a)"
  163. egrep '3PDuoramTotl read 20 30ms 100mbit (16|32|64|128|256|512|1024|2048) .* s$' duoram.dat | sort -k6 -n
  164. #echo
  165. #egrep '3PDuoramOnln read 20 30ms 100mbit (16|32|64|128|256|512|1024|2048) .* s$' duoram.dat | sort -k6 -n
  166. echo
  167. echo "# Figure 6(b)"
  168. egrep '3PDuoramTotl read .* 30ms 100mbit 10 .* s$' duoram.dat | sort -k3 -n
  169. echo
  170. #egrep '3PDuoramOnln read .* 30ms 100mbit 10 .* s$' duoram.dat | sort -k3 -n
  171. #echo
  172. echo "# Figure 6(c)"
  173. egrep '3PDuoramTotl read .* 30ms 100mbit 10 .* KiB$' duoram.dat | sort -k3 -n
  174. echo
  175. #egrep '3PDuoramOnln read .* 30ms 100mbit 10 .* KiB$' duoram.dat | sort -k3 -n
  176. #echo
  177. echo "# End figures"
  178. echo
  179. fi