repro 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. #!/bin/bash
  2. # Reproduce the Duoram experiments from our paper:
  3. # Adithya Vadapalli, Ryan Henry, Ian Goldberg. Duoram: A
  4. # Bandwidth-Efficient Distributed ORAM for 2- and 3-Party Computation.
  5. # USENIX Security Symposium 2023.
  6. # cd into the directory containing this script (from the bash faq 028)
  7. if [[ $BASH_SOURCE = */* ]]; then
  8. cd -- "${BASH_SOURCE%/*}/" || exit
  9. fi
  10. # If the master NUMA commands are set, use them for Duoram
  11. if [ "$NUMA_P0" != "" ]; then
  12. export DUORAM_NUMA_P0="$NUMA_P0"
  13. fi
  14. if [ "$NUMA_P1" != "" ]; then
  15. export DUORAM_NUMA_P1="$NUMA_P1"
  16. fi
  17. if [ "$NUMA_P2" != "" ]; then
  18. export DUORAM_NUMA_P2="$NUMA_P2"
  19. fi
  20. # Allow running only subsets of the experiment suite. Valid values are
  21. # "test", "small", "large", "scaling", "all", "none". ("none" is useful
  22. # if you just want to re-parse the output of existing logs. "scaling"
  23. # is the subset of "small" that generates the data points for Figure 10;
  24. # see the README for that one, since you need a machine with at least 64
  25. # cores to generate it.) You can also say "single" followed by all the
  26. # arguments to "run" (below) to run a single experiment; for example:
  27. # ./repro single readwrite 20 1us 100gbit 128
  28. if [ "$1" = "" ]; then
  29. whichexps="test"
  30. else
  31. whichexps="$1"
  32. fi
  33. # The number of operations per run; the graphs in the paper use 128
  34. if [ "$whichexps" = "single" -o "$2" = "" ]; then
  35. # If there's an explicit experiment on the command line, don't read
  36. # the next argument as the number of operations. $numops will be
  37. # ignored, anyway, since it will be specified as part of the
  38. # command.
  39. numops=128
  40. else
  41. numops="$2"
  42. fi
  43. # The maximum amount of memory to use (in GB). Set the environment
  44. # variable DUORAM_MAXGB to increase it beyond 16 (don't set it lower
  45. # than 16).
  46. if [ "$DUORAM_MAXGB" = "" ]; then
  47. maxgb=16
  48. elif [ "$DUORAM_MAXGB" -gt 16 ]; then
  49. maxgb=$DUORAM_MAXGB
  50. else
  51. maxgb=16
  52. fi
  53. # Run one experiment
  54. # Arguments:
  55. # $1: mode (read, write, readwrite)
  56. # $2: depth (the ORAM has 2^depth elements)
  57. # $3: latency (e.g., 30ms)
  58. # $4: bandwidth (e.g., 100mbit)
  59. # $5: number of operations (e.g., 128)
  60. # $6: phase (preproc or online)
  61. # $7: number of parties (3P or 2P)
  62. runone() {
  63. now=`date`
  64. echo "$now: Running $1 $2 $3 $4 $5 $6 $7 ..."
  65. logfile="${1}_${3}_${4}_${5}_${6}_${7}.out${LOGSUFFIX}"
  66. ./set-networking $3 $4
  67. echo "Max GB: $maxgb" >> $logfile
  68. echo "Network setup: $3 $4" >> $logfile
  69. ./run-experiment $1 $2 $5 $6 $7 $maxgb >> $logfile
  70. }
  71. # Run one set of Duoram experiments: 2P and 3P, read and write,
  72. # preprocessing and online
  73. # Arguments:
  74. # $1: depth (the ORAM has 2^depth elements)
  75. # $2: latency (e.g., 30ms)
  76. # $3: bandwidth (e.g., 100mbit)
  77. # $4: number of operations (e.g., 128)
  78. run() {
  79. # The 2P read actually does both preprocessing and online
  80. runone read $1 $2 $3 $4 online 2P
  81. runone write $1 $2 $3 $4 preproc 2P
  82. runone write $1 $2 $3 $4 online 2P
  83. # The 2P read and write protocols are completely different, so
  84. # readwrite is just the sum of read and write.
  85. # The 3P preprocessing protocol is identical for reads and writes,
  86. # so we just do it once, and count it twice for readwrite.
  87. runone read $1 $2 $3 $4 preproc 3P
  88. # The 3P online protocols do reads, writes, and readwrites in a
  89. # single run.
  90. runone readwrite $1 $2 $3 $4 online 3P
  91. # Clean up any preprocessed DPFs
  92. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p0 bash -c "rm -f *" &
  93. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p1 bash -c "rm -f *" &
  94. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p2 bash -c "rm -f *" &
  95. wait
  96. }
  97. # Parse the output logs. We run this in the docker in case you don't
  98. # have perl installed on the host.
  99. # Arguments: a list of logfiles
  100. parse() {
  101. cat $* | docker exec -w /root/duoram/Docker -i duoram_p0 ./parse_logs
  102. }
  103. # A very small kick-the-tires test to ensure everything compiled and
  104. # built properly
  105. if [ "$whichexps" = "test" ]; then
  106. echo "Running test experiment..."
  107. run 16 1us 100gbit 2
  108. echo
  109. echo "# Test output"
  110. echo
  111. parse read_1us_100gbit_2_online_2P.out${LOGSUFFIX} \
  112. write_1us_100gbit_2_preproc_2P.out${LOGSUFFIX} \
  113. write_1us_100gbit_2_online_2P.out${LOGSUFFIX} \
  114. read_1us_100gbit_2_preproc_3P.out${LOGSUFFIX} \
  115. readwrite_1us_100gbit_2_online_3P.out${LOGSUFFIX}
  116. echo
  117. echo "# End test output"
  118. echo
  119. exit
  120. fi
  121. # Be able to run a single experiment specified on the command line
  122. if [ "$whichexps" = "single" ]; then
  123. echo "Running single experiment..."
  124. shift
  125. runone $*
  126. exit
  127. fi
  128. now=`date`
  129. echo "$now: Starting experiments"
  130. if [ "$whichexps" = "small" -o "$whichexps" = "all" ]; then
  131. echo "Running small experiments..."
  132. # Figure 7(b)
  133. run 20 30ms 10mbit ${numops}
  134. run 20 30ms 30mbit ${numops}
  135. run 20 30ms 50mbit ${numops}
  136. run 20 30ms 70mbit ${numops}
  137. run 20 30ms 90mbit ${numops}
  138. run 20 30ms 110mbit ${numops}
  139. # Figure 7(c)
  140. run 20 10ms 100mbit ${numops}
  141. run 20 50ms 100mbit ${numops}
  142. run 20 70ms 100mbit ${numops}
  143. # Figures 8(a), 8(b), 8(c), 9(b), and 9(c)
  144. # Note that we set the latency to 1us, which really means "don't add
  145. # artificial latency", but we measure the one-way latency to
  146. # actually be 30us, which is what we report in the paper. (pings
  147. # from one docker to the other take about 60us round trip.)
  148. run 16 1us 100gbit ${numops}
  149. run 18 1us 100gbit ${numops}
  150. run 20 1us 100gbit ${numops}
  151. run 22 1us 100gbit ${numops}
  152. run 24 1us 100gbit ${numops}
  153. run 26 1us 100gbit ${numops}
  154. # Figures 7(a), 9(a)
  155. run 18 30ms 100mbit ${numops}
  156. run 22 30ms 100mbit ${numops}
  157. run 24 30ms 100mbit ${numops}
  158. fi
  159. if [ "$whichexps" = "small" -o "$whichexps" = "scaling" -o "$whichexps" = "all" ]; then
  160. # Figures s 7(a), 9(a), 10
  161. run 16 30ms 100mbit ${numops}
  162. run 20 30ms 100mbit ${numops}
  163. run 26 30ms 100mbit ${numops}
  164. fi
  165. if [ "$whichexps" = "large" -o "$whichexps" = "all" ]; then
  166. echo "Running large experiments..."
  167. # Figure 9(a)
  168. runone read 28 30ms 100mbit ${numops} preproc 3P
  169. runone read 28 30ms 100mbit ${numops} online 3P
  170. runone read 30 30ms 100mbit ${numops} preproc 3P
  171. runone read 30 30ms 100mbit ${numops} online 3P
  172. runone read 32 30ms 100mbit ${numops} preproc 3P
  173. runone read 32 30ms 100mbit ${numops} online 3P
  174. # Figures 9(b) and 9(c)
  175. runone read 28 1us 100gbit ${numops} preproc 3P
  176. runone read 28 1us 100gbit ${numops} online 3P
  177. runone read 30 1us 100gbit ${numops} preproc 3P
  178. runone read 30 1us 100gbit ${numops} online 3P
  179. runone read 32 1us 100gbit ${numops} preproc 3P
  180. runone read 32 1us 100gbit ${numops} online 3P
  181. fi
  182. now=`date`
  183. echo "$now: Experiments complete"
  184. # If you specified a custom log suffix, you're going to be parsing the
  185. # outputs differently.
  186. if [ "$LOGSUFFIX" = "" ]; then
  187. parse *_${numops}_{online,preproc}_{2P,3P}.out > duoram_${numops}.dat
  188. echo
  189. echo "# Figure 7(a)"
  190. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  191. echo
  192. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  193. echo
  194. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  195. echo
  196. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  197. echo
  198. echo "# Figure 7(b)"
  199. egrep '2PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  200. echo
  201. egrep '2PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  202. echo
  203. egrep '3PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  204. echo
  205. egrep '3PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  206. echo
  207. echo "# Figure 7(c)"
  208. egrep '2PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  209. echo
  210. egrep '2PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  211. echo
  212. egrep '3PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  213. echo
  214. egrep '3PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  215. echo
  216. echo "# Figure 8(a)"
  217. egrep '2PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  218. echo
  219. egrep '2PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  220. echo
  221. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  222. echo
  223. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  224. echo
  225. echo "# Figure 8(b)"
  226. egrep '2PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  227. echo
  228. egrep '2PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  229. echo
  230. egrep '3PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  231. echo
  232. egrep '3PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  233. echo
  234. echo "# Figure 8(c)"
  235. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  236. echo
  237. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  238. echo
  239. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  240. echo
  241. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  242. echo
  243. echo "# Figure 9(a)"
  244. egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  245. echo
  246. egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  247. echo
  248. echo "# Figure 9(b)"
  249. egrep '3PDuoramTotl read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  250. echo
  251. egrep '3PDuoramOnln read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  252. echo
  253. echo "# Figure 9(c)"
  254. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  255. echo
  256. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  257. echo
  258. echo "# End figures"
  259. echo
  260. fi