int updatePrefetchCache(trans_req_data_t *tdata) {
int retval;
char oidType;
+ /*//TODO comment it for now because objects read are already in the prefetch cache
oidType = 'R';
if(tdata->f.numread > 0) {
if((retval = copyToCache(tdata->f.numread, (unsigned int *)(tdata->objread), oidType)) != 0) {
return -1;
}
}
+ */
if(tdata->f.nummod > 0) {
oidType = 'M';
if((retval = copyToCache(tdata->f.nummod, tdata->oidmod, oidType)) != 0) {
int i;
for (i = 0; i < numoid; i++) {
unsigned int oid;
- if(oidType == 'R') {
- char * objread = (char *) oidarray;
- oid = *((unsigned int *)(objread+(sizeof(unsigned int)+
- sizeof(unsigned short))*i));
- } else {
+ //if(oidType == 'R') {
+ // char * objread = (char *) oidarray;
+ // oid = *((unsigned int *)(objread+(sizeof(unsigned int)+
+ // sizeof(unsigned short))*i));
+ //} else {
oid = oidarray[i];
- }
+ //}
pthread_mutex_lock(&prefetchcache_mutex);
objheader_t * header;
if((header = (objheader_t *) t_chashSearch(oid)) == NULL) {
void handle();
extern pfcstats_t *evalPrefetch;
-/*
void transStatsHandler(int sig, siginfo_t* info, void *context) {
#ifdef TRANSSTATS
FILE *fp;
fprintf(fp, "bytesSent = %d\n", bytesSent);
fprintf(fp, "bytesRecv = %d\n", bytesRecv);
fprintf(fp, "totalObjSize= %d\n", totalObjSize);
+ fprintf(fp, "sendRemoteReq= %d\n", sendRemoteReq);
+ fprintf(fp, "getResponse= %d\n", getResponse);
fprintf(fp, "**********************************\n");
fflush(fp);
fclose(fp);
exit(0);
#endif
}
-*/
+/*
void transStatsHandler(int sig, siginfo_t* info, void *context) {
#ifdef TRANSSTATS
printf("****** Transaction Stats ******\n");
exit(0);
#endif
}
+*/
void handle() {
#ifdef TRANSSTATS
nRemoteSend++;
#endif
#ifdef COMPILER
+#ifdef CACHE
+ //Copy object to prefetch cache
+ pthread_mutex_lock(&prefetchcache_mutex);
+ objheader_t *headerObj;
+ int size;
+ GETSIZE(size, objcopy);
+ if((headerObj = prefetchobjstrAlloc(size + sizeof(objheader_t))) == NULL) {
+ printf("%s(): Error in getting memory from prefetch cache at %s, %d\n", __func__,
+ __FILE__, __LINE__);
+ pthread_mutex_unlock(&prefetchcache_mutex);
+ return NULL;
+ }
+ pthread_mutex_unlock(&prefetchcache_mutex);
+ memcpy(headerObj, objcopy, size+sizeof(objheader_t));
+ //make an entry in prefetch lookup hashtable
+ void *oldptr;
+ if((oldptr = prehashSearch(oid)) != NULL) {
+ prehashRemove(oid);
+ prehashInsert(oid, headerObj);
+ } else {
+ prehashInsert(oid, headerObj);
+ }
+#endif
return &objcopy[1];
#else
return objcopy;
nRemoteSend++;
#endif
#ifdef COMPILER
+#ifdef CACHE
+ //Copy object to prefetch cache
+ pthread_mutex_lock(&prefetchcache_mutex);
+ objheader_t *headerObj;
+ int size;
+ GETSIZE(size, objcopy);
+ if((headerObj = prefetchobjstrAlloc(size + sizeof(objheader_t))) == NULL) {
+ printf("%s(): Error in getting memory from prefetch cache at %s, %d\n", __func__,
+ __FILE__, __LINE__);
+ pthread_mutex_unlock(&prefetchcache_mutex);
+ return NULL;
+ }
+ pthread_mutex_unlock(&prefetchcache_mutex);
+ memcpy(headerObj, objcopy, size+sizeof(objheader_t));
+ //make an entry in prefetch lookup hashtable
+ void *oldptr;
+ if((oldptr = prehashSearch(oid)) != NULL) {
+ prehashRemove(oid);
+ prehashInsert(oid, headerObj);
+ } else {
+ prehashInsert(oid, headerObj);
+ }
+#endif
+
return &objcopy[1];
#else
return objcopy;