repro 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. | egrep '(Onln|Totl).*readwrite' | sort
  117. echo
  118. echo "# End test output"
  119. echo
  120. exit
  121. fi
  122. # Be able to run a single experiment specified on the command line
  123. if [ "$whichexps" = "single" ]; then
  124. echo "Running single experiment..."
  125. shift
  126. runone $*
  127. exit
  128. fi
  129. now=`date`
  130. echo "$now: Starting experiments"
  131. if [ "$whichexps" = "small" -o "$whichexps" = "all" ]; then
  132. echo "Running small experiments..."
  133. # Figure 7(b)
  134. run 20 30ms 10mbit ${numops}
  135. run 20 30ms 30mbit ${numops}
  136. run 20 30ms 50mbit ${numops}
  137. run 20 30ms 70mbit ${numops}
  138. run 20 30ms 90mbit ${numops}
  139. run 20 30ms 110mbit ${numops}
  140. # Figure 7(c)
  141. run 20 10ms 100mbit ${numops}
  142. run 20 50ms 100mbit ${numops}
  143. run 20 70ms 100mbit ${numops}
  144. # Figures 8(a), 8(b), 8(c), 9(b), and 9(c)
  145. # Note that we set the latency to 1us, which really means "don't add
  146. # artificial latency", but we measure the one-way latency to
  147. # actually be 30us, which is what we report in the paper. (pings
  148. # from one docker to the other take about 60us round trip.)
  149. run 16 1us 100gbit ${numops}
  150. run 18 1us 100gbit ${numops}
  151. run 20 1us 100gbit ${numops}
  152. run 22 1us 100gbit ${numops}
  153. run 24 1us 100gbit ${numops}
  154. run 26 1us 100gbit ${numops}
  155. # Figures 7(a), 9(a)
  156. run 18 30ms 100mbit ${numops}
  157. run 22 30ms 100mbit ${numops}
  158. run 24 30ms 100mbit ${numops}
  159. fi
  160. if [ "$whichexps" = "small" -o "$whichexps" = "scaling" -o "$whichexps" = "all" ]; then
  161. # Figures s 7(a), 9(a), 10
  162. run 16 30ms 100mbit ${numops}
  163. run 20 30ms 100mbit ${numops}
  164. run 26 30ms 100mbit ${numops}
  165. fi
  166. if [ "$whichexps" = "large" -o "$whichexps" = "all" ]; then
  167. echo "Running large experiments..."
  168. # Figure 9(a)
  169. runone read 28 30ms 100mbit ${numops} preproc 3P
  170. runone read 28 30ms 100mbit ${numops} online 3P
  171. runone read 30 30ms 100mbit ${numops} preproc 3P
  172. runone read 30 30ms 100mbit ${numops} online 3P
  173. runone read 32 30ms 100mbit ${numops} preproc 3P
  174. runone read 32 30ms 100mbit ${numops} online 3P
  175. # Figures 9(b) and 9(c)
  176. runone read 28 1us 100gbit ${numops} preproc 3P
  177. runone read 28 1us 100gbit ${numops} online 3P
  178. runone read 30 1us 100gbit ${numops} preproc 3P
  179. runone read 30 1us 100gbit ${numops} online 3P
  180. runone read 32 1us 100gbit ${numops} preproc 3P
  181. runone read 32 1us 100gbit ${numops} online 3P
  182. fi
  183. now=`date`
  184. echo "$now: Experiments complete"
  185. # If you specified a custom log suffix, you're going to be parsing the
  186. # outputs differently.
  187. if [ "$LOGSUFFIX" = "" ]; then
  188. parse *_${numops}_{online,preproc}_{2P,3P}.out > duoram_${numops}.dat
  189. echo
  190. echo "# Figure 7(a)"
  191. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  192. echo
  193. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  194. echo
  195. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  196. echo
  197. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  198. echo
  199. echo "# Figure 7(b)"
  200. egrep '2PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  201. echo
  202. egrep '2PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  203. echo
  204. egrep '3PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  205. echo
  206. egrep '3PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  207. echo
  208. echo "# Figure 7(c)"
  209. egrep '2PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  210. echo
  211. egrep '2PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  212. echo
  213. egrep '3PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  214. echo
  215. egrep '3PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  216. echo
  217. echo "# Figure 8(a)"
  218. egrep '2PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  219. echo
  220. egrep '2PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  221. echo
  222. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  223. echo
  224. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  225. echo
  226. echo "# Figure 8(b)"
  227. egrep '2PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  228. echo
  229. egrep '2PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  230. echo
  231. egrep '3PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  232. echo
  233. egrep '3PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  234. echo
  235. echo "# Figure 8(c)"
  236. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  237. echo
  238. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  239. echo
  240. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  241. echo
  242. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  243. echo
  244. echo "# Figure 9(a)"
  245. egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  246. echo
  247. egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  248. echo
  249. echo "# Figure 9(b)"
  250. egrep '3PDuoramTotl read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  251. echo
  252. egrep '3PDuoramOnln read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  253. echo
  254. echo "# Figure 9(c)"
  255. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  256. echo
  257. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  258. echo
  259. echo "# End figures"
  260. echo
  261. fi