From: jihoonl Date: Thu, 18 Feb 2010 02:14:35 +0000 (+0000) Subject: to print out byte info X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ae997e327cbab07e2d37a55df979a601ecf0f9bc;p=IRC.git to print out byte info --- diff --git a/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.c b/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.c index d982ed91..95cb6484 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.c @@ -242,7 +242,7 @@ unsigned int *mhashGetKeys(unsigned int *numKeys) { }*/ #ifdef RECOVERY -void* mhashGetDuplicate(int *dupeSize, int backup) { //how big? +void* mhashGetDuplicate(unsigned int *dupeSize, int backup) { //how big? #ifdef DEBUG printf("%s-> Start\n", __func__); #endif diff --git a/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.h b/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.h index ee566865..34984bdc 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.h +++ b/Robust/src/Runtime/DSTM/interface_recovery/altmlookup.h @@ -1,5 +1,5 @@ -#ifndef _MLOOKUP_H_ -#define _MLOOKUP_H_ +#ifndef _ALTMLOOKUP_H_ +#define _ALTMLOOKUP_H_ #include #include @@ -49,6 +49,6 @@ void mhashPrint(); #endif #ifdef RECOVERY -void* mhashGetDuplicate(int* dupeSize,int backup); +void* mhashGetDuplicate(unsigned int* dupeSize,int backup); //int mhashGetThreadObjects(unsigned int** oidArray,unsigned int** midArray,unsigned int** threadidArray); #endif diff --git a/Robust/src/Runtime/DSTM/interface_recovery/dstm.h b/Robust/src/Runtime/DSTM/interface_recovery/dstm.h index 5a1e4a1f..5f4eb9d2 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/dstm.h +++ b/Robust/src/Runtime/DSTM/interface_recovery/dstm.h @@ -234,7 +234,16 @@ typedef struct trans_commit_data { pthread_mutex_t liveHosts_mutex; #endif - +#ifdef RECOVERYSTATS +/************************************** + * Structure for Recovery stats + **************************************/ +typedef struct recoverystat { + unsigned int deadMachine; + long long elapsedTime; + unsigned int recoveredData; +} recovery_stat_t; +#endif #define PRINT_TID(PTR) printf("DEBUG -> %x %d\n", PTR->mid, PTR->thread_id); @@ -280,8 +289,8 @@ void clearDeadThreadsNotification(); void reqClearNotifyList(unsigned int oid); void clearNotifyList(unsigned int oid); void duplicateLostObjects(unsigned int mid); -void duplicateLocalBackupObjects(); -void duplicateLocalOriginalObjects(); +unsigned int duplicateLocalBackupObjects(); +unsigned int duplicateLocalOriginalObjects(); void restoreDuplicationState(unsigned int deadHost); int readDuplicateObjs(int); void printRecoveryStat(); diff --git a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c index 2daa08e3..811888cd 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c @@ -288,7 +288,8 @@ void *dstmAccept(void *acceptfd) { int timeout; #endif - int i, tempsize; + int i; + unsigned int tempsize; objheader_t *h; trans_commit_data_t transinfo; unsigned short objType, *versionarry, version; @@ -632,6 +633,7 @@ void *dstmAccept(void *acceptfd) { ctrl = DUPLICATION_COMPLETE; send_data((int)acceptfd, &ctrl, sizeof(char)); + send_data((int)acceptfd, &tempsize, sizeof(unsigned int)); #ifdef DEBUG printf("%s (DUPLICATE_ORIGINAL)-> Finished\n", __func__); #endif @@ -690,6 +692,7 @@ void *dstmAccept(void *acceptfd) { ctrl = DUPLICATION_COMPLETE; send_data((int)acceptfd, &ctrl, sizeof(char)); + send_data((int)acceptfd, &tempsize, sizeof(unsigned int)); #ifdef DEBUG printf("%s (DUPLICATE_BACKUP)-> Finished\n", __func__); #endif diff --git a/Robust/src/Runtime/DSTM/interface_recovery/mlookup.h b/Robust/src/Runtime/DSTM/interface_recovery/mlookup.h index 80034f5c..21f8e35d 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/mlookup.h +++ b/Robust/src/Runtime/DSTM/interface_recovery/mlookup.h @@ -38,7 +38,7 @@ unsigned int mhashResize(unsigned int newsize); unsigned int *mhashGetKeys(unsigned int *numKeys); #ifdef RECOVERY -void* mhashGetDuplicate(int* dupeSize,int backup); +void* mhashGetDuplicate(unsigned int* dupeSize,int backup); int mhashGetThreadObjects(unsigned int** oidArray,unsigned int** midArray,unsigned int** threadidArray); #endif diff --git a/Robust/src/Runtime/DSTM/interface_recovery/trans.c b/Robust/src/Runtime/DSTM/interface_recovery/trans.c index ad2c1b08..fc52fbda 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/trans.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/trans.c @@ -26,6 +26,8 @@ #include #include "tlookup.h" +//#define CPU_FREQ 2992440 + #define CPU_FREQ 3056842 #endif @@ -115,12 +117,8 @@ unsigned int temp_v_a; int paxosRound; #ifdef RECOVERYSTATS -/************************************** - * Global variables for Recovery stats - **************************************/ -int numRecovery=0; -unsigned int deadMachine[8] ={ 0,0,0,0,0,0,0,0}; -long long elapsedTime[8] = {0,0,0,0,0,0,0,0}; + int numRecovery = 0; + recovery_stat_t* recoverStat; #endif #endif @@ -2246,6 +2244,15 @@ int processConfigFile() { myIndexInHostArray = findHost(myIpAddr); #ifdef RECOVERY liveHosts[myIndexInHostArray] = 1; + +#ifdef RECOVERYSTATS + numRecovery = 0; + if((recoverStat = (recovery_stat_t*) calloc(numHostsInSystem, sizeof(recovery_stat_t))) == NULL) { + printf("%s -> Calloc error!\n",__func__); + exit(0); + } +#endif + #endif if (myIndexInHostArray == -1) { printf("error in %s: IP Address of eth0 not found\n", CONFIG_FILENAME); @@ -2525,9 +2532,10 @@ void duplicateLostObjects(unsigned int mid){ numRecovery++; long long st; long long fi; + unsigned int dupeSize = 0; // to calculate the size of backed up data st = myrdtsc(); // to get clock - deadMachine[numRecovery-1] = mid; + recoverStat[numRecovery-1].deadMachine = mid; #endif #ifndef DEBUG @@ -2563,8 +2571,10 @@ void duplicateLostObjects(unsigned int mid){ * Backup 26 21,24 */ + dupeSize = 0; + if(originalMid == myIpAddr) { // copy local machine's backup data, make it as primary data of backup machine. - duplicateLocalOriginalObjects(backupMid); + dupeSize += duplicateLocalOriginalObjects(backupMid); // size of primary data } else if((sd = getSockWithLock(transPrefetchSockPool, originalMid)) < 0) { printf("%s -> socket create error, attempt %d\n", __func__,j); @@ -2581,7 +2591,13 @@ void duplicateLostObjects(unsigned int mid){ send_data(sd, &backupMid, sizeof(unsigned int)); char response; + unsigned int receivedSize; recv_data(sd, &response, sizeof(char)); + recv_data(sd, &receivedSize, sizeof(unsigned int)); + + dupeSize += receivedSize; // size of primary data + + #ifdef DEBUG printf("%s (DUPLICATE_ORIGINAL) -> Received %s\n", __func__,(response==DUPLICATION_COMPLETE)?"DUPLICATION_COMPLETE":"DUPLICATION_FAIL"); #endif @@ -2590,7 +2606,7 @@ void duplicateLostObjects(unsigned int mid){ } if(backupMid == myIpAddr) { // copy local machine's primary data, and make it as backup data of original machine. - duplicateLocalBackupObjects(originalMid); + dupeSize += duplicateLocalBackupObjects(originalMid); // size of backup data } else if((sd = getSockWithLock(transPrefetchSockPool, backupMid)) < 0) { printf("updateLiveHosts(): socket create error, attempt %d\n", j); @@ -2606,7 +2622,12 @@ void duplicateLostObjects(unsigned int mid){ send_data(sd, &originalMid, sizeof(unsigned int)); char response; + unsigned int receivedSize; recv_data(sd, &response, sizeof(char)); + recv_data(sd, &receivedSize, sizeof(unsigned int)); + + dupeSize += receivedSize; // size of backup data + #ifdef DEBUG printf("%s (DUPLICATE_BACKUP) -> Received %s\n", __func__,(response==DUPLICATION_COMPLETE)?"DUPLICATION_COMPLETE":"DUPLICATION_FAIL"); #endif @@ -2616,7 +2637,9 @@ void duplicateLostObjects(unsigned int mid){ #ifdef RECOVERYSTATS fi = myrdtsc(); - elapsedTime[numRecovery-1] = (fi-st)/CPU_FREQ; + recoverStat[numRecovery-1].elapsedTime = (fi-st)/CPU_FREQ; + recoverStat[numRecovery-1].recoveredData = dupeSize; + printRecoveryStat(); #endif @@ -2625,8 +2648,9 @@ void duplicateLostObjects(unsigned int mid){ #endif } -void duplicateLocalBackupObjects(unsigned int mid) { - int tempsize, sd; +unsigned int duplicateLocalBackupObjects(unsigned int mid) { + int sd; + unsigned int tempsize; int i; char *dupeptr, ctrl, response; #ifdef DEBUG @@ -2670,10 +2694,13 @@ void duplicateLocalBackupObjects(unsigned int mid) { printf("%s-> End\n", __func__); #endif + return tempsize; + } -void duplicateLocalOriginalObjects(unsigned int mid) { - int tempsize, sd; +unsigned int duplicateLocalOriginalObjects(unsigned int mid) { + int sd; + unsigned int tempsize; char *dupeptr, ctrl, response; #ifdef DEBUG @@ -2717,6 +2744,7 @@ void duplicateLocalOriginalObjects(unsigned int mid) { #ifdef DEBUG printf("%s-> End\n", __func__); #endif + return tempsize; } @@ -3468,12 +3496,13 @@ int checkiftheMachineDead(unsigned int mid) { #ifdef RECOVERYSTATS void printRecoveryStat() { - printf("***** Recovery Stats *****\n"); + printf("\n***** Recovery Stats *****\n"); printf("numRecovery = %d\n",numRecovery); int i; for(i=0; i < numRecovery;i++) { - printf("Dead Machine = %s\n",midtoIPString(deadMachine[i])); - printf("Recovery Time = %ld\n",elapsedTime[i]); + printf("Dead Machine = %s\n",midtoIPString(recoverStat[i].deadMachine)); + printf("Recoveryed data(byte) = %u\n",recoverStat[i].recoveredData); + printf("Recovery Time(us) = %ld\n",recoverStat[i].elapsedTime); } printf("**************************\n\n"); }