Changeset: bb0fe9db5555 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bb0fe9db5555
Modified Files:
        monetdb5/mal/mal.h
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_resource.c
        monetdb5/mal/mal_runtime.c
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/26_sysmon.sql
Branch: scatter
Log Message:

new branch needed for an improved claim/append api.


diffs (125 lines):

diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -191,6 +191,10 @@ typedef struct MALBLK {
        short keephistory;              /* do we need the history at all */
        int maxarg;                             /* keep track on the maximal 
arguments used */
        ptr replica;                    /* for the replicator tests */
+
+       /* During the run we keep track on the maximum number of concurrent 
threads and memory claim */
+       int             workers;
+       int             memory;
        lng starttime;                  /* track when the query started, for 
resource management */
        lng runtime;                    /* average execution time of block in 
ticks */
        int calls;                              /* number of calls */
@@ -228,7 +232,7 @@ typedef struct MALSTK {
        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 */
+       lng     memory;                         /* Actual memory claims for 
highwater mark */
 
        struct MALSTK *up;              /* stack trace list */
        struct MALBLK *blk;             /* associated definition */
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -120,6 +120,8 @@ newMalBlk(int elements)
        mb->help = NULL;
        mb->binding[0] = 0;
        mb->tag = 0;
+       mb->workers = 0;
+       mb->memory = 0;
        mb->errors = NULL;
        mb->alternative = NULL;
        mb->history = NULL;
@@ -243,6 +245,8 @@ freeMalBlk(MalBlkPtr mb)
        }
        mb->binding[0] = 0;
        mb->tag = 0;
+       mb->memory = 0;
+       mb->workers = 0;
        if (mb->help)
                GDKfree(mb->help);
        mb->help = 0;
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
@@ -81,7 +81,7 @@ getMemoryClaim(MalBlkPtr mb, MalStkPtr s
                t = IMPSimprintsize(b);
                if( t > itotal)
                        itotal = t;
-               /* We should also consider the ordered index and mosaic */
+               /* We should also consider the ordered index size */
                //total = total > (lng)(MEMORY_THRESHOLD ) ? 
(lng)(MEMORY_THRESHOLD ) : total;
                BBPunfix(b->batCacheid);
                if ( total < itotal)
@@ -135,6 +135,11 @@ MALadmission_claim(Client cntxt, MalBlkP
                }
                memorypool -= argclaim;
                stk->workers++;
+               stk->memory += argclaim;
+               if( mb->workers < stk->workers)
+                       mb->workers = stk->workers;
+               if( mb->memory < stk->memory)
+                       mb->memory = stk->memory;
                MT_lock_unset(&admissionLock);
                return 0;
        }
@@ -161,6 +166,7 @@ MALadmission_release(Client cntxt, MalBl
                memorypool = (lng) MEMORY_THRESHOLD;
        }
        stk->workers--;
+       stk->memory -= argclaim;
        MT_lock_unset(&admissionLock);
        return;
 }
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
@@ -271,7 +271,7 @@ runtimeProfileInit(Client cntxt, MalBlkP
                QRYqueue[qhead].username = GDKstrdup(cntxt->username);
        QRYqueue[qhead].idx = cntxt->idx;
        QRYqueue[qhead].memory = (int) (stk->memory / LL_CONSTANT(1048576)); /* 
Convert to MB */
-       QRYqueue[qhead].workers = (int) stk->workers;
+       QRYqueue[qhead].workers = (int) 1;      /* this is the first one */
        QRYqueue[qhead].status = "running";
        QRYqueue[qhead].cntxt = cntxt;
        QRYqueue[qhead].ticks = GDKusec();
@@ -303,6 +303,8 @@ runtimeProfileFinish(Client cntxt, MalBl
                        }
                        QRYqueue[i].status = "finished";
                        QRYqueue[i].finished = time(0);
+                       QRYqueue[i].workers = mb->workers;
+                       QRYqueue[i].memory = mb->memory;
                        QRYqueue[i].cntxt = 0;
                        QRYqueue[i].stk = 0;
                        QRYqueue[i].mb = 0;
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1475,8 +1475,8 @@ sql_update_jun2020(Client c, mvc *sql, c
                        "\"status\" string,\n"
                        "\"query\" string,\n"
                        "\"progress\" int,\n"
-                       "\"workers\" int,\n"
-                       "\"memory\" int)\n"
+                       "\"maxworkers\" int,\n"
+                       "\"footprint\" int)\n"
                        " external name sysmon.queue;\n"
                        "grant execute on function sys.queue to public;\n"
                        "create view sys.queue as select * from sys.queue();\n"
diff --git a/sql/scripts/26_sysmon.sql b/sql/scripts/26_sysmon.sql
--- a/sql/scripts/26_sysmon.sql
+++ b/sql/scripts/26_sysmon.sql
@@ -16,8 +16,8 @@ returns table(
        "status" string,        -- paused, running, finished
        "query" string,
        "finished" timestamp,   
-       "workers" int,
-       "memory" int
+       "maxworkers" int,       -- maximum number of concurrent worker threads
+       "footprint" int         -- maximum memory claim awarded
 )
 external name sysmon.queue;
 grant execute on function sys.queue to public;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to