From: adash Date: Sun, 3 Aug 2008 19:43:58 +0000 (+0000) Subject: added dsmdebug file for debugging using macros and setting flags in buildscript X-Git-Tag: preEdgeChange~40 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0cd3ede99c77a4dc6629eac9be275777c644e387;p=IRC.git added dsmdebug file for debugging using macros and setting flags in buildscript added code to verify number of reads in transaction cache, main object store etc compile error fix for clookup.h(static makes chashSearch local to file) --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 50795313..8781ff4e 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -270,6 +270,10 @@ public class BuildCode { outmethod.println("printf(\"****** Transaction Stats ******\\n\");"); outmethod.println("printf(\"numTransAbort= %d\\n\", numTransAbort);"); outmethod.println("printf(\"numTransCommit= %d\\n\", numTransCommit);"); + outmethod.println("printf(\"nchashSearch= %d\\n\", nchashSearch);"); + outmethod.println("printf(\"nmhashSearch= %d\\n\", nmhashSearch);"); + outmethod.println("printf(\"nprehashSearch= %d\\n\", nprehashSearch);"); + outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);"); outmethod.println("#endif\n"); outmethod.println("}"); @@ -727,6 +731,10 @@ public class BuildCode { outclassdefs.print("#ifdef TRANSSTATS \n"); outclassdefs.print("extern int numTransAbort;\n"); outclassdefs.print("extern int numTransCommit;\n"); + outclassdefs.print("extern int nchashSearch;\n"); + outclassdefs.print("extern int nmhashSearch;\n"); + outclassdefs.print("extern int nprehashSearch;\n"); + outclassdefs.print("extern int nRemoteSend;\n"); outclassdefs.print("extern void handle();\n"); outclassdefs.print("#endif\n"); outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n"); diff --git a/Robust/src/Runtime/DSTM/interface/addUdpEnhance.c b/Robust/src/Runtime/DSTM/interface/addUdpEnhance.c index 79d08be5..d5b88621 100644 --- a/Robust/src/Runtime/DSTM/interface/addUdpEnhance.c +++ b/Robust/src/Runtime/DSTM/interface/addUdpEnhance.c @@ -5,6 +5,7 @@ #include #include #include "addUdpEnhance.h" +#include "prelookup.h" /************************ * Global Variables * @@ -148,11 +149,11 @@ int sendUdpMsg(thread_data_array_t *tdata, struct sockaddr_in *clientaddr, int i *((short *)&writeBuffer[0]) = INVALIDATE_OBJS; //control msg offset += sizeof(short); if(iteration == 0) { // iteration flag == zero, send single udp msg - *((short *) (writeBuffer+offset)) = (short) (sizeof(unsigned int) * (tdata->buffer->f.nummod)); + *((short *) (writeBuffer+offset)) = (short) (sizeof(unsigned int) * (tdata->buffer->f.nummod)); //sizeof msg offset += sizeof(short); int i; for(i = 0; i < tdata->buffer->f.nummod; i++) { - *((unsigned int *) (writeBuffer+offset)) = tdata->buffer->oidmod[i]; + *((unsigned int *) (writeBuffer+offset)) = tdata->buffer->oidmod[i]; //copy objects offset += sizeof(unsigned int); } } else { // iteration flag > zero, send multiple udp msg diff --git a/Robust/src/Runtime/DSTM/interface/clookup.c b/Robust/src/Runtime/DSTM/interface/clookup.c index b7b9c977..4d834071 100644 --- a/Robust/src/Runtime/DSTM/interface/clookup.c +++ b/Robust/src/Runtime/DSTM/interface/clookup.c @@ -1,4 +1,4 @@ - #include "clookup.h" +#include "clookup.h" #define INLINE inline __attribute__((always_inline)) chashtable_t *chashCreate(unsigned int size, float loadfactor) { @@ -67,7 +67,7 @@ unsigned int chashInsert(chashtable_t *table, unsigned int key, void *val) { } // Search for an address for a given oid -static INLINE void * chashSearch(chashtable_t *table, unsigned int key) { +INLINE void * chashSearch(chashtable_t *table, unsigned int key) { //REMOVE HASH FUNCTION CALL TO MAKE SURE IT IS INLINED HERE chashlistnode_t *node = &table->table[(key & table->mask)>>1]; diff --git a/Robust/src/Runtime/DSTM/interface/clookup.h b/Robust/src/Runtime/DSTM/interface/clookup.h index eb7f53f7..475a66f0 100644 --- a/Robust/src/Runtime/DSTM/interface/clookup.h +++ b/Robust/src/Runtime/DSTM/interface/clookup.h @@ -4,8 +4,8 @@ #include #include -#define LOADFACTOR 0.25 -#define HASH_SIZE 1024 +#define CLOADFACTOR 0.25 +#define CHASH_SIZE 1024 typedef struct chashlistnode { unsigned int key; @@ -25,7 +25,7 @@ typedef struct chashtable { chashtable_t *chashCreate(unsigned int size, float loadfactor); static unsigned int chashFunction(chashtable_t *table, unsigned int key); unsigned int chashInsert(chashtable_t *table, unsigned int key, void *val); -static void *chashSearch(chashtable_t *table, unsigned int key); //returns val, NULL if not found +void *chashSearch(chashtable_t *table, unsigned int key); //returns val, NULL if not found unsigned int chashRemove(chashtable_t *table, unsigned int key); //returns -1 if not found unsigned int chashResize(chashtable_t *table, unsigned int newsize); void chashDelete(chashtable_t *table); diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index 11927ab1..2fbf05f6 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -49,9 +49,6 @@ //Max number of objects #define MAX_OBJECTS 20 -//Max remote-machine connections -#define NUM_MACHINES 2 -#define LOADFACTOR 0.5 #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB //Transaction id per machine #define TID_LEN 20 @@ -83,6 +80,7 @@ #include "sockpool.h" #include #include "plookup.h" +#include "dsmdebug.h" //bit designations for status field of objheader #define DIRTY 0x01 diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index 4a35c19f..0928321c 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -469,6 +469,12 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne numBytes += size; /* Send TRANS_DISAGREE to Coordinator */ control = TRANS_DISAGREE; +#ifdef CHECKTA + char b[] = "version mismatch"; + char c[] = "object type"; + TABORT3(__func__, b, c, TYPE(mobj)); +#endif + } } else {/* If Obj is not locked then lock object */ /* Save all object oids that are locked on this machine during this transaction request call */ @@ -485,6 +491,12 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne size += sizeof(objheader_t); numBytes += size; control = TRANS_DISAGREE; + +#ifdef CHECKTA + char b[] = "version mismatch"; + char c[] = "object type"; + TABORT3(__func__, b, c, TYPE(mobj)); +#endif } } } diff --git a/Robust/src/Runtime/DSTM/interface/signal.c b/Robust/src/Runtime/DSTM/interface/signal.c index dae52b8d..942c8320 100644 --- a/Robust/src/Runtime/DSTM/interface/signal.c +++ b/Robust/src/Runtime/DSTM/interface/signal.c @@ -4,6 +4,10 @@ extern int numTransAbort; extern int numTransCommit; +extern int nchashSearch; +extern int nmhashSearch; +extern int nprehashSearch; +extern int nRemoteSend; extern int numprefetchsites; void handle(); extern pfcstats_t *evalPrefetch; @@ -13,10 +17,17 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) { printf("****** Transaction Stats ******\n"); printf("numTransAbort = %d\n", numTransAbort); printf("numTransCommit = %d\n", numTransCommit); + printf("nchashSearch = %d\n", nchashSearch); + printf("nmhashSearch = %d\n", nmhashSearch); + printf("nprehashSearch = %d\n", nprehashSearch); + printf("nRemoteReadSend = %d\n", nRemoteSend); int i; + //TODO Remove later + /* for(i=0; icache = objstrCreate(1048576); - tmp->lookupTable = chashCreate(HASH_SIZE, LOADFACTOR); + tmp->lookupTable = chashCreate(CHASH_SIZE, CLOADFACTOR); #ifdef COMPILER tmp->revertlist=NULL; #endif @@ -319,7 +322,10 @@ objheader_t *transRead(transrecord_t *record, unsigned int oid) { return NULL; } - if((objheader = (objheader_t *)chashSearch(record->lookupTable, oid)) != NULL){ + if((objheader = chashSearch(record->lookupTable, oid)) != NULL){ +#ifdef TRANSSTATS + nchashSearch++; +#endif /* Search local transaction cache */ #ifdef COMPILER return &objheader[1]; @@ -327,6 +333,9 @@ objheader_t *transRead(transrecord_t *record, unsigned int oid) { return objheader; #endif } else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) { +#ifdef TRANSSTATS + nmhashSearch++; +#endif /* Look up in machine lookup table and copy into cache*/ GETSIZE(size, objheader); size += sizeof(objheader_t); @@ -341,6 +350,9 @@ objheader_t *transRead(transrecord_t *record, unsigned int oid) { return objcopy; #endif } else if((tmp = (objheader_t *) prehashSearch(oid)) != NULL) { +#ifdef TRANSSTATS + nprehashSearch++; +#endif /* Look up in prefetch cache */ GETSIZE(size, tmp); size+=sizeof(objheader_t); @@ -365,6 +377,9 @@ objheader_t *transRead(transrecord_t *record, unsigned int oid) { printf("Error: Object not found in Remote location %s, %d\n", __FILE__, __LINE__); return NULL; } else { +#ifdef TRANSSTATS + nRemoteSend++; +#endif STATUS(objcopy)=0; #ifdef COMPILER return &objcopy[1]; @@ -410,7 +425,7 @@ plistnode_t *createPiles(transrecord_t *record) { if(curr->key == 0) break; - if ((headeraddr = chashSearch(record->lookupTable, curr->key)) == NULL) { + if ((headeraddr = (objheader_t *) chashSearch(record->lookupTable, curr->key)) == NULL) { printf("Error: No such oid %s, %d\n", __FILE__, __LINE__); return NULL; } @@ -604,6 +619,10 @@ int transCommit(transrecord_t *record) { if(treplyctrl == TRANS_ABORT) { #ifdef TRANSSTATS numTransAbort++; +#endif +#ifdef CHECKTB + char a[] = "Aborting"; + TABORT1(a); #endif /* Free Resources */ objstrDelete(record->cache); @@ -615,6 +634,10 @@ int transCommit(transrecord_t *record) { } else if(treplyctrl == TRANS_COMMIT) { #ifdef TRANSSTATS numTransCommit++; +#endif +#ifdef CHECKTB + char a[] = "Commiting"; + TABORT1(a); #endif /* Free Resources */ objstrDelete(record->cache); @@ -649,10 +672,10 @@ void *transRequest(void *threadarg) { printf("transRequest(): socket create error\n"); pthread_exit(NULL); } - + /* Send bytes of data with TRANS_REQUEST control message */ send_data(sd, &(tdata->buffer->f), sizeof(fixed_data_t)); - + /* Send list of machines involved in the transaction */ { int size=sizeof(unsigned int)*tdata->buffer->f.mcount; @@ -694,6 +717,10 @@ void *transRequest(void *threadarg) { objheader_t * header; header = (objheader_t *) (((char *)newAddr) + offset); oidToPrefetch = OID(header); +#ifdef CHECKTA + char a[] = "object type"; + TABORT8(__func__, a, TYPE(header)); +#endif int size = 0; GETSIZE(size, header); size += sizeof(objheader_t); @@ -709,7 +736,13 @@ void *transRequest(void *threadarg) { offset += size; } } + recvcontrol = control; +#ifdef CHECKTA + char a[] = "mid"; + char c[] = "status"; + TABORT5(__func__, a, c, tdata->mid, control); +#endif /* Update common data structure and increment count */ tdata->recvmsg[tdata->thread_id].rcv_status = recvcontrol; @@ -727,7 +760,18 @@ void *transRequest(void *threadarg) { pthread_cond_wait(tdata->threshold, tdata->lock); } pthread_mutex_unlock(tdata->lock); + + /* Invalidate objects in other machine cache */ + if(*(tdata->replyctrl) == TRANS_COMMIT) { + if(tdata->buffer->f.nummod > 0) { + if((retval = invalidateObj(tdata)) != 0) { + printf("Error: %s() in invalidating Objects %s, %d\n", __func__, __FILE__, __LINE__); + return; + } + } + } + /* Send the final response such as TRANS_COMMIT or TRANS_ABORT * to all participants in their respective socket */ if (sendResponse(tdata, sd) == 0) { @@ -744,6 +788,7 @@ void *transRequest(void *threadarg) { } else { //printf("DEBUG-> Error: Incorrect Transaction End Message %d\n", control); } + pthread_exit(NULL); } @@ -786,18 +831,11 @@ void decideResponse(thread_data_array_t *tdata) { *(tdata->replyctrl) = TRANS_COMMIT; *(tdata->replyretry) = 0; int retval; + /* Update prefetch cache */ if((retval = updatePrefetchCache(tdata)) != 0) { printf("Error: %s() in updating prefetch cache %s, %d\n", __func__, __FILE__, __LINE__); return; } - - /* Invalidate objects in other machine cache */ - if(tdata->buffer->f.nummod > 0) { - if((retval = invalidateObj(tdata)) != 0) { - printf("Error: %s() in invalidating Objects %s, %d\n", __func__, __FILE__, __LINE__); - return; - } - } } else { /* Send Abort in soft abort case followed by retry commiting transaction again*/ *(tdata->replyctrl) = TRANS_ABORT; @@ -929,6 +967,13 @@ void *handleLocalReq(void *threadarg) { v_nomatch++; /* Send TRANS_DISAGREE to Coordinator */ localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_DISAGREE; +#ifdef CHECKTA + char a[] = "mid"; + char b[] = "version mismatch"; + char c[] = "object type"; + TABORT7(__func__, b, a, c, localtdata->tdata->mid, TYPE(mobj)); +#endif + break; } } else { //we're locked @@ -941,6 +986,13 @@ void *handleLocalReq(void *threadarg) { v_nomatch++; /* Send TRANS_DISAGREE to Coordinator */ localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_DISAGREE; +#ifdef CHECKTA + char a[] = "mid"; + char b[] = "version mismatch"; + char c[] = "object type"; + TABORT7(__func__, b, a, c, localtdata->tdata->mid, TYPE(mobj)); +#endif + break; } } } @@ -951,6 +1003,12 @@ void *handleLocalReq(void *threadarg) { } /* Condition to send TRANS_SOFT_ABORT */ if((v_matchlock > 0 && v_nomatch == 0) || (numoidnotfound > 0 && v_nomatch == 0)) { +#ifdef CHECKTA + char a[] = "mid"; + char b[] = "version mismatch"; + char c[] = "object type"; + TABORT7(__func__, b, a, c, localtdata->tdata->mid, TYPE(mobj)); +#endif localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_SOFT_ABORT; } @@ -1435,6 +1493,10 @@ int processConfigFile() #else myIpAddr = getMyIpAddr("eth0"); #endif + +#ifdef CHECKTA + printf("My ip address = %x", myIpAddr); +#endif myIndexInHostArray = findHost(myIpAddr); if (myIndexInHostArray == -1) { diff --git a/Robust/src/buildscript b/Robust/src/buildscript index e5a01ecc..a9bea668 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -190,7 +190,8 @@ RAWDEBUGFLAG=true EXTRAOPTIONS="$EXTRAOPTIONS -g" elif [[ $1 = '-runtimedebug' ]] then -EXTRAOPTIONS="$EXTRAOPTIONS -DDEBUG" +#EXTRAOPTIONS="$EXTRAOPTIONS -DDEBUG" +EXTRAOPTIONS="$EXTRAOPTIONS -DCHECKTB" elif [[ $1 = '-nooptimize' ]] then EXTRAOPTIONS="$EXTRAOPTIONS -O0"