Changeset: e866800e3df2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e866800e3df2
Modified Files:
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_runtime.c
monetdb5/modules/mal/clients.c
Branch: default
Log Message:
Make the profiler thread safe by setting locks around client inprogress[]
diffs (74 lines):
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -555,10 +555,12 @@ openProfilerStream(stream *fd, int mode)
if( (mode & PROFSHOWRUNNING) > 0){
for (i = 0; i < MAL_MAXCLIENTS; i++) {
c = mal_clients+i;
+ MT_lock_set(&mal_delayLock);
for(j = 0; j <THREADS; j++)
if( c->inprogress[j].mb)
/* show the event */
profilerEvent(c->inprogress[j].mb,
c->inprogress[j].stk, c->inprogress[j].pci, 1, c->username);
+ MT_lock_unset(&mal_delayLock);
}
}
return MAL_SUCCEED;
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -171,9 +171,11 @@ runtimeProfileBegin(Client cntxt, MalBlk
assert(pci);
/* keep track on the instructions taken in progress for stethoscope*/
if( tid < THREADS){
+ MT_lock_set(&mal_delayLock);
cntxt->inprogress[tid].mb = mb;
cntxt->inprogress[tid].stk = stk;
cntxt->inprogress[tid].pci = pci;
+ MT_lock_unset(&mal_delayLock);
}
/* always collect the MAL instruction execution time */
@@ -192,9 +194,11 @@ runtimeProfileExit(Client cntxt, MalBlkP
/* keep track on the instructions in progress*/
if ( tid < THREADS) {
+ MT_lock_set(&mal_delayLock);
cntxt->inprogress[tid].mb = 0;
- cntxt->inprogress[tid].stk =0;
+ cntxt->inprogress[tid].stk = 0;
cntxt->inprogress[tid].pci = 0;
+ MT_lock_unset(&mal_delayLock);
}
/* always collect the MAL instruction execution time */
diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c
--- a/monetdb5/modules/mal/clients.c
+++ b/monetdb5/modules/mal/clients.c
@@ -624,6 +624,7 @@ CLTsessions(Client cntxt, MalBlkPtr mb,
timestamp ret;
lng timeout;
str msg = NULL;
+ int i, cnt;
(void) cntxt;
(void) mb;
@@ -670,8 +671,16 @@ CLTsessions(Client cntxt, MalBlkPtr mb,
if (BUNappend(last, &ret, false) != GDK_SUCCEED)
goto bailout;
timeout = c->qtimeout / 1000000;
- if (BUNappend(qtimeout, &timeout, false) != GDK_SUCCEED ||
- BUNappend(active, &c->active, false) != GDK_SUCCEED)
+ if (BUNappend(qtimeout, &timeout, false) != GDK_SUCCEED)
+ goto bailout;
+ MT_lock_set(&mal_delayLock);
+ for( i = 0; i < THREADS; i++)
+ if ( c->inprogress[i].mb){
+ cnt ++;
+ break;
+ }
+ MT_lock_unset(&mal_delayLock);
+ if( BUNappend(active, &cnt, false) != GDK_SUCCEED)
goto bailout;
}
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list