__thread threadrec_t *trec;
__thread struct objlist * lockedobjs;
__thread int t_objnumcount=0;
-/** Global lock **/
-int typesCausingAbort[TOTALNUMCLASSANDARRAY];
+
+/* Collect stats for object classes causing abort */
+objtypestat_t typesCausingAbort[TOTALNUMCLASSANDARRAY];
/******Keep track of objects and types causing aborts******/
/* TODO uncomment for later use
#define DEBUGSTMSTAT(args...) { \
fflush(stdout); \
}
*/
+
+/**
+ * Inline fuction to get Transaction size per object type for those
+ * objects that cause
+ *
+ **/
+INLINE void getTransSize(objheader_t *header , int *isObjTypeTraverse) {
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ if(isObjTypeTraverse[TYPE(header)] != 1)
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ isObjTypeTraverse[TYPE(header)]=1;
+}
#define DEBUGSTMSTAT(args...)
#else
#define DEBUGSTMSTAT(args...)
* Increments the abort count for each object
**/
void ABORTCOUNT(objheader_t * x) {
- if (x->abortCount > MAXABORTS && (x->riskyflag != 1)) {
+ float transAbortProb = (PERCENT_ALLOWED_ABORT*FACTOR)/(float)typesCausingAbort[TYPE(x)].numaccess;
+ float ObjAbortProb = x->abortCount/(float) (x->accessCount);
+ DEBUGSTM("ABORTSTATS: oid= %x, transAbortProb= %3.2f, ObjAbortProb= %3.2f, numaccess= %3d, type= %2d, abortCount= %3d, accessCount= %3d\n", OID(x), transAbortProb, ObjAbortProb, typesCausingAbort[TYPE(x)].numaccess, TYPE(x), x->abortCount, x->accessCount);
+ /* Condition for locking objects */
+ if ((ObjAbortProb > transAbortProb) && (x->riskyflag != 1)) {
//makes riskflag sticky
pthread_mutex_lock(&lockedobjstore);
if (objlockscope->offset<MAXOBJLIST) {
int * oidrdage;
int * oidrdversion;
allocarrays;
+ int objtypetraverse[TOTALNUMCLASSANDARRAY];
int ObjSeqId;
+ for(i=0; i<TOTALNUMCLASSANDARRAY; i++)
+ objtypetraverse[i] = 0;
+
chashlistnode_t *ptr = c_table;
/* Represents number of bins in the chash table */
unsigned int size = c_size;
#ifdef STMSTATS
header->abortCount++;
ObjSeqId = headeraddr->accessCount;
- (typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
+ getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse);
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
}
transAbortProcess(oidwrlocked, numoidwrlocked);
#ifdef STMSTATS
- ObjSeqId = headeraddr->accessCount;
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
+ ObjSeqId = headeraddr->accessCount;
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
+ //(typesCausingAbort[TYPE(header)])++;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
+ if(getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse))
softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = headeraddr->accessCount;
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
+ if(getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse))
softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = oidrdage[i];
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = oidrdage[i];
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = oidrdage[i];
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
+ if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse))
softabort=0;
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
void ** oidwrlocked;
allocarrays;
int ObjSeqId;
+ int objtypetraverse[TOTALNUMCLASSANDARRAY];
+ for(i=0; i<TOTALNUMCLASSANDARRAY; i++)
+ objtypetraverse[i] = 0;
chashlistnode_t *curr = c_list;
/* Inner loop to traverse the linked list of the cache lookupTable */
while(likely(curr != NULL)) {
#ifdef STMSTATS
header->abortCount++;
ObjSeqId = headeraddr->accessCount;
- (typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
+ getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse);
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
#ifdef STMSTATS
header->abortCount++;
ObjSeqId = headeraddr->accessCount;
- (typesCausingAbort[TYPE(header)])++;
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
+ if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse))
softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
#ifdef STMSTATS
header->abortCount++;
ObjSeqId = headeraddr->accessCount;
- (typesCausingAbort[TYPE(header)])++;
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
+ if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse))
softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = oidrdage[i];
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = oidrdage[i];
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
- getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId);
+ getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse);
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
#ifdef STMSTATS
ObjSeqId = oidrdage[i];
header->abortCount++;
- (typesCausingAbort[TYPE(header)])++;
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ objtypetraverse[TYPE(header)]=1;
#endif
#if defined(STMSTATS)||defined(SOFTABORT)
- if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId))
+ if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse))
softabort=0;
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
* =========================================================================================
**/
int getTotalAbortCount(int start, int stop, void *startptr, int numoidrdlocked,
- void *oidrdlocked, int *oidrdversion, int *oidrdage, int ObjSeqId) {
+ void *oidrdlocked, int *oidrdversion, int *oidrdage, int ObjSeqId, objheader_t *header, int *isObjTypeTraverse) {
int i;
int hardabort=0;
int isFirstTime=0;
- objheader_t *ObjToBeLocked=NULL;
+ objheader_t *ObjToBeLocked=header;
chashlistnode_t *curr = (chashlistnode_t *) startptr;
chashlistnode_t *ptr = c_table;
/* First go through all objects left in the cache that have not been covered yet */
ObjSeqId = headeraddr->accessCount;
ObjToBeLocked = header;
}
- (typesCausingAbort[TYPE(header)])++;
+ getTransSize(header, isObjTypeTraverse);
#endif
hardabort=1;
}
ObjSeqId = OidAge;
ObjToBeLocked = header;
}
- (typesCausingAbort[TYPE(header)])++;
+ getTransSize(header, isObjTypeTraverse);
#endif
hardabort=1;
}
}
/* Acquire lock on the oldest object accessed in the transaction cache */
- if(ObjToBeLocked != NULL)
+ if(ObjToBeLocked != NULL) {
ABORTCOUNT(ObjToBeLocked);
+ }
return hardabort;
}
* =========================================================================================
**/
int getTotalAbortCount2(void *startptr, int numoidrdlocked, void *oidrdlocked,
- int *oidrdversion, int *oidrdage, int ObjSeqId) {
+ int *oidrdversion, int *oidrdage, int ObjSeqId, objheader_t *header, int *isObjTypeTraverse) {
int hardabort=0;
chashlistnode_t *curr = (chashlistnode_t *) startptr;
- objheader_t *ObjToBeLocked=NULL;
+ objheader_t *ObjToBeLocked=header;
/* Inner loop to traverse the linked list of the cache lookupTable */
while(curr != NULL) {
ObjSeqId = headeraddr->accessCount;
ObjToBeLocked = header;
}
- (typesCausingAbort[TYPE(header)])++;
+ getTransSize(header, isObjTypeTraverse);
#endif
hardabort=1;
}
ObjSeqId = OidAge;
ObjToBeLocked = header;
}
- (typesCausingAbort[TYPE(header)])++;
+ getTransSize(header, isObjTypeTraverse);
#endif
hardabort=1;
}
}
}
- if(ObjToBeLocked!=NULL)
+ if(ObjToBeLocked!=NULL) {
ABORTCOUNT(ObjToBeLocked);
+ }
return hardabort;
}
* : oidrdage : array of ages of objects read ina transaction cache
* : ObjSeqId : sequence Id/age to start the comparision with
**/
-int getReadAbortCount(int start, int stop, void *oidrdlocked, int *oidrdversion, int *oidrdage, int ObjSeqId) {
+int getReadAbortCount(int start, int stop, void *oidrdlocked, int *oidrdversion,
+ int *oidrdage, int ObjSeqId, objheader_t *header, int *isObjTypeTraverse) {
int i;
int hardabort=0;
- objheader_t *ObjToBeLocked=NULL;
+ objheader_t *ObjToBeLocked=header;
/* Go through oids read that are locked */
for(i = start; i < stop; i++) {
ObjSeqId = OidAge;
ObjToBeLocked = header;
}
- (typesCausingAbort[TYPE(header)])++;
+ getTransSize(header, isObjTypeTraverse);
#endif
hardabort=1;
}
}
- if(ObjToBeLocked != NULL)
+ if(ObjToBeLocked != NULL) {
ABORTCOUNT(ObjToBeLocked);
+ }
return hardabort;
}
return header;
}
+/**
+ * Inline fuction to get Transaction size per object type for those
+ * objects that cause
+ *
+ **/
+/*
+INLINE void getTransSize(objheader_t *header , int *isObjTypeTraverse) {
+ (typesCausingAbort[TYPE(header)]).numabort++;
+ if(isObjTypeTraverse[TYPE(header)] != 1)
+ (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements;
+ isObjTypeTraverse[TYPE(header)]=1;
+}
+*/
+
#endif