change cache lookup table,
authoradash <adash>
Fri, 5 Mar 2010 10:10:11 +0000 (10:10 +0000)
committeradash <adash>
Fri, 5 Mar 2010 10:10:11 +0000 (10:10 +0000)
remove rcount-> instead use isBackUp field for alignment issues,
add code for signal handler,
some code changes to address cache invalidation-> same as dsm

Robust/src/Runtime/DSTM/interface_recovery/addPrefetchEnhance.c
Robust/src/Runtime/DSTM/interface_recovery/clookup.c
Robust/src/Runtime/DSTM/interface_recovery/dstm.h
Robust/src/Runtime/DSTM/interface_recovery/signal.c

index ca7c845a0dec9c2235e665ef0e3a52cf58e5673b..f0436e0a76b2828c6ccc0389f3b0fa2319e211e6 100644 (file)
@@ -107,13 +107,15 @@ void cleanPCache() {
 int updatePrefetchCache(trans_req_data_t *tdata) {
   int retval;
   char oidType;
-  oidType = 'R';
-  if(tdata->f.numread > 0) {
-    if((retval = copyToCache(tdata->f.numread, (unsigned int *)(tdata->objread), oidType)) != 0) {
-      printf("%s(): Error in copying objects read at %s, %d\n", __func__, __FILE__, __LINE__);
-      return -1;
-    }
-  }
+  /* TODO commit it for now because objects read
+   * are already copied to cache during remote reading */
+  //oidType = 'R';
+  //if(tdata->f.numread > 0) {
+  //  if((retval = copyToCache(tdata->f.numread, (unsigned int *)(tdata->objread), oidType)) != 0) {
+  //    printf("%s(): Error in copying objects read at %s, %d\n", __func__, __FILE__, __LINE__);
+  //    return -1;
+  //  }
+  //}
   if(tdata->f.nummod > 0) {
     oidType = 'M';
     if((retval = copyToCache(tdata->f.nummod, tdata->oidmod, oidType)) != 0) {
index d2ec50a9dd5c4efc807cc33cc1afc54a1e67b87e..5ce813e1202c0e9748a08dda419dd3b766f08167 100644 (file)
@@ -1,11 +1,19 @@
 #include "clookup.h"
 
+#define NUMCLIST 250
+typedef struct clist {
+  struct chashlistnode array[NUMCLIST];
+  int num;
+  struct clist *next;
+} cliststruct_t;
+
 __thread chashlistnode_t *c_table;
 __thread unsigned int c_size;
 __thread unsigned int c_mask;
 __thread unsigned int c_numelements;
 __thread unsigned int c_threshold;
 __thread double c_loadfactor;
+__thread cliststruct_t *c_structs;
 
 void t_chashCreate(unsigned int size, double loadfactor) {
   chashtable_t *ctable;
@@ -20,6 +28,7 @@ void t_chashCreate(unsigned int size, double loadfactor) {
   c_size = size;
   c_threshold=size*loadfactor;
   c_mask = (size << 1)-1;
+  c_structs=calloc(1,sizeof(cliststruct_t));
   c_numelements = 0; // Initial number of elements in the hash
 }
 
@@ -101,7 +110,6 @@ INLINE void * chashSearch(chashtable_t *table, unsigned int key) {
 void t_chashInsert(unsigned int key, void *val) {
   chashlistnode_t *ptr;
 
-
   if(c_numelements > (c_threshold)) {
     //Resize
     unsigned int newsize = c_size << 1;
@@ -115,7 +123,18 @@ void t_chashInsert(unsigned int key, void *val) {
     ptr->key=key;
     ptr->val=val;
   } else { // Insert in the beginning of linked list
-    chashlistnode_t * node = calloc(1, sizeof(chashlistnode_t));
+    chashlistnode_t * node;
+    if (c_structs->num<NUMCLIST) {
+      node=&c_structs->array[c_structs->num];
+      c_structs->num++;
+    } else {
+      //get new list                                                                
+      cliststruct_t *tcl=calloc(1,sizeof(cliststruct_t));
+      tcl->next=c_structs;
+      c_structs=tcl;
+      node=&tcl->array[0];
+      tcl->num=1;
+    }
     node->key = key;
     node->val = val;
     node->next = ptr->next;
@@ -273,16 +292,13 @@ unsigned int t_chashResize(unsigned int newsize) {
       if ((key=curr->key) == 0) {             //Exit inner loop if there the first element is 0
        break;                  //key = val =0 for element if not present within the hash table
       }
-      next = curr->next;
       index = (key & mask) >>1;
       tmp=&node[index];
+      next = curr->next;
       // Insert into the new table
       if(tmp->key == 0) {
-       tmp->key = curr->key;
+       tmp->key = key;
        tmp->val = curr->val;
-       if (!isfirst) {
-         free(curr);
-       }
       }/*
         NOTE:  Add this case if you change this...
         This case currently never happens because of the way things rehash....
@@ -326,17 +342,13 @@ void chashDelete(chashtable_t *ctable) {
 
 //Delete the entire hash table
 void t_chashDelete() {
-  int i;
-  chashlistnode_t *ptr = c_table;
-
-  for(i=0 ; i<c_size ; i++) {
-    chashlistnode_t * curr = ptr[i].next;
-    while(curr!=NULL) {
-      chashlistnode_t * next = curr->next;
-      free(curr);
-      curr=next;
-    }
+  cliststruct_t *ptr=c_structs;
+  while(ptr!=NULL) {
+    cliststruct_t *next=ptr->next;
+    free(ptr);
+    ptr=next;
   }
-  free(ptr);
+  free(c_table);
   c_table=NULL;
+  c_structs=NULL;
 }
index 1583232d7851369a4ac02f9ea988caabe22af8e7..dc0965a1249a8a7667561826c5976a29d90b91e7 100644 (file)
 #include <signal.h>
 #include "plookup.h"
 #include "dsmdebug.h"
+#include "readstruct.h"
 #ifdef ABORTREADERS
 #include <setjmp.h>
 #endif
@@ -133,8 +134,8 @@ int transCount;                  /* TODO Remove, necessary to the transaction id
 typedef struct objheader {
   threadlist_t *notifylist;
   unsigned short version;
-  unsigned short rcount;
-  char isBackup;
+  //unsigned short rcount;
+  short isBackup;
 } objheader_t;
 
 #define OID(x) \
index 79917fd87bb9d2185d76b63177dbe2013935c2d1..35046d57a16da1ba94fcc77d58045fb7156a537e 100644 (file)
@@ -8,6 +8,7 @@ extern int numTransCommit;
 extern int nchashSearch;
 extern int nmhashSearch;
 extern int nprehashSearch;
+extern int ndirtyCacheObj;
 extern int nRemoteSend;
 extern int nSoftAbort;
 extern int bytesSent;
@@ -34,6 +35,7 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) {
   fprintf(fp, "nchashSearch = %d\n", nchashSearch);
   fprintf(fp, "nmhashSearch = %d\n", nmhashSearch);
   fprintf(fp, "nprehashSearch = %d\n", nprehashSearch);
+  fprintf(fp, "ndirtyCacheObj = %d\n", ndirtyCacheObj);
   fprintf(fp, "nRemoteReadSend = %d\n", nRemoteSend);
   fprintf(fp, "nSoftAbort = %d\n", nSoftAbort);
   fprintf(fp, "bytesSent = %d\n", bytesSent);
@@ -48,10 +50,6 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) {
 */
 
 void transStatsHandler(int sig, siginfo_t* info, void *context) {
-#ifdef RECOVERYSTATS
-  fflush(stdout);
-#endif
-
 #ifdef TRANSSTATS
   printf("******  Transaction Stats   ******\n");
   printf("myIpAddr = %x\n", myIpAddr);
@@ -60,6 +58,7 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) {
   printf("nchashSearch = %d\n", nchashSearch);
   printf("nmhashSearch = %d\n", nmhashSearch);
   printf("nprehashSearch = %d\n", nprehashSearch);
+  printf("ndirtyCacheObj = %d\n", ndirtyCacheObj);
   printf("nRemoteReadSend = %d\n", nRemoteSend);
   printf("nSoftAbort = %d\n", nSoftAbort);
   printf("bytesSent = %d\n", bytesSent);
@@ -68,12 +67,18 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) {
   printf("sendRemoteReq= %d\n", sendRemoteReq);
   printf("getResponse= %d\n", getResponse);
   printf("**********************************\n");
+  fflush(stdout);
+  exit(0);
+#endif
+
+#ifdef RECOVERYSTATS
+  fflush(stdout);
   exit(0);
 #endif
 }
 
 void handle() {
-#ifdef TRANSSTATS
+#if defined(TRANSSTATS) || defined(RECOVERYSTATS)
   struct sigaction siga;
   siga.sa_handler = NULL;
   siga.sa_flags = SA_SIGINFO;