Changeset: 0f8047151c43 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0f8047151c43
Modified Files:
        monetdb5/mal/mal.h
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_resource.c
        monetdb5/modules/mal/sysmon.c
Branch: default
Log Message:

Removed atomic types for 'workers' and 'memory' components of MalStack


diffs (105 lines):

diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -271,8 +271,8 @@ typedef struct MALSTK {
        char status;                    /* srunning 'R' suspended 'S', quiting 
'Q' */
        int pcup;                               /* saved pc upon a recursive 
all */
        oid tag;                                /* unique invocation call tag */
-       ATOMIC_TYPE     workers;        /* Actual number of concurrent workers 
*/
-       ATOMIC_TYPE     memory;         /* Actual memory claim highwater mark */
+       int     workers;                        /* Actual number of concurrent 
workers */
+       lng     memory;                         /* Actual memory claim 
highwater mark */
 
        struct MALSTK *up;              /* stack trace list */
        struct MALBLK *blk;             /* associated definition */
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -264,8 +264,8 @@ prepareMALstack(MalBlkPtr mb, int size)
        //stk->stksize = size;
        stk->stktop = mb->vtop;
        stk->blk = mb;
-       ATOMIC_SET(&stk->workers, 0);
-       ATOMIC_SET(&stk->memory, 0);
+       stk->workers = 0;
+       stk->memory = 0;
        initStack(0, res);
        if(!res) {
                freeStack(stk);
diff --git a/monetdb5/mal/mal_resource.c b/monetdb5/mal/mal_resource.c
--- a/monetdb5/mal/mal_resource.c
+++ b/monetdb5/mal/mal_resource.c
@@ -128,7 +128,7 @@ MALadmission(Client cntxt, MalBlkPtr mb,
         * A way out is to attach the thread count to the MAL stacks instead, 
which just limits the level
         * of parallism for a single dataflow graph.
         */
-       workers = (int) ATOMIC_GET(&stk->workers);
+       workers = stk->workers;
        if( cntxt->workerlimit && cntxt->workerlimit <= workers){
                PARDEBUG
                        fprintf(stderr, "#DFLOWadmit worker limit reached, %d 
<= %d\n", cntxt->workerlimit, workers);
@@ -154,24 +154,23 @@ MALadmission(Client cntxt, MalBlkPtr mb,
                        /* If we are low on memory resources, limit the user if 
he exceeds his memory budget 
                         * but make sure there is at least one thread active */
                        if ( cntxt->memorylimit) {
-                               lng stack_memory = (lng) 
ATOMIC_GET(&stk->memory);
-                               mbytes = (lng) cntxt->memorylimit * 1024 * 1024;
-                               if (argclaim + stack_memory > mbytes){
+                               mbytes = (lng) cntxt->memorylimit * 
LL_CONSTANT(1048576);
+                               if (argclaim + stk->memory > mbytes){
                                        MT_lock_unset(&admissionLock);
                                        PARDEBUG
                                                fprintf(stderr, "#Delayed due 
to lack of session memory " LLFMT " requested "LLFMT"\n", 
-                                                               stack_memory, 
argclaim);
+                                                               stk->memory, 
argclaim);
                                        return -1;
                                }
                        }
                        memorypool -= argclaim;
-                       (void) ATOMIC_ADD(&stk->memory, argclaim);
+                       stk->memory += argclaim;
                        memoryclaims++;
                        PARDEBUG
                                fprintf(stderr, "#DFLOWadmit %3d thread %d pool 
" LLFMT "claims " LLFMT "\n",
                                                 memoryclaims, THRgettid(), 
memorypool, argclaim);
+                       stk->workers++;
                        MT_lock_unset(&admissionLock);
-                       (void) ATOMIC_INC(&stk->workers);
                        return 0;
                }
                PARDEBUG
@@ -183,15 +182,14 @@ MALadmission(Client cntxt, MalBlkPtr mb,
        
        /* return the session budget */
        if (cntxt->memorylimit) {
-               lng stack_memory = (lng) ATOMIC_GET(&stk->memory);
                PARDEBUG
-                       fprintf(stderr, "#Return memory to session budget " 
LLFMT "\n", stack_memory);
-               (void) ATOMIC_SUB(&stk->memory, argclaim);
+                       fprintf(stderr, "#Return memory to session budget " 
LLFMT "\n", stk->memory);
+               stk->memory -= argclaim;
        }
        /* release memory claimed before */
        memorypool -= argclaim;
        memoryclaims--;
-       (void) ATOMIC_DEC(&stk->workers);
+       stk->workers--;
 
        PARDEBUG
                fprintf(stderr, "#DFLOWadmit %3d thread %d pool " LLFMT " 
claims " LLFMT "\n",
diff --git a/monetdb5/modules/mal/sysmon.c b/monetdb5/modules/mal/sysmon.c
--- a/monetdb5/modules/mal/sysmon.c
+++ b/monetdb5/modules/mal/sysmon.c
@@ -91,9 +91,9 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb, 
                }
                if (BUNappend(started, &tsn, false) != GDK_SUCCEED)
                        goto bailout;
-               
-               wrk = (int) ATOMIC_GET(&QRYqueue[i].stk->workers);
-               mem = (int) ATOMIC_GET(&QRYqueue[i].stk->memory); /* TODO it 
should cast to lng */
+
+               wrk = QRYqueue[i].stk->workers;
+               mem = (int) (QRYqueue[i].stk->memory / LL_CONSTANT(1048576)); 
/* Convert to MB */
                if (BUNappend(progress, &QRYqueue[i].progress, false) != 
GDK_SUCCEED ||
                    BUNappend(workers, &wrk, false) != GDK_SUCCEED ||
                        BUNappend(memory, &mem, false) != GDK_SUCCEED)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to