repro 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. if [ "$DUORAM_PARSE_HOST" = "1" ]; then
  102. ./parse_logs $*
  103. else
  104. cat $* | docker exec -w /root/duoram/Docker -i duoram_p0 ./parse_logs
  105. fi
  106. }
  107. # A very small kick-the-tires test to ensure everything compiled and
  108. # built properly
  109. if [ "$whichexps" = "test" ]; then
  110. echo "Running test experiment..."
  111. run 16 1us 100gbit 2
  112. echo
  113. echo "# Test output"
  114. echo
  115. parse read_1us_100gbit_2_online_2P.out${LOGSUFFIX} \
  116. write_1us_100gbit_2_preproc_2P.out${LOGSUFFIX} \
  117. write_1us_100gbit_2_online_2P.out${LOGSUFFIX} \
  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" = "small" -o "$whichexps" = "all" ]; then
  136. echo "Running small experiments..."
  137. # Figure 7(b)
  138. run 20 30ms 10mbit ${numops}
  139. run 20 30ms 30mbit ${numops}
  140. run 20 30ms 50mbit ${numops}
  141. run 20 30ms 70mbit ${numops}
  142. run 20 30ms 90mbit ${numops}
  143. run 20 30ms 110mbit ${numops}
  144. # Figure 7(c)
  145. run 20 10ms 100mbit ${numops}
  146. run 20 50ms 100mbit ${numops}
  147. run 20 70ms 100mbit ${numops}
  148. # Figures 8(a), 8(b), 8(c), 9(b), and 9(c)
  149. # Note that we set the latency to 1us, which really means "don't add
  150. # artificial latency", but we measure the one-way latency to
  151. # actually be 30us, which is what we report in the paper. (pings
  152. # from one docker to the other take about 60us round trip.)
  153. run 16 1us 100gbit ${numops}
  154. run 18 1us 100gbit ${numops}
  155. run 20 1us 100gbit ${numops}
  156. run 22 1us 100gbit ${numops}
  157. run 24 1us 100gbit ${numops}
  158. run 26 1us 100gbit ${numops}
  159. # Figures 7(a), 9(a)
  160. run 18 30ms 100mbit ${numops}
  161. run 22 30ms 100mbit ${numops}
  162. run 24 30ms 100mbit ${numops}
  163. fi
  164. if [ "$whichexps" = "small" -o "$whichexps" = "scaling" -o "$whichexps" = "all" ]; then
  165. # Figures s 7(a), 9(a), 10
  166. run 16 30ms 100mbit ${numops}
  167. run 20 30ms 100mbit ${numops}
  168. run 26 30ms 100mbit ${numops}
  169. fi
  170. if [ "$whichexps" = "large" -o "$whichexps" = "all" ]; then
  171. echo "Running large experiments..."
  172. # Figure 9(a)
  173. runone read 28 30ms 100mbit ${numops} preproc 3P
  174. runone read 28 30ms 100mbit ${numops} online 3P
  175. runone read 30 30ms 100mbit ${numops} preproc 3P
  176. runone read 30 30ms 100mbit ${numops} online 3P
  177. runone read 32 30ms 100mbit ${numops} preproc 3P
  178. runone read 32 30ms 100mbit ${numops} online 3P
  179. # Figures 9(b) and 9(c)
  180. runone read 28 1us 100gbit ${numops} preproc 3P
  181. runone read 28 1us 100gbit ${numops} online 3P
  182. runone read 30 1us 100gbit ${numops} preproc 3P
  183. runone read 30 1us 100gbit ${numops} online 3P
  184. runone read 32 1us 100gbit ${numops} preproc 3P
  185. runone read 32 1us 100gbit ${numops} online 3P
  186. fi
  187. now=`date`
  188. echo "$now: Experiments complete"
  189. # If you specified a custom log suffix, you're going to be parsing the
  190. # outputs differently.
  191. if [ "$LOGSUFFIX" = "" ]; then
  192. parse *_${numops}_{online,preproc}_{2P,3P}.out > duoram_${numops}.dat
  193. echo
  194. echo "# Figure 7(a)"
  195. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  196. echo
  197. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  198. echo
  199. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  200. echo
  201. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  202. echo
  203. echo "# Figure 7(b)"
  204. egrep '2PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  205. echo
  206. egrep '2PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  207. echo
  208. egrep '3PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  209. echo
  210. egrep '3PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  211. echo
  212. echo "# Figure 7(c)"
  213. egrep '2PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  214. echo
  215. egrep '2PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  216. echo
  217. egrep '3PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  218. echo
  219. egrep '3PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  220. echo
  221. echo "# Figure 8(a)"
  222. egrep '2PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  223. echo
  224. egrep '2PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  225. echo
  226. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  227. echo
  228. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  229. echo
  230. echo "# Figure 8(b)"
  231. egrep '2PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  232. echo
  233. egrep '2PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  234. echo
  235. egrep '3PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  236. echo
  237. egrep '3PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  238. echo
  239. echo "# Figure 8(c)"
  240. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  241. echo
  242. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  243. echo
  244. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  245. echo
  246. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  247. echo
  248. echo "# Figure 9(a)"
  249. egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  250. echo
  251. egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  252. echo
  253. echo "# Figure 9(b)"
  254. egrep '3PDuoramTotl read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  255. echo
  256. egrep '3PDuoramOnln read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  257. echo
  258. echo "# Figure 9(c)"
  259. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  260. echo
  261. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  262. echo
  263. echo "# End figures"
  264. echo
  265. fi