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

Remove unnecessary printing of long running queries in the mal_interpreter
They can be catched by inspecting the sys.queue().
Save a system call on GDKusec();


diffs (112 lines):

diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -80,8 +80,6 @@ MCinit(void)
                fprintf(stderr,"#MCinit:" MAL_MALLOC_FAIL);
                return false;
        }
-       for (int i = 0; i < MAL_MAXCLIENTS; i++)
-               ATOMIC_INIT(&mal_clients[i].lastprint, 0);
        return true;
 }
 
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -80,7 +80,6 @@ typedef struct CLIENT {
        lng             session;        /* usec since start of server */
        lng         qtimeout;   /* query abort after x usec*/
        lng             stimeout;       /* session abort after x usec */
-       ATOMIC_TYPE     lastprint;      /* when we last printed the query */
        /*
         * Communication channels for the interconnect are stored here.
         * It is perfectly legal to have a client without input stream.
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
@@ -296,7 +296,6 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
         * enough
         */
        cntxt->lastcmd= time(0);
-       ATOMIC_SET(&cntxt->lastprint, GDKusec());
        if (env != NULL) {
                int res = 1;
                stk = env;
@@ -560,22 +559,6 @@ str runMALsequence(Client cntxt, MalBlkP
                        lastcheck = runtimeProfile.ticks;
                }
 
-               if (qptimeout > 0) {
-                       lng t = GDKusec();
-                       ATOMIC_BASE_TYPE lp = ATOMIC_GET(&cntxt->lastprint);
-                       if ((lng) lp + qptimeout < t) {
-                               /* if still the same, replace lastprint with 
current
-                                * time and print the query */
-                               if (ATOMIC_CAS(&cntxt->lastprint, &lp, t)) {
-                                       const char *q = cntxt->getquery ? 
cntxt->getquery(cntxt) : NULL;
-                                       fprintf(stderr, "#%s: query already 
running "LLFMT"s: %.200s\n",
-                                                       cntxt->mythread->name,
-                                                       (lng) (time(0) - 
cntxt->lastcmd),
-                                                       q ? q : "");
-                               }
-                       }
-               }
-
                if (cntxt->qtimeout && mb->starttime && GDKusec() - 
mb->starttime > cntxt->qtimeout) {
                        freeException(ret);     /* in case it's set */
                        ret = createException(MAL, "mal.interpreter", 
SQLSTATE(HYT00) RUNTIME_QRY_TIMEOUT);
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
@@ -42,7 +42,7 @@ static str isaSQLquery(MalBlkPtr mb){
        int i;
        InstrPtr p;
        if (mb)
-       for ( i = 0; i< mb->stop; i++){
+       for ( i = 1; i< mb->stop; i++){
                p = getInstrPtr(mb,i);
                if ( getModuleId(p) && idcmp(getModuleId(p), "querylog") == 0 
&& idcmp(getFunctionId(p),"define")==0)
                        return getVarConstant(mb,getArg(p,1)).val.sval;
@@ -193,6 +193,7 @@ void
 runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, 
RuntimeProfile prof)
 {
        int tid = THRgettid();
+       lng ticks = GDKusec();
 
        /* keep track on the instructions in progress*/
        if ( tid < THREADS) {
@@ -207,7 +208,7 @@ runtimeProfileExit(Client cntxt, MalBlkP
 
        assert(prof);
        /* always collect the MAL instruction execution time */
-       pci->ticks = GDKusec() - prof->ticks;
+       pci->ticks = ticks - prof->ticks;
        pci->totticks += pci->ticks;
        pci->calls++;
        
@@ -219,9 +220,10 @@ runtimeProfileExit(Client cntxt, MalBlkP
                        malProfileMode = 1;
        }
        cntxt->active = FALSE;
-       /* reduce threads of non-admin long running transaction if needed */
-       if ( cntxt->idx > 1 )
-               MALresourceFairness(GDKusec()- mb->starttime);
+       /* Reduce worker threads of non-admin long running transaction if 
needed */
+       /* The super user can always proceed */
+       if ( cntxt->user != MAL_ADMIN )
+               MALresourceFairness(ticks - mb->starttime);
 }
 
 /*
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
@@ -13,7 +13,7 @@
 #include "mtime.h"
 
 /* (c) M.L. Kersten
- * The query runtime monitor facility is hardwired
+ * The queries currently in execution are returned to the front-end for 
managing expensive ones.
 */
 
 str
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to