added dsmdebug file for debugging using macros and setting flags in buildscript
authoradash <adash>
Sun, 3 Aug 2008 19:43:58 +0000 (19:43 +0000)
committeradash <adash>
Sun, 3 Aug 2008 19:43:58 +0000 (19:43 +0000)
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)

Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/DSTM/interface/addUdpEnhance.c
Robust/src/Runtime/DSTM/interface/clookup.c
Robust/src/Runtime/DSTM/interface/clookup.h
Robust/src/Runtime/DSTM/interface/dstm.h
Robust/src/Runtime/DSTM/interface/dstmserver.c
Robust/src/Runtime/DSTM/interface/signal.c
Robust/src/Runtime/DSTM/interface/trans.c
Robust/src/buildscript

index 50795313ed29bd34784c5678e88af71b796b6a48..8781ff4e3ca832db40545acb02f3d86ce2a20c59 100644 (file)
@@ -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");
index 79d08be5284ebc4716bba78c501706c0872ad82d..d5b886213f6467d9e8c6d1c492fd14bd42b79916 100644 (file)
@@ -5,6 +5,7 @@
 #include <math.h>
 #include <netinet/tcp.h>
 #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
index b7b9c97796da1dd23972b003e6392b49af434408..4d8340716f3c08118ef3ec59bc3272ea21ee18e4 100644 (file)
@@ -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];
   
index eb7f53f76512286b46615863b5ab132ca56c9a01..475a66f00fc473b2965d810fbfbfa96fce44da59 100644 (file)
@@ -4,8 +4,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#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);
index 11927ab1f8d7028f62cc8e739e21a58286572562..2fbf05f60dffb7207bb95f4e404c7eb6010cbd16 100644 (file)
@@ -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 <signal.h>
 #include "plookup.h"
+#include "dsmdebug.h"
 
 //bit designations for status field of objheader
 #define DIRTY 0x01
index 4a35c19f3b4fc749304415b59b4905dc0b8023fc..0928321c310245151796b6cbe686c879d8c0a515 100644 (file)
@@ -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
             }
           }
         }
index dae52b8d55fbd1521b9fcb783990bab61d8545be..942c83203794a645e1284a743347e8c9cc45771d 100644 (file)
@@ -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; i<numprefetchsites; i++) {
     printf("siteid = %d,  callCount = %d\n", i, evalPrefetch[i].callcount);
   }
+  */
   exit(0);
 #endif
 }
index 639ac7875060f9e55e5b78d2a9e03c2ddeb5493b..b5527c2be573efd1ca69930b98d0e58a5fc1e57d 100644 (file)
@@ -1,6 +1,5 @@
 #include "dstm.h"
 #include "ip.h"
-#include "clookup.h"
 #include "machinepile.h"
 #include "mlookup.h"
 #include "llookup.h"
@@ -50,6 +49,10 @@ pthread_mutex_t atomicObjLock;
  **********************************/
 int numTransCommit = 0;
 int numTransAbort = 0;
+int nchashSearch = 0;
+int nmhashSearch = 0;
+int nprehashSearch = 0;
+int nRemoteSend = 0;
 
 void printhex(unsigned char *, int);
 plistnode_t *createPiles(transrecord_t *);
@@ -299,7 +302,7 @@ transrecord_t *transStart() {
     return NULL;
   }
   tmp->cache = 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)
        {
index e5a01ecc20ca64aea549bbf93d3633db99c2463c..a9bea668513c68dc57fbc592535380601d3f2ff7 100755 (executable)
@@ -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"