repro 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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" = "all" ]; then
  165. # Figures 7(a), 9(a)
  166. run 16 30ms 100mbit ${numops}
  167. run 20 30ms 100mbit ${numops}
  168. run 26 30ms 100mbit ${numops}
  169. fi
  170. if [ "$whichexps" = "scaling" ]; then
  171. echo "Running scaling experiments..."
  172. # Figure 10
  173. runone read 16 30ms 100mbit ${numops} online 2P
  174. runone read 20 30ms 100mbit ${numops} online 2P
  175. runone read 26 30ms 100mbit ${numops} online 2P
  176. runone read 16 30ms 100mbit ${numops} online 3P
  177. runone read 20 30ms 100mbit ${numops} online 3P
  178. runone read 26 30ms 100mbit ${numops} online 3P
  179. fi
  180. if [ "$whichexps" = "large" -o "$whichexps" = "all" ]; then
  181. echo "Running large experiments..."
  182. # Figure 9(a)
  183. runone read 28 30ms 100mbit ${numops} preproc 3P
  184. runone read 28 30ms 100mbit ${numops} online 3P
  185. runone read 30 30ms 100mbit ${numops} preproc 3P
  186. runone read 30 30ms 100mbit ${numops} online 3P
  187. runone read 32 30ms 100mbit ${numops} preproc 3P
  188. runone read 32 30ms 100mbit ${numops} online 3P
  189. # Figures 9(b) and 9(c)
  190. runone read 28 1us 100gbit ${numops} preproc 3P
  191. runone read 28 1us 100gbit ${numops} online 3P
  192. runone read 30 1us 100gbit ${numops} preproc 3P
  193. runone read 30 1us 100gbit ${numops} online 3P
  194. runone read 32 1us 100gbit ${numops} preproc 3P
  195. runone read 32 1us 100gbit ${numops} online 3P
  196. fi
  197. now=`date`
  198. echo "$now: Experiments complete"
  199. # If you specified a custom log suffix, you're going to be parsing the
  200. # outputs differently.
  201. if [ "$LOGSUFFIX" = "" ]; then
  202. parse *_${numops}_{online,preproc}_{2P,3P}.out > duoram_${numops}.dat
  203. echo
  204. echo "# Figure 7(a)"
  205. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  206. echo
  207. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  208. echo
  209. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  210. echo
  211. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  212. echo
  213. echo "# Figure 7(b)"
  214. egrep '2PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  215. echo
  216. egrep '2PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  217. echo
  218. egrep '3PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  219. echo
  220. egrep '3PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  221. echo
  222. echo "# Figure 7(c)"
  223. egrep '2PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  224. echo
  225. egrep '2PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  226. echo
  227. egrep '3PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  228. echo
  229. egrep '3PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  230. echo
  231. echo "# Figure 8(a)"
  232. egrep '2PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  233. echo
  234. egrep '2PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  235. echo
  236. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  237. echo
  238. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  239. echo
  240. echo "# Figure 8(b)"
  241. egrep '2PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  242. echo
  243. egrep '2PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  244. echo
  245. egrep '3PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  246. echo
  247. egrep '3PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  248. echo
  249. echo "# Figure 8(c)"
  250. egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  251. echo
  252. egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  253. echo
  254. egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  255. echo
  256. egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  257. echo
  258. echo "# Figure 9(a)"
  259. egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  260. echo
  261. egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  262. echo
  263. echo "# Figure 9(b)"
  264. egrep '3PDuoramTotl read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  265. echo
  266. egrep '3PDuoramOnln read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
  267. echo
  268. echo "# Figure 9(c)"
  269. egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  270. echo
  271. egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
  272. echo
  273. if [ "$DUORAM_EXTENDED_PLOTS" = "1" ]; then
  274. # Also show the plots for the extended version (Figures 11, 12)
  275. echo "# Figure 11(a)"
  276. egrep '2PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  277. echo
  278. egrep '2PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  279. echo
  280. egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  281. echo
  282. egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  283. echo
  284. echo "# Figure 11(b)"
  285. egrep '2PDuoramTotl read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  286. echo
  287. egrep '2PDuoramOnln read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  288. echo
  289. egrep '3PDuoramTotl read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  290. echo
  291. egrep '3PDuoramOnln read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  292. echo
  293. echo "# Figure 11(c)"
  294. egrep '2PDuoramTotl read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  295. echo
  296. egrep '2PDuoramOnln read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  297. echo
  298. egrep '3PDuoramTotl read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  299. echo
  300. egrep '3PDuoramOnln read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  301. echo
  302. echo
  303. echo "# Figure 12(a)"
  304. egrep '2PDuoramTotl write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  305. echo
  306. egrep '2PDuoramOnln write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  307. echo
  308. egrep '3PDuoramTotl write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  309. echo
  310. egrep '3PDuoramOnln write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
  311. echo
  312. echo "# Figure 12(b)"
  313. egrep '2PDuoramTotl write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  314. echo
  315. egrep '2PDuoramOnln write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  316. echo
  317. egrep '3PDuoramTotl write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  318. echo
  319. egrep '3PDuoramOnln write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
  320. echo
  321. echo "# Figure 12(c)"
  322. egrep '2PDuoramTotl write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  323. echo
  324. egrep '2PDuoramOnln write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  325. echo
  326. egrep '3PDuoramTotl write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  327. echo
  328. egrep '3PDuoramOnln write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
  329. echo
  330. fi
  331. echo "# End figures"
  332. echo
  333. fi