-
Notifications
You must be signed in to change notification settings - Fork 344
Open
Description
Hi, mkskeller!
I am developing a secure multi-party computation algorithm that performs an equi-join between two relational tables using primary keys (left table) and foreign keys (right table).
I have following test_db_join_.mpc
from Compiler.types import regint, sint
from Compiler.library import for_range, for_range_opt, print_ln
# oblivious nest loop join
def oblivious_join(jtable, jn, ltable, ln, lm, rtable, rn, rm, key_index_a=None, key_index_b=None):
print_ln("Start oblivious join computation")
valid_index = regint(lm+rm-4)
@for_range_opt(rn)
def _(i):
jtable[jn+i][valid_index] = sint(0)
@for_range_opt(rm-2)
def _(idx):
jtable[jn+i][lm-2+idx] = rtable[i][idx+1]
@for_range_opt(ln*rn,budget=65536)
def _(j):
i = j // rn
k = j % rn
match = (ltable[i][key_index_a].equal(rtable[k][key_index_b]))*rtable[k][rm-1]*ltable[i][lm-1]
jtable[jn+k][valid_index] = jtable[jn+k][valid_index] + match
@for_range_opt(lm-2)
def _(idx):
jtable[jn+k][idx] = ltable[i][idx+1]*match + jtable[jn+k][idx]*(1-match)
jn.update(jn+rn)
MAX_ROW = 50000
MAX_COL = 10
row_l=regint(60)
col_l=regint(4)
# row_l=60
# col_l=4
a =sint.Matrix(60,4)
a.input_from(0)
A = sint.Matrix(MAX_ROW,MAX_COL)
@for_range(row_l)
def _(i):
@for_range(col_l)
def _(j):
A[i][j] = a[i][j]
row_r=regint(1500)
col_r =regint(4)
# row_r=1500
# col_r =4
b = sint.Matrix(1500,4)
b.input_from(1)
B = sint.Matrix(MAX_ROW,MAX_COL)
@for_range(row_r)
def _(i):
@for_range(col_r)
def _(j):
B[i][j] = b[i][j]
jn = regint(0)
jtable = sint.Matrix(MAX_ROW,MAX_COL)
C = regint.Matrix(MAX_ROW,MAX_COL)
key_index_a = regint(0)
key_index_b = regint(0)
oblivious_join(jtable, jn, A,row_l,col_l,B,row_r,col_r,key_index_a,key_index_b)I test it in a linux cloud server with 8vCPU and 32GiB memory. I execute following bash command in a terminal
./compile.py -R 64 test_db_join_
Scripts/ring.sh test_db_join_data are stored in Player-Data/Input-P0-0 and Player-Data/Input-P1-0 and they are all int like these
7168 7168 7168 1
2307 2307 2307 1
2466 2466 2466 1
I find that if I use
row_l=regint(60)
col_l=regint(4)
row_r=regint(1500)
col_r =regint(4)then the Time = 38.3457 seconds, if I use
row_l=60
col_l=4
row_r=1500
col_r =4then the Time = 1.37221 seconds.
Can you tell me that's why, and how can I reduce Time in regint, because I have to use regint in some other code.
Metadata
Metadata
Assignees
Labels
No labels