Changeset: b67688492489 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b67688492489
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_runtime.h
        sql/backends/monet5/sql_scenario.c
Branch: sql_profiler
Log Message:

Generate the tag for the upcoming mal program at the start of the SQL parsing 
phase.


diffs (81 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1323,6 +1323,7 @@ void runtimeProfileBegin(Client cntxt, M
 void runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci, RuntimeProfile prof);
 void runtimeProfileFinish(Client cntxt, MalBlkPtr mb, MalStkPtr stk);
 void runtimeProfileInit(Client cntxt, MalBlkPtr mb, MalStkPtr stk);
+oid runtimeProfileSetTag(Client cntxt);
 const char *sampleRef;
 const char *schedulerRef;
 const char *selectNotNilRef;
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
@@ -189,6 +189,15 @@ dropQRYqueue(void)
        MT_lock_unset(&mal_delayLock);
 }
 
+oid
+runtimeProfileSetTag(Client cntxt) {
+       MT_lock_set(&mal_delayLock);
+       cntxt->curprg->def->tag = qtag++;
+       MT_lock_unset(&mal_delayLock);
+
+       return cntxt->curprg->def->tag;
+}
+
 /* At the start of every MAL block or SQL query */
 void
 runtimeProfileInit(Client cntxt, MalBlkPtr mb, MalStkPtr stk)
@@ -246,7 +255,7 @@ runtimeProfileInit(Client cntxt, MalBlkP
        // add new invocation
        cntxt->idle = 0;
        QRYqueue[qhead].mb = mb;
-       QRYqueue[qhead].tag = stk->tag = mb->tag = qtag++;
+       QRYqueue[qhead].tag = stk->tag = mb->tag;
        QRYqueue[qhead].stk = stk;                              // for status 
pause 'p'/running '0'/ quiting 'q'
        QRYqueue[qhead].finished = 0;
        QRYqueue[qhead].start = time(0);
diff --git a/monetdb5/mal/mal_runtime.h b/monetdb5/mal/mal_runtime.h
--- a/monetdb5/mal/mal_runtime.h
+++ b/monetdb5/mal/mal_runtime.h
@@ -63,6 +63,7 @@ typedef struct WORKINGSET{
 
 mal_export Workingset workingset[THREADS];
 
+mal_export oid runtimeProfileSetTag(Client cntxt);
 mal_export void runtimeProfileInit(Client cntxt, MalBlkPtr mb, MalStkPtr stk);
 mal_export void runtimeProfileFinish(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk);
 mal_export void runtimeProfileBegin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci, RuntimeProfile prof);
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -32,6 +32,7 @@
 #include "mal.h"
 #include "mal_instruction.h"
 #include "mal_interpreter.h"
+#include "mal_runtime.h"
 #include "mal_parser.h"
 #include "mal_builder.h"
 #include "mal_namespace.h"
@@ -965,6 +966,7 @@ SQLparser(Client c)
        int oldvtop, oldstop, oldvid, ok;
        int pstatus = 0;
        int err = 0, opt, preparedid = -1;
+       oid tag = 0;
 
        c->query = NULL;
        be = (backend *) c->sqlcontext;
@@ -1103,7 +1105,10 @@ SQLparser(Client c)
                goto finalize;
        }
 
-       // TODO PROFILER: I will try to have the c->curprg->def->tag available
+       // generate and set the tag in the mal block of the clients current 
program.
+       tag = runtimeProfileSetTag(c);
+       assert(tag == c->curprg->def->tag);
+       (void) tag;
        // TODO PROFILER EVENT: start of sql parsing is start of sql compilation
 
        if ((err = sqlparse(m)) ||
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to