Quellcode durchsuchen

Reproduction script and log parsing for the PRAC paper

Ian Goldberg vor 2 Jahren
Ursprung
Commit
80050b8007
3 geänderte Dateien mit 95 neuen und 209 gelöschten Zeilen
  1. 3 2
      Docker/Dockerfile
  2. 43 2
      Docker/parse_logs
  3. 49 205
      Docker/repro

+ 3 - 2
Docker/Dockerfile

@@ -8,5 +8,6 @@ RUN cd OTExtension/ && git checkout a9aa1ac94b7b3f171424af26c211c13dd342f712 &&
 COPY . duoram
 RUN cd duoram/preprocessing && make -j`nproc`
 RUN cd duoram/duoram-online && make -j`nproc`
-RUN cd duoram/2p-preprocessing && make -j`nproc`
-RUN cd duoram/cpir-read/cxx && make -j`nproc`
+# PRAC only compares to 3P-Duoram, so don't bother building the 2P version
+#RUN cd duoram/2p-preprocessing && make -j`nproc`
+#RUN cd duoram/cpir-read/cxx && make -j`nproc`

+ 43 - 2
Docker/parse_logs

@@ -336,6 +336,16 @@ sub statsum {
     }
 }
 
+# Sum two stat arrays, scaling the second by the given factor
+sub statscalesum {
+    my ($data0, $data1, $scale) = @_;
+    if (defined $data0->[1] && defined $data1->[1]) {
+        return [$data0->[0] + $data1->[0]*$scale, $data0->[1] + $data1->[1]*$scale];
+    } else {
+        return [$data0->[0] + $data1->[0]*$scale, undef];
+    }
+}
+
 # The 2P readwrite values are just the sums of the read and the write values
 sub sum_readwrite_2P {
     my $dict = $_[0];
@@ -361,9 +371,40 @@ sub sum_readwrite_2P {
 sub sum_preproc_online {
     my ($tdict, $pdict, $odict) = @_;
     my $key;
-    foreach $key (keys %$pdict) {
-        if (defined $odict->{$key}) {
+    foreach $key (keys %$odict) {
+        if (defined $pdict->{$key}) {
             $tdict->{$key} = &statsum($pdict->{$key}, $odict->{$key});
+        } else {
+            # We were able to do the online phase of a given
+            # configuration, but not the preprocessing phase.  That's
+            # possibly, OK, since to preprocess k DPFs of a given size,
+            # you can always just preprocess k/2 DPFs twice.  (If you're
+            # _able_ to do them in parallel, you'll probably get better
+            # results, but worst case, just find the largest set of this
+            # configuration we were able to preprocess in parallel, and
+            # multiply the results by how many times we would have to
+            # repeat it.)
+
+            # The key will end with k (the number of read (or whatever)
+            # operations we're making DPFs for.  Replace that number
+            # with the literal regexp "(\d+)".
+            my $config = $key;
+            $config =~ s/\d+$/\(\\d\+\)/;
+            # How many did we try and fail to preprocess
+            $key =~ $config;
+            my $triednum = $1;
+            # Find the largest number we were able to preprocess
+            my $pkey;
+            my $maxnum = 0;
+            foreach $pkey (keys %$pdict) {
+                if ($pkey =~ /$config/) {
+                    $maxnum = $1 if $1 > $maxnum;
+                }
+            }
+            $pkey = $key;
+            $pkey =~ s/\d+$/$maxnum/;
+            my $scale = int(($triednum+$maxnum-1)/$maxnum);
+            $tdict->{$key} = &statscalesum($odict->{$key}, $pdict->{$pkey}, $scale);
         }
     }
 }

+ 49 - 205
Docker/repro

@@ -2,24 +2,35 @@
 
 # Reproduce the Duoram experiments from our paper:
 
-# Adithya Vadapalli, Ryan Henry, Ian Goldberg. Duoram: A
-# Bandwidth-Efficient Distributed ORAM for 2- and 3-Party Computation.
-# USENIX Security Symposium 2023.
+# Sajin Sasy, Adithya Vadapalli, Ian Goldberg. PRAC: Round-Efficient
+# 3-Party MPC for Dynamic Data Structures
 
 # cd into the directory containing this script (from the bash faq 028)
 if [[ $BASH_SOURCE = */* ]]; then
   cd -- "${BASH_SOURCE%/*}/" || exit
 fi
 
-# If the master NUMA commands are set, use them for Duoram
-if [ "$NUMA_P0" != "" ]; then
-    export DUORAM_NUMA_P0="$NUMA_P0"
+# If the PRAC NUMA commands are set, use them for Duoram
+if [ "$PRAC_NUMA_P0" != "" ]; then
+    export DUORAM_NUMA_P0="$PRAC_NUMA_P0"
 fi
-if [ "$NUMA_P1" != "" ]; then
-    export DUORAM_NUMA_P1="$NUMA_P1"
+if [ "$PRAC_NUMA_P1" != "" ]; then
+    export DUORAM_NUMA_P1="$PRAC_NUMA_P1"
 fi
-if [ "$NUMA_P2" != "" ]; then
-    export DUORAM_NUMA_P2="$NUMA_P2"
+if [ "$PRAC_NUMA_P2" != "" ]; then
+    export DUORAM_NUMA_P2="$PRAC_NUMA_P2"
+fi
+
+# If the PRAC memory usage is set, use it for Duoram. In Duoram, P2 uses
+# twice the memory of P0 or P1 for preprocessing, so if P0 and P2 are on
+# the same NUMA node, set the total RAM available to 4/3 of the RAM
+# available for that node.
+if [ "$PRAC_P0_MAXGB" != "" ]; then
+    export DUORAM_MAXGB=$((2*PRAC_P0_MAXGB))
+elif [ "$PRAC_P02_MAXGB" != "" ]; then
+    export DUORAM_MAXGB=$((4*PRAC_P02_MAXGB/3))
+elif [ "$PRAC_MAXGB" != "" ]; then
+    export DUORAM_MAXGB=$PRAC_MAXGB
 fi
 
 # Allow running only subsets of the experiment suite.  Valid values are
@@ -36,15 +47,15 @@ else
     whichexps="$1"
 fi
 
-# The number of operations per run; the graphs in the paper use 128
+# The number of iterations per run; the graphs in the paper use 3
 if [ "$whichexps" = "single" -o "$2" = "" ]; then
     # If there's an explicit experiment on the command line, don't read
-    # the next argument as the number of operations.  $numops will be
+    # the next argument as the number of operations.  $numiters will be
     # ignored, anyway, since it will be specified as part of the
     # command.
-    numops=128
+    numiters=3
 else
-    numops="$2"
+    numiters="$2"
 fi
 
 # The maximum amount of memory to use (in GB).  Set the environment
@@ -85,12 +96,6 @@ runone() {
 # $3: bandwidth (e.g., 100mbit)
 # $4: number of operations (e.g., 128)
 run() {
-    # The 2P read actually does both preprocessing and online
-    runone read $1 $2 $3 $4 online 2P
-    runone write $1 $2 $3 $4 preproc 2P
-    runone write $1 $2 $3 $4 online 2P
-    # The 2P read and write protocols are completely different, so
-    # readwrite is just the sum of read and write.
     # The 3P preprocessing protocol is identical for reads and writes,
     # so we just do it once, and count it twice for readwrite.
     runone read $1 $2 $3 $4 preproc 3P
@@ -123,9 +128,7 @@ if [ "$whichexps" = "test" ]; then
     echo
     echo "# Test output"
     echo
-    parse read_1us_100gbit_2_online_2P.out${LOGSUFFIX} \
-        write_1us_100gbit_2_preproc_2P.out${LOGSUFFIX} \
-        write_1us_100gbit_2_online_2P.out${LOGSUFFIX} \
+    parse \
         read_1us_100gbit_2_preproc_3P.out${LOGSUFFIX} \
         readwrite_1us_100gbit_2_online_3P.out${LOGSUFFIX} \
         | egrep '(Onln|Totl).*readwrite' | sort
@@ -148,65 +151,19 @@ echo "$now: Starting experiments"
 
 if [ "$whichexps" = "small" -o "$whichexps" = "all" ]; then
     echo "Running small experiments..."
-    # Figure 7(b)
-    run 20 30ms 10mbit ${numops}
-    run 20 30ms 30mbit ${numops}
-    run 20 30ms 50mbit ${numops}
-    run 20 30ms 70mbit ${numops}
-    run 20 30ms 90mbit ${numops}
-    run 20 30ms 110mbit ${numops}
-    # Figure 7(c)
-    run 20 10ms 100mbit ${numops}
-    run 20 50ms 100mbit ${numops}
-    run 20 70ms 100mbit ${numops}
-    # Figures 8(a), 8(b), 8(c), 9(b), and 9(c)
-    # Note that we set the latency to 1us, which really means "don't add
-    # artificial latency", but we measure the one-way latency to
-    # actually be 30us, which is what we report in the paper. (pings
-    # from one docker to the other take about 60us round trip.)
-    run 16 1us 100gbit ${numops}
-    run 18 1us 100gbit ${numops}
-    run 20 1us 100gbit ${numops}
-    run 22 1us 100gbit ${numops}
-    run 24 1us 100gbit ${numops}
-    run 26 1us 100gbit ${numops}
-    # Figures 7(a), 9(a)
-    run 18 30ms 100mbit ${numops}
-    run 22 30ms 100mbit ${numops}
-    run 24 30ms 100mbit ${numops}
-fi
-if [ "$whichexps" = "small" -o "$whichexps" = "all" ]; then
-    # Figures 7(a), 9(a)
-    run 16 30ms 100mbit ${numops}
-    run 20 30ms 100mbit ${numops}
-    run 26 30ms 100mbit ${numops}
-fi
-if [ "$whichexps" = "scaling" ]; then
-    echo "Running scaling experiments..."
-    # Figure 10
-    runone read 16 30ms 100mbit ${numops} online 2P
-    runone read 20 30ms 100mbit ${numops} online 2P
-    runone read 26 30ms 100mbit ${numops} online 2P
-    runone read 16 30ms 100mbit ${numops} online 3P
-    runone read 20 30ms 100mbit ${numops} online 3P
-    runone read 26 30ms 100mbit ${numops} online 3P
+    for i in $(seq 1 $numiters); do
+        # Figure 6(a)
+        for nops in 16 32 64 128 256 512 1024 2048; do
+            run 20 30ms 100mbit $nops
+        done
+        # Figures 6(b), 6(c)
+        for size in 16 18 20 22 24 26 28 30; do
+            run $size 30ms 100mbit 10
+        done
+    done
 fi
 if [ "$whichexps" = "large" -o "$whichexps" = "all" ]; then
     echo "Running large experiments..."
-    # Figure 9(a)
-    runone read 28 30ms 100mbit ${numops} preproc 3P
-    runone read 28 30ms 100mbit ${numops} online 3P
-    runone read 30 30ms 100mbit ${numops} preproc 3P
-    runone read 30 30ms 100mbit ${numops} online 3P
-    runone read 32 30ms 100mbit ${numops} preproc 3P
-    runone read 32 30ms 100mbit ${numops} online 3P
-    # Figures 9(b) and 9(c)
-    runone read 28 1us 100gbit ${numops} preproc 3P
-    runone read 28 1us 100gbit ${numops} online 3P
-    runone read 30 1us 100gbit ${numops} preproc 3P
-    runone read 30 1us 100gbit ${numops} online 3P
-    runone read 32 1us 100gbit ${numops} preproc 3P
-    runone read 32 1us 100gbit ${numops} online 3P
 fi
 
 now=`date`
@@ -216,137 +173,24 @@ echo "$now: Experiments complete"
 # outputs differently.
 if [ "$LOGSUFFIX" = "" ]; then
 
-parse *_${numops}_{online,preproc}_{2P,3P}.out > duoram_${numops}.dat
+parse *_{online,preproc}_3P.out > duoram.dat
 
 echo
-echo "# Figure 7(a)"
-egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-echo
-echo "# Figure 7(b)"
-egrep '2PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-echo
-egrep '2PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-echo
-egrep '3PDuoramTotl readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-echo
-egrep '3PDuoramOnln readwrite 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-echo
-echo "# Figure 7(c)"
-egrep '2PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-echo
-egrep '2PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-echo
-egrep '3PDuoramTotl readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-echo
-egrep '3PDuoramOnln readwrite 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-echo
-echo "# Figure 8(a)"
-egrep '2PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '2PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-echo "# Figure 8(b)"
-egrep '2PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '2PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramTotl write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramOnln write .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-echo "# Figure 8(c)"
-egrep '2PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '2PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramTotl readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramOnln readwrite .* 30ms 100mbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-echo "# Figure 9(a)"
-egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
+echo "# Figure 6(a)"
+egrep '3PDuoramTotl read 20 30ms 100mbit (16|32|64|128|256|512|1024|2048) .* s$' duoram.dat | sort -k6 -n
+#echo
+#egrep '3PDuoramOnln read 20 30ms 100mbit (16|32|64|128|256|512|1024|2048) .* s$' duoram.dat | sort -k6 -n
 echo
-echo "# Figure 9(b)"
-egrep '3PDuoramTotl read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
+echo "# Figure 6(b)"
+egrep '3PDuoramTotl read .* 30ms 100mbit 10 .* s$' duoram.dat | sort -k3 -n
 echo
-egrep '3PDuoramOnln read .* 1us 100gbit .* s$' duoram_${numops}.dat | sort -k3 -n
+#egrep '3PDuoramOnln read .* 30ms 100mbit 10 .* s$' duoram.dat | sort -k3 -n
+#echo
+echo "# Figure 6(c)"
+egrep '3PDuoramTotl read .* 30ms 100mbit 10 .* KiB$' duoram.dat | sort -k3 -n
 echo
-echo "# Figure 9(c)"
-egrep '3PDuoramTotl read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-egrep '3PDuoramOnln read .* 1us 100gbit .* KiB$' duoram_${numops}.dat | sort -k3 -n
-echo
-
-if [ "$DUORAM_EXTENDED_PLOTS" = "1" ]; then
-    # Also show the plots for the extended version (Figures 11, 12)
-    echo "# Figure 11(a)"
-    egrep '2PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    egrep '2PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    egrep '3PDuoramTotl read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    egrep '3PDuoramOnln read .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    echo "# Figure 11(b)"
-    egrep '2PDuoramTotl read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    egrep '2PDuoramOnln read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    egrep '3PDuoramTotl read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    egrep '3PDuoramOnln read 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    echo "# Figure 11(c)"
-    egrep '2PDuoramTotl read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    egrep '2PDuoramOnln read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    egrep '3PDuoramTotl read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    egrep '3PDuoramOnln read 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    echo
-    echo "# Figure 12(a)"
-    egrep '2PDuoramTotl write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    egrep '2PDuoramOnln write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    egrep '3PDuoramTotl write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    egrep '3PDuoramOnln write .* 30ms 100mbit .* s$' duoram_${numops}.dat | sort -k3 -n
-    echo
-    echo "# Figure 12(b)"
-    egrep '2PDuoramTotl write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    egrep '2PDuoramOnln write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    egrep '3PDuoramTotl write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    egrep '3PDuoramOnln write 20 30ms .* s$' duoram_${numops}.dat | sort -k5 -n
-    echo
-    echo "# Figure 12(c)"
-    egrep '2PDuoramTotl write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    egrep '2PDuoramOnln write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    egrep '3PDuoramTotl write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-    egrep '3PDuoramOnln write 20 .* 100mbit .* s$' duoram_${numops}.dat | sort -k4 -n
-    echo
-fi
+#egrep '3PDuoramOnln read .* 30ms 100mbit 10 .* KiB$' duoram.dat | sort -k3 -n
+#echo
 
 echo "# End figures"
 echo