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

Compilation fixes


diffs (137 lines):

diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -266,16 +266,16 @@ typedef struct MALSTK {
  * It is handy to administer the timing in the stack frame
  * for use in profiling instructions.
  */
-       struct timeval clock;   /* time this stack was created */
-       char cmd;               /* debugger and runtime communication */
-       char status;            /* srunning 'R' suspended 'S', quiting 'Q' */
-       int pcup;               /* saved pc upon a recursive all */
-       oid tag;                /* unique invocation call tag */
-       int     workers;                        /* Actual number of concurrent 
workers */
-       lng     memory;                         /* Actual memory claim 
highwater mark */
+       struct timeval clock;   /* time this stack was created */
+       char cmd;                               /* debugger and runtime 
communication */
+       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 */
 
-       struct MALSTK *up;      /* stack trace list */
-       struct MALBLK *blk;     /* associated definition */
+       struct MALSTK *up;              /* stack trace list */
+       struct MALBLK *blk;             /* associated definition */
        ValRecord stk[FLEXIBLE_ARRAY_MEMBER];
 } MalStack, *MalStkPtr;
 
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
@@ -12,7 +12,7 @@
 #include "mal_resource.h"
 #include "mal_private.h"
 
-/* MEMORY admission does not seem to have a major impact sofar. */
+/* MEMORY admission does not seem to have a major impact so far. */
 static lng memorypool = 0;      /* memory claimed by concurrent threads */
 static int memoryclaims = 0;
 
@@ -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 = stk->workers;
+       workers = (int) ATOMIC_GET(&stk->workers);
        if( cntxt->workerlimit && cntxt->workerlimit <= workers){
                PARDEBUG
                        fprintf(stderr, "#DFLOWadmit worker limit reached, %d 
<= %d\n", cntxt->workerlimit, workers);
@@ -145,7 +145,7 @@ MALadmission(Client cntxt, MalBlkPtr mb,
        if ( memorypool <= 0 && memoryclaims == 0){
                PARDEBUG
                        fprintf(stderr, "#DFLOWadmit memorypool reset ");
-               memorypool = (lng)(MEMORY_THRESHOLD );
+               memorypool = (lng) MEMORY_THRESHOLD;
        }
 
        /* the argument claim is based on the input for an instruction */
@@ -153,46 +153,48 @@ MALadmission(Client cntxt, MalBlkPtr mb,
                if ( memoryclaims == 0 || memorypool > argclaim ) {
                        /* 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){
-                               mbytes = ((lng) cntxt->memorylimit) * 1024 * 
1024;
-                               if (argclaim + stk->memory > mbytes){
+                       if ( cntxt->memorylimit) {
+                               lng stack_memory = (lng) 
ATOMIC_GET(&stk->memory);
+                               mbytes = (lng) cntxt->memorylimit * 1024 * 1024;
+                               if (argclaim + stack_memory > mbytes){
                                        MT_lock_unset(&admissionLock);
                                        PARDEBUG
-                                       fprintf(stderr, "#Delayed due to lack 
of session memory " LLFMT " requested "LLFMT"\n", 
-                                               stk->memory, argclaim);
+                                               fprintf(stderr, "#Delayed due 
to lack of session memory " LLFMT " requested "LLFMT"\n", 
+                                                               stack_memory, 
argclaim);
                                        return -1;
                                }
                        }
-                       memorypool -= (lng) (argclaim);
-                       stk->memory += argclaim;
+                       memorypool -= argclaim;
+                       (void) ATOMIC_ADD(&stk->memory, argclaim);
                        memoryclaims++;
                        PARDEBUG
-                       fprintf(stderr, "#DFLOWadmit %3d thread %d pool " LLFMT 
"claims " LLFMT "\n",
+                               fprintf(stderr, "#DFLOWadmit %3d thread %d pool 
" LLFMT "claims " LLFMT "\n",
                                                 memoryclaims, THRgettid(), 
memorypool, argclaim);
                        MT_lock_unset(&admissionLock);
-                       stk->workers++;
+                       (void) ATOMIC_INC(&stk->workers);
                        return 0;
                }
                PARDEBUG
-               fprintf(stderr, "#Delayed due to lack of memory " LLFMT " 
requested " LLFMT " memoryclaims %d\n", 
-                       memorypool, argclaim, memoryclaims);
+                       fprintf(stderr, "#Delayed due to lack of memory " LLFMT 
" requested " LLFMT " memoryclaims %d\n", 
+                               memorypool, argclaim, memoryclaims);
                MT_lock_unset(&admissionLock);
                return -1;
        }
        
        /* return the session budget */
-       if(cntxt->memorylimit){
+       if (cntxt->memorylimit) {
+               lng stack_memory = (lng) ATOMIC_GET(&stk->memory);
                PARDEBUG
-                       fprintf(stderr, "#Return memory to session budget " 
LLFMT "\n", stk->memory);
-               stk->memory += -argclaim;
+                       fprintf(stderr, "#Return memory to session budget " 
LLFMT "\n", stack_memory);
+               (void) ATOMIC_SUB(&stk->memory, argclaim);
        }
        /* release memory claimed before */
-       memorypool += -argclaim ;
+       memorypool -= argclaim;
        memoryclaims--;
-       stk->workers--;
+       (void) ATOMIC_DEC(&stk->workers);
 
        PARDEBUG
-       fprintf(stderr, "#DFLOWadmit %3d thread %d pool " LLFMT " claims " 
LLFMT "\n",
+               fprintf(stderr, "#DFLOWadmit %3d thread %d pool " LLFMT " 
claims " LLFMT "\n",
                                 memoryclaims, THRgettid(), memorypool, 
argclaim);
        MT_lock_unset(&admissionLock);
        return 0;
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
@@ -93,7 +93,7 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb, 
                        goto bailout;
                
                wrk = (int) ATOMIC_GET(&QRYqueue[i].stk->workers);
-               mem = (int) ATOMIC_GET(&QRYqueue[i].stk->memory);
+               mem = (int) ATOMIC_GET(&QRYqueue[i].stk->memory); /* TODO it 
should cast to lng */
                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