From 974b36ff40399cb92365b2e576dd7e8612c8c09b Mon Sep 17 00:00:00 2001 From: Thomas Skovlund Hansen Date: Tue, 2 May 2023 11:31:19 +0200 Subject: [PATCH] Add more benchmark functionality --- Compiler/path_oblivious_heap.py | 12 +++--- Programs/Source/benchmark_priority_queue.mpc | 44 +++++++++++++++----- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Compiler/path_oblivious_heap.py b/Compiler/path_oblivious_heap.py index 1d03d68c..94a5b073 100644 --- a/Compiler/path_oblivious_heap.py +++ b/Compiler/path_oblivious_heap.py @@ -857,7 +857,7 @@ class PathObliviousHeap(AbstractMinPriorityQueue[_secret]): dprint( f"[POH] __init__: Type hiding security is {'en' if self.type_hiding_security else 'dis'}abled", ) - dprint("[POH] __init__: Variant is %s", variant) + dprint(f"[POH] __init__: Variant is {variant}") # Initialize data structure with dummy elements self.tree = variant.get_tree_class()( @@ -938,10 +938,11 @@ class POHToHeapQAdapter(PathObliviousHeap): self, max_size, *args, - init_rounds=-1, int_type=sint, - bucket_size=2, variant=POHVariant.PATH, + bucket_size=None, + stash_size=None, + init_rounds=-1, **kwargs, ): """Initialize a POH with the required capacity @@ -949,10 +950,11 @@ class POHToHeapQAdapter(PathObliviousHeap): """ super().__init__( max_size, - init_rounds=init_rounds, int_type=int_type, - bucket_size=bucket_size, variant=variant, + bucket_size=bucket_size, + stash_size=stash_size, + init_rounds=init_rounds, ) def update(self, value, priority, for_real=True): diff --git a/Programs/Source/benchmark_priority_queue.mpc b/Programs/Source/benchmark_priority_queue.mpc index 88504e7e..0c90fdc3 100644 --- a/Programs/Source/benchmark_priority_queue.mpc +++ b/Programs/Source/benchmark_priority_queue.mpc @@ -25,20 +25,22 @@ dprint = lib.print_ln if DEBUG else noop # Benchmark types INSERT = True EXTRACT = True -SORTING = True +SORTING = False INSERT = INSERT or EXTRACT # Always insert if we are going to extract # Benchmark parameters ## Insert / ExtractMin -RANGE = [2**i for i in range(1, 14)] # TODO: Test this range +RANGE = [2**i for i in range(1, 10)] OPERATIONS_PER_STEP = 3 TIME_INIT = True -TREE = False -TREE_PATH = False -OPTIMAL_TREE = True -OPTIMAL_PATH = True +TREE_HEAP = True +TREE_PATH_HEAP = True +LINEAR_HEAP = True +OPTIMAL_TREE_HEAP = False +OPTIMAL_PATH_HEAP = False POH_PATH = True +POH_PATH_CONSTANT_STASH = True ## Sorting LENGTHS = [5, 10, 15, 20, 25, 30] @@ -91,12 +93,12 @@ if INSERT: if EXTRACT: operation_round(q, apply_extract, capacity, tag=tag + " extract_min") - dprint(f"\n\nBENCHMARKING INSERT{'AND EXTRACT ' if EXTRACT else ''} TIME") + dprint(f"\n\nBENCHMARKING INSERT {'AND EXTRACT ' if EXTRACT else ''}TIME") for capacity in RANGE: dprint(f"\nCAPACITY {capacity}") - if TREE: + if TREE_HEAP: # Benchmark binary heap built on ORAM (Tree ORAM variant) benchmark_operations( HeapQ, @@ -105,7 +107,7 @@ if INSERT: tag="ORAM Heap (Tree)", ) - if TREE_PATH: + if TREE_PATH_HEAP: # Benchmark binary heap built on ORAM (Path ORAM variant) benchmark_operations( HeapQ, @@ -114,7 +116,16 @@ if INSERT: tag="ORAM Heap (Path)", ) - if OPTIMAL_TREE: + if LINEAR_HEAP: + # Benchmark binary heap built on ORAM (Linear ORAM variant) + benchmark_operations( + HeapQ, + capacity, + oram_type=oram.LinearORAM, + tag="ORAM Heap (Linear)", + ) + + if OPTIMAL_TREE_HEAP: # Benchmark binary heap built on ORAM (OptimalORAM variant) benchmark_operations( HeapQ, @@ -123,7 +134,7 @@ if INSERT: tag="ORAM Heap (Optimal Tree)", ) - if OPTIMAL_PATH: + if OPTIMAL_PATH_HEAP: # Benchmark binary heap built on ORAM (OptimalORAM Path variant) benchmark_operations( HeapQ, @@ -142,6 +153,17 @@ if INSERT: tag="POH (Path)", ) + if POH_PATH_CONSTANT_STASH: + # Benchmark Path Oblivious Heap (Path variant with constant stash size) + benchmark_operations( + POHToHeapQAdapter, + capacity, + bucket_size=2, + stash_size=20, # based on empirical analysis by Keller and Scholl + variant=POHVariant.PATH, + tag="POH (Path (constant stash size))", + ) + if SORTING: dprint("\n\nBENCHMARKING SORTING TIME") for n in LENGTHS: