add sandbox checks for excessive memory allocation and make all exponential
authoradash <adash>
Wed, 10 Feb 2010 02:22:03 +0000 (02:22 +0000)
committeradash <adash>
Wed, 10 Feb 2010 02:22:03 +0000 (02:22 +0000)
delay variables as thread locals

Robust/src/Runtime/DSTM/interface/dstm.h
Robust/src/Runtime/DSTM/interface/sandbox.c
Robust/src/Runtime/DSTM/interface/sandbox.h
Robust/src/Runtime/DSTM/interface/trans.c

index b9791968ebd96592bea10cc13eae73600d8ef6f7..b7913809e3cf8bffa1e557faadc7b355ca3d6f13 100644 (file)
@@ -59,6 +59,8 @@
 //#define SHUTDOWNINTERVAL  3 //M
 #define RETRYINTERVAL 100  //N  (For MatrixMultiply, 2DFFT, 2DConv benchmarks)
 #define SHUTDOWNINTERVAL 1 //M
+#define NUM_TRY_TO_COMMIT 2
+#define MEM_ALLOC_THRESHOLD 20485760//20MB
 
 #include <stdlib.h>
 #include <stdio.h>
index e42ca4acd876764b738300c857fdf33a33c47321..29e1bbd657d4ea344ed0410e92924d32e0befcb2 100644 (file)
@@ -255,6 +255,7 @@ int verify(nodeElem_t *pile) {
   return -1;
 }
 
+/* Check looping */
 void checkObjects() {
   if (abortenabled&&checktrans()) {
     printf("Loop Abort\n");
@@ -269,6 +270,22 @@ void checkObjects() {
   transaction_check_counter=*counter_reset_pointer;
 }
 
+/* Check excessive memory allocation */
+void check_mem_alloc() {
+  if (abortenabled&&checktrans()) {
+    printf("Excessive Allocation\n");
+    trans_allocation_bytes=0;
+    transaction_check_counter=(*counter_reset_pointer=HIGH_CHECK_FREQUENCY);
+#ifdef TRANSSTATS
+    numTransAbort++;
+#endif
+    objstrDelete(t_cache);
+    t_chashDelete();
+    _longjmp(aborttrans, 1);
+  }
+  trans_allocation_bytes=0;
+}
+
 /* Obtain a backtrace and print it to stdout */
 void print_trace() {
   void *array[100];
index d2f5fd6b8b7305361f92d87ba8f0c51f5ee2e0e4..21ff07d08d73fadba34254190d47d4be659a805f 100644 (file)
@@ -16,7 +16,7 @@ extern __thread jmp_buf aborttrans;
 extern __thread int abortenabled;
 extern __thread int* counter_reset_pointer;
 extern __thread int transaction_check_counter;
-
+extern __thread int trans_allocation_bytes;
 
 /* Global Variables */
 #define CHECK_OBJECTS   51
index 1eeca47fb4c32257481433bb97eedbb2a66aa42d..430c12b5d4b712294dce70dcd87a7df41c039e9f 100644 (file)
@@ -58,9 +58,14 @@ int bigindex1=0;
 #endif
 
 /* Thread transaction variables */
-
 __thread objstr_t *t_cache;
 __thread struct ___Object___ *revertlist;
+__thread struct timespec exponential_backoff;
+__thread int count_exponential_backoff;
+__thread const int max_exponential_backoff = 1000; // safety limit
+__thread int trans_allocation_bytes;
+
+
 #ifdef ABORTREADERS
 __thread int t_abort;
 __thread jmp_buf aborttrans;
@@ -92,10 +97,6 @@ sockPoolHashTable_t *transPrefetchSockPool;
 sockPoolHashTable_t *transRequestSockPool;
 pthread_mutex_t notifymutex;
 pthread_mutex_t atomicObjLock;
-struct timespec exponential_backoff;
-static int count_exponential_backoff = 0;
-static const int max_exponential_backoff = 1000; // safety limit
-
 
 /***********************************
  * Global Variables for statistics
@@ -553,6 +554,7 @@ void transStart() {
   t_cache = objstrCreate(1048576);
   t_chashCreate(CHASH_SIZE, CLOADFACTOR);
   revertlist=NULL;
+  trans_allocation_bytes = 0;
 #ifdef ABORTREADERS
   t_abort=0;
 #endif
@@ -837,6 +839,11 @@ objheader_t *transCreateObj(unsigned int size) {
   tmp->rcount = 1;
   STATUS(tmp) = NEW;
   t_chashInsert(OID(tmp), tmp);
+  trans_allocation_bytes += size;
+  /* Validate the read set if allocation is exceeds threshold */
+  if(trans_allocation_bytes > MEM_ALLOC_THRESHOLD) {
+    check_mem_alloc();
+  }
 
 #ifdef COMPILER
   return &tmp[1]; //want space after object header
@@ -958,8 +965,10 @@ int transCommit() {
 
 
   int treplyretryCount = 0;
+  /* Initialize timeout for exponential delay */
   exponential_backoff.tv_sec = 0;
   exponential_backoff.tv_nsec = (long)(10000);//10 microsec
+  count_exponential_backoff = 0;
   do {
     treplyretry = 0;
 
@@ -1188,10 +1197,8 @@ int transCommit() {
     /* Retry trans commit procedure during soft_abort case */
   } while (treplyretry);
 
-  /* Reset to initial timeout for exponential delay */
   exponential_backoff.tv_sec = 0;
   exponential_backoff.tv_nsec = (long)(10000);//10 microsec_
-  count_exponential_backoff = 0;
 
   if(finalResponse == TRANS_ABORT) {
 #ifdef TRANSSTATS