From 923afbb53c16c314ecb01e45f3f278212908dcca Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 9 Feb 2010 20:14:52 +0000 Subject: [PATCH] binary exponential backoff for soft abort --- Robust/src/Runtime/DSTM/interface/trans.c | 30 +++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index d233b2df..1eeca47f 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -87,12 +87,15 @@ int myIndexInHostArray; unsigned int oidsPerBlock; unsigned int oidMin; unsigned int oidMax; - sockPoolHashTable_t *transReadSockPool; 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 @@ -534,6 +537,17 @@ void randomdelay() { return; } +void exponentialdelay() { + exponential_backoff.tv_nsec = exponential_backoff.tv_nsec * 2; + nanosleep(&exponential_backoff, NULL); + ++count_exponential_backoff; + if (count_exponential_backoff >= max_exponential_backoff) { + printf(" reached max_exponential_backoff at %s, %s(), %d\n", __FILE__, __func__, __LINE__); + exit(-1); + } + return; +} + /* This function initializes things required in the transaction start*/ void transStart() { t_cache = objstrCreate(1048576); @@ -943,6 +957,9 @@ int transCommit() { #endif + int treplyretryCount = 0; + exponential_backoff.tv_sec = 0; + exponential_backoff.tv_nsec = (long)(10000);//10 microsec do { treplyretry = 0; @@ -1159,7 +1176,11 @@ int transCommit() { pDelete(pile_ptr); /* wait a random amount of time before retrying to commit transaction*/ if(treplyretry) { - randomdelay(); + treplyretryCount++; + if(treplyretryCount >= NUM_TRY_TO_COMMIT) + exponentialdelay(); + else + randomdelay(); #ifdef TRANSSTATS nSoftAbort++; #endif @@ -1167,6 +1188,11 @@ 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 LOGEVENT('A'); -- 2.34.1