From 10e59d0ba4ecfdf8883a4525bded131f3eb9389d Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Mon, 27 Jul 2020 18:33:10 -0400 Subject: [PATCH 1/8] - Create Dataset Generator class, to generate multiple types of datasets for test --- include/CPISync/Syncs/GenSync.h | 16 +- src/Syncs/GenSync.cpp | 13 +- src/Syncs/IBLTMultiset.cpp | 1 - tests/DatasetGenerator.h | 274 ++++++++++++++++++++++++++++++++ tests/TestAuxiliary.h | 58 +++++-- 5 files changed, 345 insertions(+), 17 deletions(-) create mode 100644 tests/DatasetGenerator.h diff --git a/include/CPISync/Syncs/GenSync.h b/include/CPISync/Syncs/GenSync.h index 7492b7d..ce488fe 100644 --- a/include/CPISync/Syncs/GenSync.h +++ b/include/CPISync/Syncs/GenSync.h @@ -63,7 +63,7 @@ class GenSync { * 3. del - a pointer to the dell method of my GenSync object * 4. pGenSync - a pointer to this GenSync object * @param data The initial data with which to populate the data structure. The data is added element by element - * so that synchronization method metadata can be properly maintained. Initilizes to the empty list + * so that synchronization method metadata can be properly maintained. Initializes to the empty list * if not specified. * */ @@ -334,6 +334,10 @@ class GenSync { END // one after the end of iterable options }; + SyncProtocol getProtocol() { + return myProtocol; + } + private: @@ -359,6 +363,12 @@ class GenSync { /** The file to which to output any additions to the data structure. */ shared_ptr outFile; + + SyncProtocol myProtocol; + + void setProtocol(SyncProtocol proto) { + myProtocol = proto; + } }; @@ -399,6 +409,10 @@ class GenSync::Builder { return *this; } + SyncProtocol getProtocol() { + return this->proto; + } + /** * Sets the host to which to connect for synchronization in a socket-based sync. */ diff --git a/src/Syncs/GenSync.cpp b/src/Syncs/GenSync.cpp index 150d23d..55ccef4 100644 --- a/src/Syncs/GenSync.cpp +++ b/src/Syncs/GenSync.cpp @@ -421,10 +421,15 @@ GenSync GenSync::Builder::build() { } theMeths.push_back(myMeth); - if (fileName.isNullQ()) // is data to be drawn from a file? - return GenSync(theComms, theMeths, _postProcess); - else - return GenSync(theComms, theMeths, fileName); + if (fileName.isNullQ()) { // is data to be drawn from a file? + GenSync obj = GenSync(theComms, theMeths, _postProcess); + obj.setProtocol(proto); + return obj; + } else { + GenSync obj = GenSync(theComms, theMeths, fileName); + obj.setProtocol(proto); + return obj; + } } // static consts diff --git a/src/Syncs/IBLTMultiset.cpp b/src/Syncs/IBLTMultiset.cpp index 5aecf08..839d958 100644 --- a/src/Syncs/IBLTMultiset.cpp +++ b/src/Syncs/IBLTMultiset.cpp @@ -50,7 +50,6 @@ void IBLTMultiset::_insertModular(long plusOrMinus, ZZ key, ZZ value) { for(int ii=0; ii < N_HASH; ii++){ hash_t hk = _hashK(key, ii); long startEntry = ii * bucketsPerHash; - long pos = startEntry + (hk%bucketsPerHash); IBLTMultiset::HashTableEntry& entry = hashTable.at(startEntry + (hk%bucketsPerHash)); hash_t modHashCheck = _hashK(key, N_HASHCHECK) % LARGE_PRIME; diff --git a/tests/DatasetGenerator.h b/tests/DatasetGenerator.h new file mode 100644 index 0000000..ee3d645 --- /dev/null +++ b/tests/DatasetGenerator.h @@ -0,0 +1,274 @@ +// +// Created by Shubham Arora on 7/21/20. +// + +#include +#include +#include + +#ifndef CPISYNC_DATASETGENERATOR_H +#define CPISYNC_DATASETGENERATOR_H + +using namespace std; + +const size_t _eltSize = sizeof(randZZ()); // Size of elements stored in sync tests in bytes + + +/** + * class to generate testing dataset for unit tests + * also populates the dataset into GenSyncClient and GenSyncServer objects + */ +class DatasetGenerator { +public: + + struct Dataset { + vector> client; + vector> server; + multiset reconciled; + string desc; // description of dataset + }; + +/** +* generate list of data for the syncType +*/ + static vector + generate(GenSync::SyncProtocol syncType) { + vector result; + addEmptySets(result); + addOneEmptySet(result); + addSubsetData(result); + addBigDiffData(result); + addHugeDiffData(result); + addEqualData(result); + + + switch (syncType) { + case GenSync::SyncProtocol::CPISync: + case GenSync::SyncProtocol::FullSync: + cout << "Multiset type sync\n"; +// addMultisetData(res); + break; + default: + break; + } + + return result; + } + +/** +* add elements in `dataSet` to client and server, +* add the reconciliation result in `reconciled` +*/ + static void addElements(GenSync &GenSyncClient, GenSync &GenSyncServer, + multiset &reconciled, const pair>, vector>> &dataSet) { + // add client data + for (const auto &clientData: dataSet.first) { + GenSyncClient.addElem(clientData); + reconciled.insert(clientData->print()); + } + + // add server data + for (const auto &serverData: dataSet.second) { + GenSyncServer.addElem(serverData); + reconciled.insert(serverData->print()); + } + + // add union data to reconciled - added + + } + + /** +* add elements in `dataSet` to client and server, +* add the reconciliation result in `reconciled` +*/ + static void addElements(GenSync &GenSyncClient, GenSync &GenSyncServer, const DatasetGenerator::Dataset &dataSet) { + // add client data + for (const auto &clientData: dataSet.client) { + GenSyncClient.addElem(clientData); + } + + // add server data + for (const auto &serverData: dataSet.server) { + GenSyncServer.addElem(serverData); + } + } + +private: + + + /** + * returns a vector of unique DataObject elements + * @param countOfElements - no of unique elements + * @return - vector of DataObjects + */ + static vector> getUniqueElements(unsigned long countOfElements) { + vector> result; + std::set dataSet; + ZZ data = rep(random_ZZ_p()); + for (unsigned long jj = 0; jj < countOfElements; jj++) { + //Checks if elements have already been added before adding them to objectsPtr to ensure that sync is being + //performed on a set rather than a multiset + data = rep(random_ZZ_p()); + //While you fail to add an element to the set (Because it is a duplicate) + while (!dataSet.insert(data).second) { + if (dataSet.size() == pow(2, _eltSize * 8)) { + string errorMsg = + "Attempting to add more elements to a set than can be represented by " + toStr(_eltSize) + + " bytes"; + Logger::error_and_quit(errorMsg); + } + data = rep(random_ZZ_p()); + } + result.push_back(make_shared(data)); + } + return result; + } + + + /** + * Adds elements to the clientData and serverData and return a multist containing the elements that were added + * This vector contains SERVER_MINUS_CLIENT elements that are only added to the server, followed by CLIENT_MINUS_SERVER + * elements that are only on the client. The remaining elements are elements that both the server and client have + * @param SIMILAR # of same elems between server and client + * @param SERVER_MINUS_CLIENT # of elems on server but not on client + * @param CLIENT_MINUS_SERVER # of elems on client but not on server + * @param serverData server data object + * @param clientData client data object + * @return reconciled multiset off all elements added + */ + static void getElems(const long SIMILAR, + const long SERVER_MINUS_CLIENT, + const long CLIENT_MINUS_SERVER, + vector> &serverData, + vector> &clientData, multiset &reconciled + ) { + + vector> objectsPtr; + std::set dataSet; + ZZ data = rep(random_ZZ_p()); + + //Creates a set of unique elements + for (unsigned long jj = 0; jj < SIMILAR + SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) { + //Checks if elements have already been added before adding them to objectsPtr to ensure that sync is being + //performed on a set rather than a multiset + data = rep(random_ZZ_p()); + //While you fail to add an element to the set (Because it is a duplicate) + while (!dataSet.insert(data).second) { + if (dataSet.size() == pow(2, _eltSize * 8)) { + string errorMsg = + "Attempting to add more elements to a set than can be represented by " + toStr(_eltSize) + + " bytes"; + Logger::error_and_quit(errorMsg); + } + data = rep(random_ZZ_p()); + } + objectsPtr.push_back(make_shared(data)); + reconciled.insert(objectsPtr[jj]->print()); + } + + // add data objects unique to the server + for (int jj = 0; jj < SERVER_MINUS_CLIENT; jj++) + serverData.push_back(objectsPtr[jj]); + + // add data objects unique to the client + for (int jj = SERVER_MINUS_CLIENT; jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) + clientData.push_back(objectsPtr[jj]); + + // add common data objects to both + for (int jj = SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; + jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER + SIMILAR; jj++) { + clientData.push_back(objectsPtr[jj]); + serverData.push_back(objectsPtr[jj]); + } + + } + + // Both A and B are empty sets + static void addEmptySets(vector &allDataSet) { + vector> res; + multiset recon; + allDataSet.push_back(Dataset{res, res, recon, "empty sets"}); + } + + // A is empty, B is not + // B is empty, A is not + static void + addOneEmptySet(vector &allDataSet) { + vector> full, empty; + multiset reconciled; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; + + getElems(0, 0, CLIENT_MINUS_SERVER, empty, full, reconciled); + + allDataSet.push_back(Dataset{full, empty, reconciled, "one empty sets"}); + allDataSet.push_back(Dataset{empty, full, reconciled, "one empty sets"}); + } + + + // A is subset B + // B is subset A + static void addSubsetData(vector &allDataSet) { + vector> subset, superset; + multiset reconciled; + const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + 1; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; + + getElems(SIMILAR, 0, CLIENT_MINUS_SERVER, subset, superset, reconciled); + + allDataSet.push_back(Dataset{superset, subset, reconciled, "subset sets"}); + allDataSet.push_back(Dataset{subset, superset, reconciled, "subset sets"}); + + } + + // A intersection B is non-empty set but A - B is a huge set + // A intersection B is non-empty set but B - A is a huge set + static void addBigDiffData(vector &allDataSet) { + vector> setA, setB; + multiset reconciled; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int SIMILAR = static_cast (rand() % SCHAR_MAX) + 1; // smaller than the two above + + getElems(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + + allDataSet.push_back(Dataset{setA, setB, reconciled, "big diff sets"}); + allDataSet.push_back(Dataset{setB, setA, reconciled, "big diff sets"}); + } + + // A and B have no intersection and both are huge sets + static void addHugeDiffData(vector &allDataSet) { + vector> setA, setB; + multiset reconciled; + + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int SIMILAR = 0; + + getElems(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + + allDataSet.push_back(Dataset{setA, setB, reconciled, "huge diff sets"}); + allDataSet.push_back(Dataset{setB, setA, reconciled, "huge diff sets"}); + } + + // A and B are exactly equal but non-empty + static void addEqualData(vector &allDataSet) { + vector> setA, setB; + const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + multiset reconciled; + + getElems(SIMILAR, 0, 0, setA, setB, reconciled); + + allDataSet.push_back(Dataset{setA, setB, reconciled, "equal data sets"}); + } + + // A and B have multiset data + static void addMultisetData(vector,multiset>> &dataSet) { + multiset setA, setB; + + dataSet.push_back(make_pair(setA, setB)); + } + +}; + + +#endif //CPISYNC_DATASETGENERATOR_H diff --git a/tests/TestAuxiliary.h b/tests/TestAuxiliary.h index 820436c..b3a6f54 100644 --- a/tests/TestAuxiliary.h +++ b/tests/TestAuxiliary.h @@ -16,6 +16,7 @@ #include #include #include +#include "DatasetGenerator.h" #ifndef CPISYNCLIB_GENERIC_SYNC_TESTS_H #define CPISYNCLIB_GENERIC_SYNC_TESTS_H @@ -400,7 +401,7 @@ inline bool checkServerSuccess(multiset &resServer, multiset &re * @return true iff server reconciliation check is successful, false otherwise */ inline bool -checkServerSucceeded(multiset &resultantServer, multiset &reconciled, bool setofSets, bool oneWay, +checkServerSucceeded(multiset &resultantServer, const multiset &reconciled, bool setofSets, bool oneWay, forkHandleReport &serverReport) { if (!setofSets) { @@ -426,7 +427,7 @@ checkServerSucceeded(multiset &resultantServer, multiset &reconc * @return true iff client reconciliation check is successful, false otherwise */ inline bool -checkClientSucceeded(multiset &resultantClient, multiset &initialClient, multiset &reconciled, +checkClientSucceeded(multiset &resultantClient, multiset &initialClient, const multiset &reconciled, bool setofSets, bool oneWay, forkHandleReport &clientReport) { if (!oneWay) { // reconciliation conditions are same for client and server in two way sync @@ -460,7 +461,7 @@ checkClientSucceeded(multiset &resultantClient, multiset &initia */ inline bool createForkForTest(GenSync& GenSyncClient, GenSync& GenSyncServer,bool oneWay, bool probSync,bool syncParamTest, const unsigned int SIMILAR,const unsigned int CLIENT_MINUS_SERVER, - const unsigned int SERVER_MINUS_CLIENT, multiset reconciled, + const unsigned int SERVER_MINUS_CLIENT, const multiset &reconciled, bool setofSets){ int child_state; @@ -520,6 +521,9 @@ inline bool createForkForTest(GenSync& GenSyncClient, GenSync& GenSyncServer,boo clientReport); Logger::gLog(Logger::COMM, "waiting for test fork to finish, pid: " + toStr(getpid())); bool isSyncSuccess = isClientSuccess && bool(child_state); +// Logger::gLog(Logger::TEST, +// "client, status: " + toStr(clientReport.success) + ", check success: " + toStr(isClientSuccess) + +// ", syncSuccess: " + toStr(isSyncSuccess) ); return isSyncSuccess; } @@ -686,7 +690,7 @@ inline vector> addElements(bool Multiset, const long SIMI { if (dataSet.size() == pow(2, eltSize * 8)) { - string errorMsg = "Attempting to add more elements to a set than can bre represented by " + toStr(eltSize) + " bytes"; + string errorMsg = "Attempting to add more elements to a set than can be represented by " + toStr(eltSize) + " bytes"; Logger::error_and_quit(errorMsg); } data = rep(random_ZZ_p()); @@ -912,18 +916,50 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay (largeSync ? (rand() % largeLimit) + 1 : (rand() % UCHAR_MAX) + 1); // amt of elems unique to server (!= 0) multiset reconciled; - - // add elements to server, client and reconciled - auto objectsPtr = addElements(Multiset,SIMILAR,SERVER_MINUS_CLIENT,CLIENT_MINUS_SERVER,GenSyncServer,GenSyncClient,reconciled); - //Returns a boolean value for the success of the synchronization - success &= createForkForTest(GenSyncClient, GenSyncServer, oneWay, probSync, syncParamTest, SIMILAR, - CLIENT_MINUS_SERVER,SERVER_MINUS_CLIENT, reconciled,false); + vector dataList = DatasetGenerator::generate(GenSyncClient.getProtocol()); + int testNo = 0; + for (const auto& testData : dataList) { + bool thisTestSuccess = true; + DatasetGenerator::addElements(GenSyncClient, GenSyncServer, testData); + reconciled = testData.reconciled; + + int clientInitSize = GenSyncClient.dumpElements().size(); + int serverInitSize = GenSyncServer.dumpElements().size(); + + //Returns a boolean value for the success of the synchronization + thisTestSuccess &= createForkForTest(GenSyncClient, GenSyncServer, oneWay, probSync, syncParamTest, SIMILAR, + CLIENT_MINUS_SERVER,SERVER_MINUS_CLIENT, testData.reconciled,false); + + // TODO: what effect does this have? + // how to best delete data? + // Remove all elements from GenSyncs and clear dynamically allocated memory for reuse + thisTestSuccess &= GenSyncServer.clearData(); + thisTestSuccess &= GenSyncClient.clearData(); +// reconciled.clear(); + +// if (thisTestSuccess) { +//// cout << "sync successful: " << testData.desc << endl; +// } else{ +// cout << "Finished test no: " << testNo << endl; +// cout << "sync failed: " << testData.desc << endl; +// cout << "Client size : " << clientInitSize << endl; +// cout << "Server size : " << serverInitSize << endl; +// } + testNo++; + success &= thisTestSuccess; + } + + // add elements to server, client and reconciled +// auto objectsPtr = addElements(Multiset,SIMILAR,SERVER_MINUS_CLIENT,CLIENT_MINUS_SERVER,GenSyncServer,GenSyncClient,reconciled); +// //Returns a boolean value for the success of the synchronization +// success &= createForkForTest(GenSyncClient, GenSyncServer, oneWay, probSync, syncParamTest, SIMILAR, +// CLIENT_MINUS_SERVER,SERVER_MINUS_CLIENT, reconciled,false); //Remove all elements from GenSyncs and clear dynamically allocated memory for reuse success &= GenSyncServer.clearData(); success &= GenSyncClient.clearData(); //Memory is deallocated here because these are shared_ptrs and are deleted when the last ptr to an object is deleted - objectsPtr.clear(); +// objectsPtr.clear(); reconciled.clear(); } return success; // returns success status of tests From f7bcd4421e05e75b985fe04235a192d6f258d02f Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Mon, 27 Jul 2020 19:46:43 -0400 Subject: [PATCH 2/8] - cleanup Dataset Gen code - remove unused params --- src/Syncs/CPISync.cpp | 1 + tests/DatasetGenerator.h | 192 ++++++++++++++++++++++++--------------- tests/TestAuxiliary.h | 48 ++-------- 3 files changed, 128 insertions(+), 113 deletions(-) diff --git a/src/Syncs/CPISync.cpp b/src/Syncs/CPISync.cpp index 60cb816..9735f91 100644 --- a/src/Syncs/CPISync.cpp +++ b/src/Syncs/CPISync.cpp @@ -467,6 +467,7 @@ bool CPISync::SyncClient(const shared_ptr& commSync, listgetXmitBytes()); mySyncStats.increment(SyncStats::RECV,commSync->getRecvBytes()); + Logger::gLog(Logger::METHOD, "client, sync fail, curDiff == maxDiff"); return false; } else { // Send more samples and try again diff --git a/tests/DatasetGenerator.h b/tests/DatasetGenerator.h index ee3d645..91fec77 100644 --- a/tests/DatasetGenerator.h +++ b/tests/DatasetGenerator.h @@ -11,7 +11,9 @@ using namespace std; +// these constants are used as is from TestAuxiliary.h const size_t _eltSize = sizeof(randZZ()); // Size of elements stored in sync tests in bytes +const size_t _largeLimit = static_cast(pow(2, 9)); // Max number of elements for *each* SIMILAR, CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT in largeSync /** @@ -29,11 +31,28 @@ class DatasetGenerator { }; /** -* generate list of data for the syncType -*/ + * generate list of data for the syncType + * @param isMultiset if specified, only returns multiset data + * @param isLargeSync if specified, only returns large no of elements in dataset + * @return + */ static vector - generate(GenSync::SyncProtocol syncType) { + generate(bool isMultiset, bool isLargeSync) { vector result; + + if(isMultiset && isLargeSync) { + Logger::error_and_quit("logic not implemented for large multiset sync at the moment"); + return result; + } + if(isMultiset) { + addMultisetData(result); + return result; + } + if(isLargeSync) { + addLargeData(result); + return result; + } + addEmptySets(result); addOneEmptySet(result); addSubsetData(result); @@ -41,46 +60,15 @@ class DatasetGenerator { addHugeDiffData(result); addEqualData(result); - - switch (syncType) { - case GenSync::SyncProtocol::CPISync: - case GenSync::SyncProtocol::FullSync: - cout << "Multiset type sync\n"; -// addMultisetData(res); - break; - default: - break; - } - return result; } /** -* add elements in `dataSet` to client and server, -* add the reconciliation result in `reconciled` -*/ - static void addElements(GenSync &GenSyncClient, GenSync &GenSyncServer, - multiset &reconciled, const pair>, vector>> &dataSet) { - // add client data - for (const auto &clientData: dataSet.first) { - GenSyncClient.addElem(clientData); - reconciled.insert(clientData->print()); - } - - // add server data - for (const auto &serverData: dataSet.second) { - GenSyncServer.addElem(serverData); - reconciled.insert(serverData->print()); - } - - // add union data to reconciled - added - - } - - /** -* add elements in `dataSet` to client and server, -* add the reconciliation result in `reconciled` -*/ + * + * @param GenSyncClient the client to update + * @param GenSyncServer the server to update + * @param dataSet the dataSet from which to initialize client and serer data + */ static void addElements(GenSync &GenSyncClient, GenSync &GenSyncServer, const DatasetGenerator::Dataset &dataSet) { // add client data for (const auto &clientData: dataSet.client) { @@ -97,36 +85,75 @@ class DatasetGenerator { /** - * returns a vector of unique DataObject elements - * @param countOfElements - no of unique elements - * @return - vector of DataObjects + * Adds multiset elements to the clientData, serverData and reconciled + * This vector contains SERVER_MINUS_CLIENT elements that are only added to the server, followed by CLIENT_MINUS_SERVER + * elements that are only on the client. The remaining elements are elements that both the server and client have + * @param SIMILAR # of same elems between server and client + * @param SERVER_MINUS_CLIENT # of elems on server but not on client + * @param CLIENT_MINUS_SERVER # of elems on client but not on server + * @param serverData server data object + * @param clientData client data object + * @return reconciled multiset off all elements added */ - static vector> getUniqueElements(unsigned long countOfElements) { - vector> result; + static void getMultisetElements(const long SIMILAR, + const long SERVER_MINUS_CLIENT, + const long CLIENT_MINUS_SERVER, + vector> &serverData, + vector> &clientData, multiset &reconciled) { + vector> objectsPtr; std::set dataSet; ZZ data = rep(random_ZZ_p()); - for (unsigned long jj = 0; jj < countOfElements; jj++) { - //Checks if elements have already been added before adding them to objectsPtr to ensure that sync is being - //performed on a set rather than a multiset - data = rep(random_ZZ_p()); - //While you fail to add an element to the set (Because it is a duplicate) - while (!dataSet.insert(data).second) { - if (dataSet.size() == pow(2, _eltSize * 8)) { - string errorMsg = - "Attempting to add more elements to a set than can be represented by " + toStr(_eltSize) + - " bytes"; - Logger::error_and_quit(errorMsg); + + long addElemCount = SERVER_MINUS_CLIENT; + //Adds elements to objects pointer for SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER and SIMILAR (hence 3 loops) + //Must be split to prevent half of a pair being added to SERVER_MINUS_CLIENT and the other half to CLIENT_MINUS_SERVER + for (int jj = 0; jj < 3; jj++) { + for (int kk = 0; kk < addElemCount; kk++) { + //Every 10 elements will have 1 pair and 1 triplet of elements + if (kk % 10 == 0 || kk % 10 == 2 || kk % 10 == 3) { + objectsPtr.push_back(make_shared(data)); + } else { //Prevent elements that have already been added from being added again data = randZZ(); + //While you fail to add an element to the set (Because it is a duplicate) + while (!get<1>(dataSet.insert(data))) + data = rep(random_ZZ_p()); + + objectsPtr.push_back(make_shared(data)); } - data = rep(random_ZZ_p()); } - result.push_back(make_shared(data)); + //Re-randomize the data between the different sections of the vector + data = rep(random_ZZ_p()); + + //Change the number of elements to add + if (jj == 0) + addElemCount = CLIENT_MINUS_SERVER; + else if (jj == 1) + addElemCount = SIMILAR; } - return result; + + // add data objects unique to the server + for (int jj = 0; jj < SERVER_MINUS_CLIENT; jj++) + serverData.push_back(objectsPtr[jj]); + + // add data objects unique to the client + for (int jj = SERVER_MINUS_CLIENT; jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) + clientData.push_back(objectsPtr[jj]); + + // add common data objects to both + for (int jj = SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; + jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER + SIMILAR; jj++) { + clientData.push_back(objectsPtr[jj]); + serverData.push_back(objectsPtr[jj]); + } + + for (int ii = 0; ii < SIMILAR + SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; ii++) { + reconciled.insert(objectsPtr[ii]->print()); + } + } /** - * Adds elements to the clientData and serverData and return a multist containing the elements that were added + * Adds elements to the clientData, serverData and reconciled * This vector contains SERVER_MINUS_CLIENT elements that are only added to the server, followed by CLIENT_MINUS_SERVER * elements that are only on the client. The remaining elements are elements that both the server and client have * @param SIMILAR # of same elems between server and client @@ -136,11 +163,11 @@ class DatasetGenerator { * @param clientData client data object * @return reconciled multiset off all elements added */ - static void getElems(const long SIMILAR, - const long SERVER_MINUS_CLIENT, - const long CLIENT_MINUS_SERVER, - vector> &serverData, - vector> &clientData, multiset &reconciled + static void getUniqueElements(const long SIMILAR, + const long SERVER_MINUS_CLIENT, + const long CLIENT_MINUS_SERVER, + vector> &serverData, + vector> &clientData, multiset &reconciled ) { vector> objectsPtr; @@ -198,7 +225,7 @@ class DatasetGenerator { multiset reconciled; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; - getElems(0, 0, CLIENT_MINUS_SERVER, empty, full, reconciled); + getUniqueElements(0, 0, CLIENT_MINUS_SERVER, empty, full, reconciled); allDataSet.push_back(Dataset{full, empty, reconciled, "one empty sets"}); allDataSet.push_back(Dataset{empty, full, reconciled, "one empty sets"}); @@ -213,7 +240,7 @@ class DatasetGenerator { const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; - getElems(SIMILAR, 0, CLIENT_MINUS_SERVER, subset, superset, reconciled); + getUniqueElements(SIMILAR, 0, CLIENT_MINUS_SERVER, subset, superset, reconciled); allDataSet.push_back(Dataset{superset, subset, reconciled, "subset sets"}); allDataSet.push_back(Dataset{subset, superset, reconciled, "subset sets"}); @@ -229,7 +256,7 @@ class DatasetGenerator { const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; const unsigned int SIMILAR = static_cast (rand() % SCHAR_MAX) + 1; // smaller than the two above - getElems(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); allDataSet.push_back(Dataset{setA, setB, reconciled, "big diff sets"}); allDataSet.push_back(Dataset{setB, setA, reconciled, "big diff sets"}); @@ -244,7 +271,7 @@ class DatasetGenerator { const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; const unsigned int SIMILAR = 0; - getElems(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); allDataSet.push_back(Dataset{setA, setB, reconciled, "huge diff sets"}); allDataSet.push_back(Dataset{setB, setA, reconciled, "huge diff sets"}); @@ -256,16 +283,37 @@ class DatasetGenerator { const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; multiset reconciled; - getElems(SIMILAR, 0, 0, setA, setB, reconciled); + getUniqueElements(SIMILAR, 0, 0, setA, setB, reconciled); allDataSet.push_back(Dataset{setA, setB, reconciled, "equal data sets"}); } // A and B have multiset data - static void addMultisetData(vector,multiset>> &dataSet) { - multiset setA, setB; + static void addMultisetData(vector &allDataSet) { + vector> setA, setB; + multiset reconciled; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + + getMultisetElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + + allDataSet.push_back(Dataset{setA, setB, reconciled, "multiset data"}); + allDataSet.push_back(Dataset{setB, setA, reconciled, "multiset data"}); + } + + // A and B have large unique data sets + static void addLargeData(vector &allDataSet) { + vector> setA, setB; + multiset reconciled; + const unsigned int SIMILAR = static_cast (rand() % _largeLimit) + 1 ; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % _largeLimit) + 1 ; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % _largeLimit) + 1 ; + + getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); - dataSet.push_back(make_pair(setA, setB)); + allDataSet.push_back(Dataset{setA, setB, reconciled, "large data sets"}); + allDataSet.push_back(Dataset{setB, setA, reconciled, "large data sets"}); } }; diff --git a/tests/TestAuxiliary.h b/tests/TestAuxiliary.h index b3a6f54..bee083a 100644 --- a/tests/TestAuxiliary.h +++ b/tests/TestAuxiliary.h @@ -460,9 +460,7 @@ checkClientSucceeded(multiset &resultantClient, multiset &initia * @return true if reconciliation succeeded, false otherwise */ inline bool createForkForTest(GenSync& GenSyncClient, GenSync& GenSyncServer,bool oneWay, bool probSync,bool syncParamTest, - const unsigned int SIMILAR,const unsigned int CLIENT_MINUS_SERVER, - const unsigned int SERVER_MINUS_CLIENT, const multiset &reconciled, - bool setofSets){ + const multiset &reconciled, bool setofSets){ int child_state; int my_opt = 0; @@ -899,7 +897,7 @@ inline void addElemsSetofSets(GenSync &GenSyncServer, * @return True if *every* recon test appears to be successful (and, if syncParamTest==true, reports that it is successful) and false otherwise. */ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay, bool probSync, bool syncParamTest, - bool Multiset,bool largeSync){ + bool Multiset, bool largeSync){ //Seed test so that changing other tests does not cause failure in tests with a small probability of failure //Don't seed oneWay tests because they loop on the outside of syncTest and you want different values for each run @@ -908,59 +906,27 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay //If one way, run 1 time, if not run NUM_TESTS times for(int ii = 0 ; ii < (oneWay ? 1 : NUM_TESTS); ii++) { - const unsigned int SIMILAR = static_cast - (largeSync ? (rand() % largeLimit) + 1 : (rand() % UCHAR_MAX) + 1); // amt of elems common to both GenSyncs (!= 0) - const unsigned int CLIENT_MINUS_SERVER = static_cast - (largeSync ? (rand() % largeLimit) + 1 : (rand() % UCHAR_MAX) + 1); // amt of elems unique to client (!= 0) - const unsigned int SERVER_MINUS_CLIENT = static_cast - (largeSync ? (rand() % largeLimit) + 1 : (rand() % UCHAR_MAX) + 1); // amt of elems unique to server (!= 0) - - multiset reconciled; - vector dataList = DatasetGenerator::generate(GenSyncClient.getProtocol()); - int testNo = 0; + vector dataList = DatasetGenerator::generate(Multiset, largeSync); for (const auto& testData : dataList) { bool thisTestSuccess = true; + // add elements to server, client DatasetGenerator::addElements(GenSyncClient, GenSyncServer, testData); - reconciled = testData.reconciled; - - int clientInitSize = GenSyncClient.dumpElements().size(); - int serverInitSize = GenSyncServer.dumpElements().size(); //Returns a boolean value for the success of the synchronization - thisTestSuccess &= createForkForTest(GenSyncClient, GenSyncServer, oneWay, probSync, syncParamTest, SIMILAR, - CLIENT_MINUS_SERVER,SERVER_MINUS_CLIENT, testData.reconciled,false); + thisTestSuccess &= createForkForTest(GenSyncClient, GenSyncServer, oneWay, probSync, syncParamTest, + testData.reconciled, false); - // TODO: what effect does this have? - // how to best delete data? // Remove all elements from GenSyncs and clear dynamically allocated memory for reuse thisTestSuccess &= GenSyncServer.clearData(); thisTestSuccess &= GenSyncClient.clearData(); -// reconciled.clear(); - -// if (thisTestSuccess) { -//// cout << "sync successful: " << testData.desc << endl; -// } else{ -// cout << "Finished test no: " << testNo << endl; -// cout << "sync failed: " << testData.desc << endl; -// cout << "Client size : " << clientInitSize << endl; -// cout << "Server size : " << serverInitSize << endl; -// } - testNo++; + success &= thisTestSuccess; } - // add elements to server, client and reconciled -// auto objectsPtr = addElements(Multiset,SIMILAR,SERVER_MINUS_CLIENT,CLIENT_MINUS_SERVER,GenSyncServer,GenSyncClient,reconciled); -// //Returns a boolean value for the success of the synchronization -// success &= createForkForTest(GenSyncClient, GenSyncServer, oneWay, probSync, syncParamTest, SIMILAR, -// CLIENT_MINUS_SERVER,SERVER_MINUS_CLIENT, reconciled,false); //Remove all elements from GenSyncs and clear dynamically allocated memory for reuse success &= GenSyncServer.clearData(); success &= GenSyncClient.clearData(); - //Memory is deallocated here because these are shared_ptrs and are deleted when the last ptr to an object is deleted -// objectsPtr.clear(); - reconciled.clear(); } return success; // returns success status of tests } From 948ea604db254d4bfe5f3b26d3796cdc91de66c5 Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Mon, 27 Jul 2020 19:57:07 -0400 Subject: [PATCH 3/8] undo get protocol changes --- include/CPISync/Syncs/GenSync.h | 16 +--------------- src/Syncs/GenSync.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/include/CPISync/Syncs/GenSync.h b/include/CPISync/Syncs/GenSync.h index ce488fe..7492b7d 100644 --- a/include/CPISync/Syncs/GenSync.h +++ b/include/CPISync/Syncs/GenSync.h @@ -63,7 +63,7 @@ class GenSync { * 3. del - a pointer to the dell method of my GenSync object * 4. pGenSync - a pointer to this GenSync object * @param data The initial data with which to populate the data structure. The data is added element by element - * so that synchronization method metadata can be properly maintained. Initializes to the empty list + * so that synchronization method metadata can be properly maintained. Initilizes to the empty list * if not specified. * */ @@ -334,10 +334,6 @@ class GenSync { END // one after the end of iterable options }; - SyncProtocol getProtocol() { - return myProtocol; - } - private: @@ -363,12 +359,6 @@ class GenSync { /** The file to which to output any additions to the data structure. */ shared_ptr outFile; - - SyncProtocol myProtocol; - - void setProtocol(SyncProtocol proto) { - myProtocol = proto; - } }; @@ -409,10 +399,6 @@ class GenSync::Builder { return *this; } - SyncProtocol getProtocol() { - return this->proto; - } - /** * Sets the host to which to connect for synchronization in a socket-based sync. */ diff --git a/src/Syncs/GenSync.cpp b/src/Syncs/GenSync.cpp index 55ccef4..150d23d 100644 --- a/src/Syncs/GenSync.cpp +++ b/src/Syncs/GenSync.cpp @@ -421,15 +421,10 @@ GenSync GenSync::Builder::build() { } theMeths.push_back(myMeth); - if (fileName.isNullQ()) { // is data to be drawn from a file? - GenSync obj = GenSync(theComms, theMeths, _postProcess); - obj.setProtocol(proto); - return obj; - } else { - GenSync obj = GenSync(theComms, theMeths, fileName); - obj.setProtocol(proto); - return obj; - } + if (fileName.isNullQ()) // is data to be drawn from a file? + return GenSync(theComms, theMeths, _postProcess); + else + return GenSync(theComms, theMeths, fileName); } // static consts From ca1e75c3a3dbc182d9974a356561c28ec9eba463 Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Tue, 28 Jul 2020 17:02:19 -0400 Subject: [PATCH 4/8] add test debug info --- tests/TestAuxiliary.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/TestAuxiliary.h b/tests/TestAuxiliary.h index bee083a..84b936e 100644 --- a/tests/TestAuxiliary.h +++ b/tests/TestAuxiliary.h @@ -920,6 +920,17 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay thisTestSuccess &= GenSyncServer.clearData(); thisTestSuccess &= GenSyncClient.clearData(); + if (!thisTestSuccess) { + cout << "test fail, client size: " << testData.client.size() + << ", server size: " << testData.server.size() + << ", type: " << testData.desc << endl; + } + else { + cout << "test success, client size: " << testData.client.size() + << ", server size: " << testData.server.size() + << ", type: " << testData.desc << endl; + } + success &= thisTestSuccess; } From 52e3dc3e7bbdffdb925fab40597bb528a59e5ea4 Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Wed, 29 Jul 2020 16:25:50 -0400 Subject: [PATCH 5/8] - change data set sizes to values consistent with earlier filter sizes --- src/Syncs/CPISync.cpp | 5 +++-- tests/DatasetGenerator.h | 31 +++++++++++++++---------------- tests/TestAuxiliary.h | 13 ++++--------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/Syncs/CPISync.cpp b/src/Syncs/CPISync.cpp index 9735f91..d7cca5d 100644 --- a/src/Syncs/CPISync.cpp +++ b/src/Syncs/CPISync.cpp @@ -282,8 +282,9 @@ Logger::gLog(Logger::METHOD,"Entering CPISync::set_reconcile"); for (itCPI = CPI_hash.begin(); itCPI != CPI_hash.end(); itCPI++) append(delta_self, to_ZZ_p(itCPI->first)); - } else // otherSetSize >=1 - the other set has something - if (CPI_hash.empty()) { // I have nothing new + } else if (CPI_hash.empty()) { // I have nothing new // otherSetSize >=1 - the other set has something + Logger::gLog(Logger::METHOD, + "CPISync::set_reconcile:: I have nothing new, the other set has something"); return true; } else { // we both have something new vec_ZZ_p coefficient_P, coefficient_Q; diff --git a/tests/DatasetGenerator.h b/tests/DatasetGenerator.h index 91fec77..efa7db8 100644 --- a/tests/DatasetGenerator.h +++ b/tests/DatasetGenerator.h @@ -24,8 +24,8 @@ class DatasetGenerator { public: struct Dataset { - vector> client; vector> server; + vector> client; multiset reconciled; string desc; // description of dataset }; @@ -221,14 +221,17 @@ class DatasetGenerator { // B is empty, A is not static void addOneEmptySet(vector &allDataSet) { - vector> full, empty; + vector> setA, setB; multiset reconciled; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; - getUniqueElements(0, 0, CLIENT_MINUS_SERVER, empty, full, reconciled); + getUniqueElements(0, 0, CLIENT_MINUS_SERVER, setA, setB, reconciled); + allDataSet.push_back(Dataset{setA, setB, reconciled, "server empty set"}); - allDataSet.push_back(Dataset{full, empty, reconciled, "one empty sets"}); - allDataSet.push_back(Dataset{empty, full, reconciled, "one empty sets"}); + vector> setC, setD; + multiset reconciled2; + getUniqueElements(0, 0, CLIENT_MINUS_SERVER, setC, setD, reconciled2); + allDataSet.push_back(Dataset{setD, setC, reconciled2, "client empty set"}); } @@ -243,7 +246,6 @@ class DatasetGenerator { getUniqueElements(SIMILAR, 0, CLIENT_MINUS_SERVER, subset, superset, reconciled); allDataSet.push_back(Dataset{superset, subset, reconciled, "subset sets"}); - allDataSet.push_back(Dataset{subset, superset, reconciled, "subset sets"}); } @@ -252,14 +254,13 @@ class DatasetGenerator { static void addBigDiffData(vector &allDataSet) { vector> setA, setB; multiset reconciled; - const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; - const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SIMILAR = static_cast (rand() % SCHAR_MAX) + 1; // smaller than the two above getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); allDataSet.push_back(Dataset{setA, setB, reconciled, "big diff sets"}); - allDataSet.push_back(Dataset{setB, setA, reconciled, "big diff sets"}); } // A and B have no intersection and both are huge sets @@ -267,14 +268,12 @@ class DatasetGenerator { vector> setA, setB; multiset reconciled; - const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; - const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1 ; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SIMILAR = 0; getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); - allDataSet.push_back(Dataset{setA, setB, reconciled, "huge diff sets"}); - allDataSet.push_back(Dataset{setB, setA, reconciled, "huge diff sets"}); } // A and B are exactly equal but non-empty @@ -292,9 +291,9 @@ class DatasetGenerator { static void addMultisetData(vector &allDataSet) { vector> setA, setB; multiset reconciled; - const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; - const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; - const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; + const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; + const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + 1; + const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + 1; getMultisetElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); diff --git a/tests/TestAuxiliary.h b/tests/TestAuxiliary.h index 84b936e..39394ed 100644 --- a/tests/TestAuxiliary.h +++ b/tests/TestAuxiliary.h @@ -26,7 +26,7 @@ const int NUM_TESTS = 1; // Times to run oneWay and twoWay sync tests const size_t eltSizeSq = (size_t) pow((double) sizeof(randZZ()), 2.0); // Size^2 of elements stored in sync tests const size_t eltSize = sizeof(randZZ()); // Size of elements stored in sync tests in bytes -const int mBar = 2 * UCHAR_MAX; // Max differences between client and server in sync tests +const int mBar = 3 * UCHAR_MAX; // Max differences between client and server in sync tests const size_t largeLimit = static_cast(pow(2, 9)); // Max number of elements for *each* SIMILAR, CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT in largeSync const int mBarLarge = largeLimit * 2; // Maximum sum of CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT const int partitions = 5; //The "arity" of the ptree in InterCPISync if it needs to recurse to complete the sync @@ -921,14 +921,9 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay thisTestSuccess &= GenSyncClient.clearData(); if (!thisTestSuccess) { - cout << "test fail, client size: " << testData.client.size() - << ", server size: " << testData.server.size() - << ", type: " << testData.desc << endl; - } - else { - cout << "test success, client size: " << testData.client.size() - << ", server size: " << testData.server.size() - << ", type: " << testData.desc << endl; + Logger::gLog(Logger::TEST, "test fail type: " + testData.desc + + ", client size: " + toStr(testData.client.size()) + + ", server size: " + toStr(testData.server.size())); } success &= thisTestSuccess; From c7c8fff991e18d1ba071edb26b5549f348628390 Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Wed, 29 Jul 2020 16:39:45 -0400 Subject: [PATCH 6/8] increase cuckoo filter size --- tests/unit/CuckooSyncTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/CuckooSyncTest.cpp b/tests/unit/CuckooSyncTest.cpp index ca4352e..fc6c87c 100644 --- a/tests/unit/CuckooSyncTest.cpp +++ b/tests/unit/CuckooSyncTest.cpp @@ -27,7 +27,7 @@ void CuckooSyncTest::setReconcileTest() { const size_t bits = sizeof(randZZ()); const size_t fngprtSize = 12; const size_t bucketSize = 4; - const size_t filterSize = UCHAR_MAX + 1; // UCHAR_MAX is taken from syncTest + const size_t filterSize = 512 * (UCHAR_MAX + 1); // UCHAR_MAX is taken from syncTest const size_t maxKicks = 500; GenSync server = GenSync::Builder() From 91bcea3c18ade9242ed9b96cb6f119097a844e91 Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Mon, 3 Aug 2020 08:45:47 -0400 Subject: [PATCH 7/8] - updated dataset Struct - update usage in all places --- tests/DatasetGenerator.h | 168 +++++++++++++++++++-------------------- tests/TestAuxiliary.h | 58 +++++++++----- 2 files changed, 123 insertions(+), 103 deletions(-) diff --git a/tests/DatasetGenerator.h b/tests/DatasetGenerator.h index efa7db8..200cb84 100644 --- a/tests/DatasetGenerator.h +++ b/tests/DatasetGenerator.h @@ -11,9 +11,7 @@ using namespace std; -// these constants are used as is from TestAuxiliary.h -const size_t _eltSize = sizeof(randZZ()); // Size of elements stored in sync tests in bytes -const size_t _largeLimit = static_cast(pow(2, 9)); // Max number of elements for *each* SIMILAR, CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT in largeSync + /** @@ -23,32 +21,36 @@ const size_t _largeLimit = static_cast(pow(2, 9)); // Max number of e class DatasetGenerator { public: + const static size_t _eltSize = sizeof(randZZ()); // Size of elements stored in sync tests in bytes + const static size_t _largeLimit = static_cast(pow(2, 9)); // Max number of elements for *each* SIMILAR, CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT in largeSync + struct Dataset { vector> server; vector> client; multiset reconciled; string desc; // description of dataset + vector> allObjects; }; /** * generate list of data for the syncType - * @param isMultiset if specified, only returns multiset data - * @param isLargeSync if specified, only returns large no of elements in dataset + * @param isMultiset if true, only returns multiset data + * @param isLargeSync if true, only returns large no of elements in dataset * @return */ static vector generate(bool isMultiset, bool isLargeSync) { vector result; - + // use a seed if(isMultiset && isLargeSync) { - Logger::error_and_quit("logic not implemented for large multiset sync at the moment"); + Logger::error_and_quit("logic not implemented for large multiset sync"); return result; } - if(isMultiset) { + else if(isMultiset) { addMultisetData(result); return result; } - if(isLargeSync) { + else if(isLargeSync) { addLargeData(result); return result; } @@ -81,26 +83,20 @@ class DatasetGenerator { } } -private: - /** - * Adds multiset elements to the clientData, serverData and reconciled + * Adds multiset elements to the testSet Object * This vector contains SERVER_MINUS_CLIENT elements that are only added to the server, followed by CLIENT_MINUS_SERVER * elements that are only on the client. The remaining elements are elements that both the server and client have * @param SIMILAR # of same elems between server and client * @param SERVER_MINUS_CLIENT # of elems on server but not on client * @param CLIENT_MINUS_SERVER # of elems on client but not on server - * @param serverData server data object - * @param clientData client data object - * @return reconciled multiset off all elements added + * @param testSet the Dataset object that is filled */ static void getMultisetElements(const long SIMILAR, const long SERVER_MINUS_CLIENT, const long CLIENT_MINUS_SERVER, - vector> &serverData, - vector> &clientData, multiset &reconciled) { - vector> objectsPtr; + Dataset &testSet) { std::set dataSet; ZZ data = rep(random_ZZ_p()); @@ -111,13 +107,13 @@ class DatasetGenerator { for (int kk = 0; kk < addElemCount; kk++) { //Every 10 elements will have 1 pair and 1 triplet of elements if (kk % 10 == 0 || kk % 10 == 2 || kk % 10 == 3) { - objectsPtr.push_back(make_shared(data)); + testSet.allObjects.push_back(make_shared(data)); } else { //Prevent elements that have already been added from being added again data = randZZ(); //While you fail to add an element to the set (Because it is a duplicate) while (!get<1>(dataSet.insert(data))) data = rep(random_ZZ_p()); - objectsPtr.push_back(make_shared(data)); + testSet.allObjects.push_back(make_shared(data)); } } //Re-randomize the data between the different sections of the vector @@ -132,187 +128,191 @@ class DatasetGenerator { // add data objects unique to the server for (int jj = 0; jj < SERVER_MINUS_CLIENT; jj++) - serverData.push_back(objectsPtr[jj]); + testSet.server.push_back(testSet.allObjects[jj]); // add data objects unique to the client - for (int jj = SERVER_MINUS_CLIENT; jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) - clientData.push_back(objectsPtr[jj]); + for (int jj = SERVER_MINUS_CLIENT; + jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) + testSet.client.push_back(testSet.allObjects[jj]); // add common data objects to both for (int jj = SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER + SIMILAR; jj++) { - clientData.push_back(objectsPtr[jj]); - serverData.push_back(objectsPtr[jj]); + testSet.client.push_back(testSet.allObjects[jj]); + testSet.server.push_back(testSet.allObjects[jj]); } for (int ii = 0; ii < SIMILAR + SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; ii++) { - reconciled.insert(objectsPtr[ii]->print()); + testSet.reconciled.insert(testSet.allObjects[ii]->print()); } } - /** - * Adds elements to the clientData, serverData and reconciled + * Adds elements to the testSet object * This vector contains SERVER_MINUS_CLIENT elements that are only added to the server, followed by CLIENT_MINUS_SERVER * elements that are only on the client. The remaining elements are elements that both the server and client have * @param SIMILAR # of same elems between server and client * @param SERVER_MINUS_CLIENT # of elems on server but not on client * @param CLIENT_MINUS_SERVER # of elems on client but not on server - * @param serverData server data object - * @param clientData client data object - * @return reconciled multiset off all elements added + * @param testSet the Dataset object to be filled */ static void getUniqueElements(const long SIMILAR, const long SERVER_MINUS_CLIENT, const long CLIENT_MINUS_SERVER, - vector> &serverData, - vector> &clientData, multiset &reconciled + Dataset &testSet, const long Rounds = 0, + const long difPerRound = 0 ) { - vector> objectsPtr; +// vector> objectsPtr; std::set dataSet; ZZ data = rep(random_ZZ_p()); //Creates a set of unique elements - for (unsigned long jj = 0; jj < SIMILAR + SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) { - //Checks if elements have already been added before adding them to objectsPtr to ensure that sync is being + for (unsigned long jj = 0; jj < + SIMILAR + SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER + + Rounds * difPerRound; jj++) { + //Checks if elements have already been added before adding them to objectsPtr + // to ensure that sync is being //performed on a set rather than a multiset data = rep(random_ZZ_p()); //While you fail to add an element to the set (Because it is a duplicate) while (!dataSet.insert(data).second) { if (dataSet.size() == pow(2, _eltSize * 8)) { string errorMsg = - "Attempting to add more elements to a set than can be represented by " + toStr(_eltSize) + + "Attempting to add more elements to a set than can be represented by " + + toStr(_eltSize) + " bytes"; Logger::error_and_quit(errorMsg); } data = rep(random_ZZ_p()); } - objectsPtr.push_back(make_shared(data)); - reconciled.insert(objectsPtr[jj]->print()); + testSet.allObjects.push_back(make_shared(data)); + testSet.reconciled.insert(testSet.allObjects[jj]->print()); } // add data objects unique to the server for (int jj = 0; jj < SERVER_MINUS_CLIENT; jj++) - serverData.push_back(objectsPtr[jj]); + testSet.server.push_back(testSet.allObjects[jj]); // add data objects unique to the client - for (int jj = SERVER_MINUS_CLIENT; jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) - clientData.push_back(objectsPtr[jj]); + for (int jj = SERVER_MINUS_CLIENT; + jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj++) + testSet.client.push_back(testSet.allObjects[jj]); // add common data objects to both for (int jj = SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER; jj < SERVER_MINUS_CLIENT + CLIENT_MINUS_SERVER + SIMILAR; jj++) { - clientData.push_back(objectsPtr[jj]); - serverData.push_back(objectsPtr[jj]); + testSet.client.push_back(testSet.allObjects[jj]); + testSet.server.push_back(testSet.allObjects[jj]); } } +private: + // Both A and B are empty sets static void addEmptySets(vector &allDataSet) { vector> res; multiset recon; - allDataSet.push_back(Dataset{res, res, recon, "empty sets"}); + Dataset testData; + testData.desc = "empty sets"; + allDataSet.push_back(testData); } // A is empty, B is not // B is empty, A is not static void addOneEmptySet(vector &allDataSet) { - vector> setA, setB; - multiset reconciled; - const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; + auto CLIENT_MINUS_SERVER = + static_cast (rand() % UCHAR_MAX) + 1; + Dataset testData, testData2; + testData.desc = "server empty set"; - getUniqueElements(0, 0, CLIENT_MINUS_SERVER, setA, setB, reconciled); - allDataSet.push_back(Dataset{setA, setB, reconciled, "server empty set"}); + getUniqueElements(0, 0, CLIENT_MINUS_SERVER, testData); + allDataSet.push_back(testData); - vector> setC, setD; - multiset reconciled2; - getUniqueElements(0, 0, CLIENT_MINUS_SERVER, setC, setD, reconciled2); - allDataSet.push_back(Dataset{setD, setC, reconciled2, "client empty set"}); + testData2.desc = "server empty set"; + getUniqueElements(0, CLIENT_MINUS_SERVER, 0, testData2); + allDataSet.push_back(testData2); } // A is subset B // B is subset A static void addSubsetData(vector &allDataSet) { - vector> subset, superset; - multiset reconciled; - const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + 1; - const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; + Dataset testData; + testData.desc = "subset sets"; + auto SIMILAR = static_cast (rand() % UCHAR_MAX) + 1; + auto CLIENT_MINUS_SERVER = + static_cast (rand() % UCHAR_MAX) + 1; - getUniqueElements(SIMILAR, 0, CLIENT_MINUS_SERVER, subset, superset, reconciled); + getUniqueElements(SIMILAR, 0, CLIENT_MINUS_SERVER, testData); - allDataSet.push_back(Dataset{superset, subset, reconciled, "subset sets"}); + allDataSet.push_back(testData); } // A intersection B is non-empty set but A - B is a huge set // A intersection B is non-empty set but B - A is a huge set static void addBigDiffData(vector &allDataSet) { - vector> setA, setB; - multiset reconciled; + Dataset testData; + testData.desc = "big diff sets"; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SIMILAR = static_cast (rand() % SCHAR_MAX) + 1; // smaller than the two above - getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); - - allDataSet.push_back(Dataset{setA, setB, reconciled, "big diff sets"}); + getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, testData); + allDataSet.push_back(testData); } // A and B have no intersection and both are huge sets static void addHugeDiffData(vector &allDataSet) { - vector> setA, setB; - multiset reconciled; + Dataset testData; + testData.desc = "huge diff sets"; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1 ; const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SIMILAR = 0; - getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); - allDataSet.push_back(Dataset{setA, setB, reconciled, "huge diff sets"}); + getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, testData); + allDataSet.push_back(testData); } // A and B are exactly equal but non-empty static void addEqualData(vector &allDataSet) { - vector> setA, setB; + Dataset testData; + testData.desc = "equal data sets"; const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + UCHAR_MAX; - multiset reconciled; - - getUniqueElements(SIMILAR, 0, 0, setA, setB, reconciled); - allDataSet.push_back(Dataset{setA, setB, reconciled, "equal data sets"}); + getUniqueElements(SIMILAR, 0, 0, testData); + allDataSet.push_back(testData); } // A and B have multiset data static void addMultisetData(vector &allDataSet) { - vector> setA, setB; - multiset reconciled; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % UCHAR_MAX) + 1; const unsigned int SIMILAR = static_cast (rand() % UCHAR_MAX) + 1; - getMultisetElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + Dataset testData; + testData.desc = "multiset data"; + getMultisetElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, testData); - allDataSet.push_back(Dataset{setA, setB, reconciled, "multiset data"}); - allDataSet.push_back(Dataset{setB, setA, reconciled, "multiset data"}); + allDataSet.push_back(testData); } // A and B have large unique data sets static void addLargeData(vector &allDataSet) { - vector> setA, setB; - multiset reconciled; + Dataset testData; + testData.desc = "large data sets"; const unsigned int SIMILAR = static_cast (rand() % _largeLimit) + 1 ; const unsigned int CLIENT_MINUS_SERVER = static_cast (rand() % _largeLimit) + 1 ; const unsigned int SERVER_MINUS_CLIENT = static_cast (rand() % _largeLimit) + 1 ; - getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, setA, setB, reconciled); + getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, testData); - allDataSet.push_back(Dataset{setA, setB, reconciled, "large data sets"}); - allDataSet.push_back(Dataset{setB, setA, reconciled, "large data sets"}); + allDataSet.push_back(testData); } }; diff --git a/tests/TestAuxiliary.h b/tests/TestAuxiliary.h index 39394ed..7574c52 100644 --- a/tests/TestAuxiliary.h +++ b/tests/TestAuxiliary.h @@ -24,10 +24,10 @@ // constants const int NUM_TESTS = 1; // Times to run oneWay and twoWay sync tests -const size_t eltSizeSq = (size_t) pow((double) sizeof(randZZ()), 2.0); // Size^2 of elements stored in sync tests -const size_t eltSize = sizeof(randZZ()); // Size of elements stored in sync tests in bytes -const int mBar = 3 * UCHAR_MAX; // Max differences between client and server in sync tests -const size_t largeLimit = static_cast(pow(2, 9)); // Max number of elements for *each* SIMILAR, CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT in largeSync +const size_t eltSize = DatasetGenerator::_eltSize; +const size_t eltSizeSq = (size_t) pow((double) eltSize, 2.0); // Size^2 of elements stored in sync tests +const int mBar = 2 * UCHAR_MAX; // Max differences between client and server in sync tests +const size_t largeLimit = DatasetGenerator::_largeLimit; const int mBarLarge = largeLimit * 2; // Maximum sum of CLIENT_MINUS_SERVER and SEVER_MINUS_CLIENT const int partitions = 5; //The "arity" of the ptree in InterCPISync if it needs to recurse to complete the sync const string iostr; // Initial string used to construct CommString @@ -904,10 +904,11 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay if(!oneWay) srand(3721); bool success = true; + //If one way, run 1 time, if not run NUM_TESTS times for(int ii = 0 ; ii < (oneWay ? 1 : NUM_TESTS); ii++) { vector dataList = DatasetGenerator::generate(Multiset, largeSync); - for (const auto& testData : dataList) { + for ( auto testData : dataList) { bool thisTestSuccess = true; // add elements to server, client DatasetGenerator::addElements(GenSyncClient, GenSyncServer, testData); @@ -919,6 +920,7 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay // Remove all elements from GenSyncs and clear dynamically allocated memory for reuse thisTestSuccess &= GenSyncServer.clearData(); thisTestSuccess &= GenSyncClient.clearData(); + testData.allObjects.clear(); if (!thisTestSuccess) { Logger::gLog(Logger::TEST, "test fail type: " + testData.desc @@ -927,6 +929,7 @@ inline bool syncTest(GenSync &GenSyncClient, GenSync &GenSyncServer, bool oneWay } success &= thisTestSuccess; + } //Remove all elements from GenSyncs and clear dynamically allocated memory for reuse @@ -946,24 +949,32 @@ inline bool benchmarkSync(GenSync GenSyncClient, GenSync GenSyncServer, int SIMI bool success = true; - multiset reconciled; - auto objectsPtr = addElements(Multiset,SIMILAR,SERVER_MINUS_CLIENT,CLIENT_MINUS_SERVER,GenSyncServer,GenSyncClient,reconciled); +// multiset reconciled; +// auto objectsPtr = addElements(Multiset, SIMILAR, SERVER_MINUS_CLIENT, +// CLIENT_MINUS_SERVER, GenSyncServer, GenSyncClient, +// reconciled); + DatasetGenerator::Dataset testData; + DatasetGenerator::getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, + testData); + DatasetGenerator::addElements(GenSyncClient, GenSyncServer, testData); //Returns a boolean value for the success of the synchronization - success &= syncTestForkHandle(GenSyncClient, GenSyncServer, false, probSync, false, SIMILAR, - CLIENT_MINUS_SERVER,SERVER_MINUS_CLIENT, reconciled,false); + success &= syncTestForkHandle(GenSyncClient, GenSyncServer, false, probSync, false, + SIMILAR, + CLIENT_MINUS_SERVER, SERVER_MINUS_CLIENT, + testData.reconciled, false); //Remove all elements from GenSyncs and clear dynamically allocated memory for reuse success &= GenSyncServer.clearData(); success &= GenSyncClient.clearData(); //Memory is deallocated here because these are shared_ptrs and are deleted when the last ptr to an object is deleted - objectsPtr.clear(); - reconciled.clear(); + testData.allObjects.clear(); + testData.reconciled.clear(); return success; // returns success status of tests } -/** Sync test for IBLT set of sets funciton +/** Sync test for IBLT set of sets function * @param GenSyncClient the client object * @param GenSyncServer the server object * @param numPerSet upper bound for # of elements in a child set @@ -1045,9 +1056,18 @@ inline bool longTermSync(GenSync &GenSyncClient, bool serverReconcileSuccess = true, clientReconcileSuccess = true; long curRound = 0; - multiset reconciled; + DatasetGenerator::Dataset testData; + if (!Multiset) { + DatasetGenerator::getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, + CLIENT_MINUS_SERVER, + testData, Rounds, difPerRound); + } else { + DatasetGenerator::getMultisetElements(SIMILAR, SERVER_MINUS_CLIENT, + CLIENT_MINUS_SERVER, testData); + } - auto objectsPtr = addElements(Multiset,SIMILAR,SERVER_MINUS_CLIENT,CLIENT_MINUS_SERVER,GenSyncServer,GenSyncClient,reconciled,Rounds,difPerRound); + DatasetGenerator::addElements(GenSyncClient, GenSyncServer, testData); + multiset reconciled = testData.reconciled; const long refillIndex = reconciled.size(); @@ -1074,8 +1094,8 @@ inline bool longTermSync(GenSync &GenSyncClient, for (int ii = 0; ii < difPerRound; ii++) { - GenSyncServer.addElem(objectsPtr[refillIndex + (curRound - 1) * difPerRound + ii]); - reconciled.insert(objectsPtr[refillIndex + (curRound - 1) * difPerRound + ii]->print()); + GenSyncServer.addElem(testData.allObjects[refillIndex + (curRound - 1) * difPerRound + ii]); + reconciled.insert(testData.allObjects[refillIndex + (curRound - 1) * difPerRound + ii]->print()); } // waiting for start signal from server side @@ -1149,8 +1169,8 @@ inline bool longTermSync(GenSync &GenSyncClient, // add more elements to client for (int ii = 0; ii < difPerRound; ii++) { - GenSyncClient.addElem(objectsPtr[refillIndex + (curRound - 1) * difPerRound + ii]); - reconciled.insert(objectsPtr[refillIndex + (curRound - 1) * difPerRound + ii]->print()); + GenSyncClient.addElem(testData.allObjects[refillIndex + (curRound - 1) * difPerRound + ii]); + reconciled.insert(testData.allObjects[refillIndex + (curRound - 1) * difPerRound + ii]->print()); } } @@ -1227,7 +1247,7 @@ inline bool longTermSync(GenSync &GenSyncClient, { // clear dynamically allocated memory for reuse serverReconcileSuccess &= GenSyncServer.clearData() && GenSyncClient.clearData(); - objectsPtr.clear(); + testData.allObjects.clear(); return serverReconcileSuccess; } From 91c9524d094424fc1aaf9663aa4916c7674ef90d Mon Sep 17 00:00:00 2001 From: Shubham Arora Date: Mon, 3 Aug 2020 09:03:54 -0400 Subject: [PATCH 8/8] - remove unnecessary comments --- tests/TestAuxiliary.h | 8 -------- tests/unit/CuckooSyncTest.cpp | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/TestAuxiliary.h b/tests/TestAuxiliary.h index 7574c52..1b13e1d 100644 --- a/tests/TestAuxiliary.h +++ b/tests/TestAuxiliary.h @@ -519,9 +519,6 @@ inline bool createForkForTest(GenSync& GenSyncClient, GenSync& GenSyncServer,boo clientReport); Logger::gLog(Logger::COMM, "waiting for test fork to finish, pid: " + toStr(getpid())); bool isSyncSuccess = isClientSuccess && bool(child_state); -// Logger::gLog(Logger::TEST, -// "client, status: " + toStr(clientReport.success) + ", check success: " + toStr(isClientSuccess) + -// ", syncSuccess: " + toStr(isSyncSuccess) ); return isSyncSuccess; } @@ -948,11 +945,6 @@ inline bool benchmarkSync(GenSync GenSyncClient, GenSync GenSyncServer, int SIMI int SERVER_MINUS_CLIENT, bool probSync, bool Multiset){ bool success = true; - -// multiset reconciled; -// auto objectsPtr = addElements(Multiset, SIMILAR, SERVER_MINUS_CLIENT, -// CLIENT_MINUS_SERVER, GenSyncServer, GenSyncClient, -// reconciled); DatasetGenerator::Dataset testData; DatasetGenerator::getUniqueElements(SIMILAR, SERVER_MINUS_CLIENT, CLIENT_MINUS_SERVER, testData); diff --git a/tests/unit/CuckooSyncTest.cpp b/tests/unit/CuckooSyncTest.cpp index fc6c87c..eb19baf 100644 --- a/tests/unit/CuckooSyncTest.cpp +++ b/tests/unit/CuckooSyncTest.cpp @@ -27,7 +27,7 @@ void CuckooSyncTest::setReconcileTest() { const size_t bits = sizeof(randZZ()); const size_t fngprtSize = 12; const size_t bucketSize = 4; - const size_t filterSize = 512 * (UCHAR_MAX + 1); // UCHAR_MAX is taken from syncTest + const size_t filterSize = 512 * (UCHAR_MAX + 1); const size_t maxKicks = 500; GenSync server = GenSync::Builder()