diff --git a/aws_benchmark/aws_setup.py b/aws_benchmark/aws_setup.py index a7634061..c0978b10 100644 --- a/aws_benchmark/aws_setup.py +++ b/aws_benchmark/aws_setup.py @@ -109,28 +109,64 @@ def setup_instances(num): instance.public_dns_name for instance in running_instances] pool = multiprocessing.Pool(len(running_instance_ips)) - pool.map(worker, running_instance_ips) + pool.map(setup_worker, running_instance_ips) -def worker(ip): +def setup_worker(ip): print("Setting up", ip) key = paramiko.RSAKey.from_private_key_file("the-key-to-her-heart.pem") client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(hostname=ip, username="ubuntu", pkey=key) + stdin, stdout, stderr = client.exec_command( - "cd ~ && git clone https://github.com/circify/circ.git && cd ~/circ && git checkout mpc_aws && cd ~ && ./circ/aws_benchmark/setup.sh") + "cd ~ && git clone https://github.com/circify/circ.git && cd ~/circ && git checkout mpc_aws && cd ~ && chmod 700 ./circ/aws_benchmark/setup.sh && ./circ/aws_benchmark/setup.sh") stdin.flush() if stdout.channel.recv_exit_status(): - print(ip, " failed clone") + print(ip, " failed setup") client.close() -create_instances(2) -setup_instances(2) +def run_benchmarks(num): + assert(num == 2) + running_instances = list(ec2_resource.instances.filter( + Filters=[{"Name": "instance-state-name", "Values": ["running"]}])) + if len(running_instances) < num: + print("Not all instances are up yet!") + return + + running_instance_ips = [ + instance.public_dns_name for instance in running_instances] + running_instance_private_ips = [ + running_instances[0].private_ip_address for _ in running_instances] + roles = [0, 1] + pool = multiprocessing.Pool(len(running_instance_ips)) + pool.map(setup_worker, running_instance_ips, + running_instance_private_ips, roles) + + +def benchmark_worker(ip, connect_ip, role): + print("Running benchmark", ip) + key = paramiko.RSAKey.from_private_key_file("the-key-to-her-heart.pem") + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + client.connect(hostname=ip, username="ubuntu", pkey=key) + + stdin, stdout, stderr = client.exec_command( + "cd ~ && chmod 700 ./circ/aws_benchmark/benchmark.sh && ./circ/aws_benchmark/benchmark.sh {} {} > benchmark.log".format(connect_ip, role)) + stdin.flush() + + if stdout.channel.recv_exit_status(): + print(ip, " failed running benchmark") + + client.close() + + +# create_instances(2) +# setup_instances(2) +run_benchmarks(2) # stop_instances(4) diff --git a/aws_benchmark/benchmark.sh b/aws_benchmark/benchmark.sh new file mode 100644 index 00000000..c3ecf53d --- /dev/null +++ b/aws_benchmark/benchmark.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./../ABY/build/bin/aby_interpreter -m mpc -f ./scripts/aby_tests/tests/2pc_millionaires_c -t ./scripts/aby_tests/test_inputs/lt_1.txt --address $1 -r $2 \ No newline at end of file diff --git a/aws_benchmark/setup.sh b/aws_benchmark/setup.sh index e1d30a09..dbc5b5d6 100644 --- a/aws_benchmark/setup.sh +++ b/aws_benchmark/setup.sh @@ -12,6 +12,4 @@ git clone https://github.com/edwjchen/ABY.git cd ABY && git checkout functions && mkdir build && cd build cmake .. -DABY_BUILD_EXE=On -DCMAKE_BUILD_TYPE=Release -make - -cd ~/circ \ No newline at end of file +make \ No newline at end of file