Merge branch 'master' of gitfub.space:Pownie/alex-retrieval
This commit is contained in:
commit
85cd701f32
|
@ -20,7 +20,7 @@ public class Driver {
|
|||
}
|
||||
EvenSimplerClient client = new EvenSimplerClient(settings, servers, profiler);
|
||||
profiler.start();
|
||||
client.receiveBits(1);
|
||||
client.receiveBits(0);
|
||||
profiler.stop();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class Driver {
|
|||
}
|
||||
SimpleClient client = new SimpleClient(settings, servers, profiler);
|
||||
profiler.start();
|
||||
client.receiveBit(1);
|
||||
client.receiveBit(0);
|
||||
profiler.stop();
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class Driver {
|
|||
}
|
||||
SimpleClient client = new SimpleClient(settings, servers, profiler);
|
||||
profiler.start();
|
||||
client.receiveBits(1);
|
||||
client.receiveBits(0);
|
||||
profiler.stop();
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class Driver {
|
|||
}
|
||||
InterPolyClient client = new InterPolyClient(settings, servers, profiler);
|
||||
profiler.start();
|
||||
client.receive(1);
|
||||
client.receive(0);
|
||||
profiler.stop();
|
||||
}
|
||||
|
||||
|
@ -64,78 +64,69 @@ public class Driver {
|
|||
}
|
||||
InterPolyClient client = new InterPolyClient(settings, servers, profiler);
|
||||
profiler.start();
|
||||
client.receiveBlock(1);
|
||||
client.receiveBlock(0);
|
||||
profiler.stop();
|
||||
}
|
||||
|
||||
public static void runTests() {
|
||||
for (int numServers = 1; numServers <= 8; numServers = numServers*2) {
|
||||
for (int databaseSize = 2; databaseSize <= 4096; databaseSize = databaseSize*2) {
|
||||
for (int blockSize = 1; blockSize <= Math.min(512, databaseSize); blockSize = blockSize*2) {
|
||||
for (int latency = 0; latency <= 50; latency = latency + 10) {
|
||||
for (int bandwidth = 1024; bandwidth <= 2048; bandwidth = bandwidth*2) {
|
||||
runTest(numServers, databaseSize, blockSize, latency, bandwidth);
|
||||
}
|
||||
private static void runTests() {
|
||||
for (int numServers = 1; numServers <= 16; numServers = numServers*2) {
|
||||
for (int databaseSize = 2048; databaseSize <= 32_768; databaseSize = databaseSize*2) {
|
||||
for (int blockSize = 64; blockSize <= 16_384; blockSize = blockSize*2) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
runTest(numServers, databaseSize, blockSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void runTest(int numServers, int databaseSize, int blockSize, int latency, int bandwidth) {
|
||||
PIRSettings settings = new PIRSettings(databaseSize, numServers, blockSize);
|
||||
int[] x = new int[databaseSize];
|
||||
private static void runTest(int numServers, int databaseSize, int blockSize) {
|
||||
PIRSettings settings = new PIRSettings(databaseSize*blockSize, numServers, blockSize);
|
||||
int[] x = new int[databaseSize*blockSize];
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
x[i] = (int) (Math.random()*2); // 0 or 1
|
||||
}
|
||||
Database database = new MemoryDatabase(settings, x);
|
||||
Profiler profiler = new Profiler(latency, bandwidth/10, bandwidth);
|
||||
Profiler profiler = new Profiler();
|
||||
|
||||
profiler.reset();
|
||||
testEvenSimplerScheme(settings, database, profiler);
|
||||
reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "EvenSimplerScheme");
|
||||
|
||||
reportResult(numServers, databaseSize, blockSize, profiler, "EvenSimplerScheme");
|
||||
|
||||
if (numServers == 2) {
|
||||
profiler.reset();
|
||||
testSimpleScheme(settings, database, profiler);
|
||||
reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "SimpleScheme");
|
||||
reportResult(numServers, databaseSize, blockSize, profiler, "SimpleScheme");
|
||||
|
||||
profiler.reset();
|
||||
testSimpleBlockScheme(settings, database, profiler);
|
||||
reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "SimpleBlockScheme");
|
||||
reportResult(numServers, databaseSize, blockSize, profiler, "SimpleBlockScheme");
|
||||
}
|
||||
|
||||
if (settings.getS() != 0 && numServers != 1) {
|
||||
profiler.reset();
|
||||
testGeneralInterPolyScheme(settings, database, profiler);
|
||||
reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "GeneralInterPolyScheme");
|
||||
reportResult(numServers, databaseSize, blockSize, profiler, "GeneralInterPolyScheme");
|
||||
|
||||
profiler.reset();
|
||||
testGeneralInterPolyBlockScheme(settings, database, profiler);
|
||||
reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "GeneralInterPolyBlockScheme");
|
||||
reportResult(numServers, databaseSize, blockSize, profiler, "GeneralInterPolyBlockScheme");
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportResult(int numServers, int databaseSize, int blockSize, int latency, int bandwidth, Profiler profiler, String protocolName) {
|
||||
private static void reportResult(int numServers, int databaseSize, int blockSize, Profiler profiler, String protocolName) {
|
||||
System.out.println(
|
||||
numServers + " " +
|
||||
databaseSize + " " +
|
||||
blockSize + " " +
|
||||
latency + " " +
|
||||
bandwidth + " " +
|
||||
protocolName + " " +
|
||||
profiler.getTotalCPUTime() + " " +
|
||||
profiler.getSent() + " " +
|
||||
profiler.getReceived() + " " +
|
||||
profiler.getTotalNetworkTime() + " "
|
||||
profiler.getReceived()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
runTests(); // warm-up
|
||||
System.out.println("================");
|
||||
runTests();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,20 +4,12 @@ import dk.au.pir.utils.FieldElement;
|
|||
import dk.au.pir.utils.MathUtils;
|
||||
|
||||
public class Profiler {
|
||||
private final int latency;
|
||||
private final int sendBandwidth;
|
||||
private final int receiveBandwidth;
|
||||
|
||||
private int sent;
|
||||
private int received;
|
||||
private int networkTime;
|
||||
private long startTime;
|
||||
private long stopTime;
|
||||
|
||||
public Profiler(int latency, int sendBandwidth, int receiveBandwidth) {
|
||||
this.latency = latency;
|
||||
this.sendBandwidth = sendBandwidth;
|
||||
this.receiveBandwidth = receiveBandwidth;
|
||||
public Profiler() {
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -33,19 +25,10 @@ public class Profiler {
|
|||
public void reset() {
|
||||
this.sent = 0;
|
||||
this.received = 0;
|
||||
this.networkTime = 0;
|
||||
this.startTime = 0;
|
||||
this.stopTime = 0;
|
||||
}
|
||||
|
||||
public void addNetworkDelay() {
|
||||
this.addNetworkDelay(1);
|
||||
}
|
||||
|
||||
public void addNetworkDelay(int n) {
|
||||
this.networkTime += latency * n;
|
||||
}
|
||||
|
||||
public int clientSend(int number) {
|
||||
this.sent += log2(number);
|
||||
return number;
|
||||
|
@ -115,10 +98,6 @@ public class Profiler {
|
|||
return this.stopTime - this.startTime;
|
||||
}
|
||||
|
||||
public int getTotalNetworkTime() {
|
||||
return networkTime + (this.sent/this.sendBandwidth) + (this.received/this.receiveBandwidth);
|
||||
}
|
||||
|
||||
public int log2(int n) {
|
||||
if (n == 0) {
|
||||
return 1; // technically incorrect but for the sake of profiling, a 0-bit requires 1 bit of space
|
||||
|
|
|
@ -15,14 +15,12 @@ public class EvenSimplerClient {
|
|||
}
|
||||
|
||||
public int receiveBit(int index) {
|
||||
this.profiler.addNetworkDelay(2);
|
||||
int[] data = this.profiler.clientReceive(this.servers[0].giveDatabase());
|
||||
return data[index];
|
||||
}
|
||||
|
||||
public int[] receiveBits(int record) {
|
||||
int[] res = new int[settings.getBlocksize()];
|
||||
this.profiler.addNetworkDelay();
|
||||
int[] data = this.profiler.clientReceive(this.servers[0].giveDatabase());
|
||||
System.arraycopy(data, (record * settings.getBlocksize()), res, 0, settings.getBlocksize());
|
||||
return res;
|
||||
|
|
|
@ -60,7 +60,6 @@ public class InterPolyClient {
|
|||
private int receiveBit(int index) {
|
||||
FieldElement[] randoms = this.getRandomFieldElements();
|
||||
FieldElement[] Fs = new FieldElement[this.servers.length];
|
||||
this.profiler.addNetworkDelay(2);
|
||||
for (int z = 0; z < this.servers.length; z++) {
|
||||
Fs[z] = this.profiler.clientReceive(this.servers[z].F(this.profiler.clientSend(this.getGs(index, z+1, randoms))));
|
||||
}
|
||||
|
@ -84,7 +83,6 @@ public class InterPolyClient {
|
|||
/**
|
||||
* 1) Compute all the Gs for each server, s.t. the first index should be the blocksize and it should contain all the Gs for the given index
|
||||
*/
|
||||
this.profiler.addNetworkDelay(2);
|
||||
for (int z = 0; z < this.servers.length; z++) {
|
||||
FieldElement[][] Gs = new FieldElement[settings.getBlocksize()][this.s];
|
||||
for (int i = 0; i < settings.getBlocksize(); i++) {
|
||||
|
|
|
@ -36,7 +36,6 @@ public class SimpleClient {
|
|||
S2[index] = 1;
|
||||
}
|
||||
|
||||
this.profiler.addNetworkDelay(2);
|
||||
int resBit1 = this.profiler.clientReceive(this.servers[0].computeBit(this.profiler.clientSend(S1)));
|
||||
int resBit2 = this.profiler.clientReceive(this.servers[1].computeBit(this.profiler.clientSend(S2)));
|
||||
|
||||
|
@ -61,7 +60,6 @@ public class SimpleClient {
|
|||
}
|
||||
}
|
||||
|
||||
this.profiler.addNetworkDelay(2);
|
||||
int[] resBit1 = this.profiler.clientReceive(this.servers[0].computeBits(this.profiler.clientSend(S1s)));
|
||||
int[] resBit2 = this.profiler.clientReceive(this.servers[1].computeBits(this.profiler.clientSend(S2s)));
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ public class PIRSettings {
|
|||
this.s = calculateS(numServers, databaseSize);
|
||||
this.sequences = ProtocolUtils.createSequences(s, numServers, databaseSize);
|
||||
} catch (IllegalArgumentException error) {
|
||||
System.out.println("pls");
|
||||
this.s = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user