Changeset: 9d7d46fecd6e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d7d46fecd6e
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        clients/mapiclient/Tests/stethoscope--help.stable.err
        monetdb5/mal/mal_profiler.c
        monetdb5/modules/mal/profiler.mal
        monetdb5/modules/mal/querylog.c
        monetdb5/modules/mal/querylog.h
        monetdb5/modules/mal/querylog.mal
        monetdb5/optimizer/opt_garbageCollector.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
        sql/backends/monet5/sql_gencode.c
Branch: default
Log Message:

Added the querylog.context instruction to make MAL plans more informative.
Emit the user OID in the eventstream too.


diffs (truncated from 354 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -11523,14 +11523,13 @@ stdout of test 'MAL-signatures` in direc
 [ "profiler",  "getTrace",     "pattern profiler.getTrace(e:str):bat[:any_1] 
",        "CMDgetTrace;", "Get the trace details of a specific event"     ]
 [ "profiler",  "getUserTime",  "command profiler.getUserTime():lng ",  
"CMDgetUserTime;",      "Obtain the user timing information."   ]
 [ "profiler",  "noop", "command profiler.noop():void ",        
"CMDnoopProfiler;",     "Fetch any pending performance events"  ]
-[ "profiler",  "openstream",   "pattern profiler.openstream(mode:int):void ",  
"CMDopenProfilerStream;",       "Start profiling the events, send to output 
stream"     ]
+[ "profiler",  "openstream",   "pattern profiler.openstream():void ",  
"CMDopenProfilerStream;",       "Start profiling the events, send to output 
stream"     ]
 [ "profiler",  "setheartbeat", "command profiler.setheartbeat(b:int):void ",   
"CMDsetHeartbeat;",     "Set heart beat performance tracing"    ]
 [ "profiler",  "start",        "pattern profiler.start():void ",       
"CMDstartProfiler;",    "Start offline performance profiling"   ]
 [ "profiler",  "starttrace",   "pattern profiler.starttrace():void ",  
"CMDstartTrace;",       "Start collecting trace information"    ]
-[ "profiler",  "starttrace",   "pattern profiler.starttrace(path:str):void ",  
"CMDstartTracePath;",   "Start collecting trace information and keep around in 
'path' directory"        ]
 [ "profiler",  "stop", "pattern profiler.stop():void ",        
"CMDstopProfiler;",     "Stop offline performance profiling"    ]
 [ "profiler",  "stoptrace",    "pattern profiler.stoptrace():void ",   
"CMDstopTrace;",        "Stop collecting trace information"     ]
-[ "profiler",  "stoptrace",    "pattern profiler.stoptrace(path:str):void ",   
"CMDstopTracePath;",    "Stop collecting trace information"     ]
+[ "profiler",  "stoptrace",    "pattern profiler.stoptrace(path:str):void ",   
"CMDstopTracePath;",    ""      ]
 [ "pyapi",     "eval", "unsafe pattern pyapi.eval(fptr:ptr, expr:str):any ",   
"PYAPI2PyAPIevalStd;",  "Execute a simple Python script returning a single 
value"       ]
 [ "pyapi",     "eval", "unsafe pattern pyapi.eval(fptr:ptr, expr:str, 
arg:any...):any... ",    "PYAPI2PyAPIevalStd;",  "Execute a simple Python 
script value"  ]
 [ "pyapi",     "eval_aggr",    "unsafe pattern pyapi.eval_aggr(fptr:ptr, 
expr:str, arg:any...):any... ",       "PYAPI2PyAPIevalAggr;", "grouped 
aggregates through Python"     ]
@@ -11544,6 +11543,7 @@ stdout of test 'MAL-signatures` in direc
 [ "pyapimap",  "subeval_aggr", "pattern pyapimap.subeval_aggr(fptr:ptr, 
expr:str, arg:any...):any... ",        "PYAPI2PyAPIevalAggrMap;",      "grouped 
aggregates through Python"     ]
 [ "querylog",  "append",       "pattern querylog.append(q:str, pipe:str, 
usr:str, tick:timestamp):void ",      "QLOGappend;",  "Add a new query call to 
the query log" ]
 [ "querylog",  "call", "pattern querylog.call(tick1:timestamp, 
tick2:timestamp, arg:str, tuples:lng, xtime:lng, rtime:lng, cpu:int, 
iowait:int):void ",        "QLOGcall;",    "Add a new query call to the query 
log" ]
+[ "querylog",  "context",      "command querylog.context(release:str, 
version:str, revision:str, uri:str):void ",      "QLOGcontextNaive;",    "Noop 
operation, just marking the query"        ]
 [ "querylog",  "define",       "command querylog.define(q:str, pipe:str, 
size:int):void ",     "QLOGdefineNaive;",     "Noop operation, just marking the 
query"        ]
 [ "querylog",  "disable",      "command querylog.disable():void ",     
"QLOGdisable;", "Turn off the query logger"     ]
 [ "querylog",  "empty",        "command querylog.empty():void ",       
"QLOGempty;",   "Clear the query log tables"    ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -15927,14 +15927,13 @@ stdout of test 'MAL-signatures` in direc
 [ "profiler",  "getTrace",     "pattern profiler.getTrace(e:str):bat[:any_1] 
",        "CMDgetTrace;", "Get the trace details of a specific event"     ]
 [ "profiler",  "getUserTime",  "command profiler.getUserTime():lng ",  
"CMDgetUserTime;",      "Obtain the user timing information."   ]
 [ "profiler",  "noop", "command profiler.noop():void ",        
"CMDnoopProfiler;",     "Fetch any pending performance events"  ]
-[ "profiler",  "openstream",   "pattern profiler.openstream(mode:int):void ",  
"CMDopenProfilerStream;",       "Start profiling the events, send to output 
stream"     ]
+[ "profiler",  "openstream",   "pattern profiler.openstream():void ",  
"CMDopenProfilerStream;",       "Start profiling the events, send to output 
stream"     ]
 [ "profiler",  "setheartbeat", "command profiler.setheartbeat(b:int):void ",   
"CMDsetHeartbeat;",     "Set heart beat performance tracing"    ]
 [ "profiler",  "start",        "pattern profiler.start():void ",       
"CMDstartProfiler;",    "Start offline performance profiling"   ]
 [ "profiler",  "starttrace",   "pattern profiler.starttrace():void ",  
"CMDstartTrace;",       "Start collecting trace information"    ]
-[ "profiler",  "starttrace",   "pattern profiler.starttrace(path:str):void ",  
"CMDstartTracePath;",   "Start collecting trace information and keep around in 
'path' directory"        ]
 [ "profiler",  "stop", "pattern profiler.stop():void ",        
"CMDstopProfiler;",     "Stop offline performance profiling"    ]
 [ "profiler",  "stoptrace",    "pattern profiler.stoptrace():void ",   
"CMDstopTrace;",        "Stop collecting trace information"     ]
-[ "profiler",  "stoptrace",    "pattern profiler.stoptrace(path:str):void ",   
"CMDstopTracePath;",    "Stop collecting trace information"     ]
+[ "profiler",  "stoptrace",    "pattern profiler.stoptrace(path:str):void ",   
"CMDstopTracePath;",    ""      ]
 [ "pyapi",     "eval", "unsafe pattern pyapi.eval(fptr:ptr, expr:str):any ",   
"PYAPI2PyAPIevalStd;",  "Execute a simple Python script returning a single 
value"       ]
 [ "pyapi",     "eval", "unsafe pattern pyapi.eval(fptr:ptr, expr:str, 
arg:any...):any... ",    "PYAPI2PyAPIevalStd;",  "Execute a simple Python 
script value"  ]
 [ "pyapi",     "eval_aggr",    "unsafe pattern pyapi.eval_aggr(fptr:ptr, 
expr:str, arg:any...):any... ",       "PYAPI2PyAPIevalAggr;", "grouped 
aggregates through Python"     ]
@@ -15948,6 +15947,7 @@ stdout of test 'MAL-signatures` in direc
 [ "pyapimap",  "subeval_aggr", "pattern pyapimap.subeval_aggr(fptr:ptr, 
expr:str, arg:any...):any... ",        "PYAPI2PyAPIevalAggrMap;",      "grouped 
aggregates through Python"     ]
 [ "querylog",  "append",       "pattern querylog.append(q:str, pipe:str, 
usr:str, tick:timestamp):void ",      "QLOGappend;",  "Add a new query call to 
the query log" ]
 [ "querylog",  "call", "pattern querylog.call(tick1:timestamp, 
tick2:timestamp, arg:str, tuples:lng, xtime:lng, rtime:lng, cpu:int, 
iowait:int):void ",        "QLOGcall;",    "Add a new query call to the query 
log" ]
+[ "querylog",  "context",      "command querylog.context(release:str, 
version:str, revision:str, uri:str):void ",      "QLOGcontextNaive;",    "Noop 
operation, just marking the query"        ]
 [ "querylog",  "define",       "command querylog.define(q:str, pipe:str, 
size:int):void ",     "QLOGdefineNaive;",     "Noop operation, just marking the 
query"        ]
 [ "querylog",  "disable",      "command querylog.disable():void ",     
"QLOGdisable;", "Turn off the query logger"     ]
 [ "querylog",  "empty",        "command querylog.empty():void ",       
"QLOGempty;",   "Clear the query log tables"    ]
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
@@ -1165,10 +1165,8 @@ str CMDsetName(str *rname, const bat *b,
 str CMDsetprofilerlimit(void *res, int *lim);
 str CMDstartProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CMDstartTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str CMDstartTracePath(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CMDstopProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CMDstopTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str CMDstopTracePath(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CMDstr2qgrams(bat *ret, str *val);
 str CMDstrlength(int *ret, str *v);
 str CMDvarABS(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
@@ -1668,6 +1666,7 @@ str QLOGappend(Client cntxt, MalBlkPtr m
 str QLOGcall(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str QLOGcalls(BAT **r);
 str QLOGcatalog(BAT **r);
+str QLOGcontextNaive(void *ret, str *release, str *version, str *revision, str 
*uri);
 str QLOGdefineNaive(void *ret, str *qry, str *opt, int *nr);
 str QLOGdisable(void *ret);
 str QLOGempty(void *ret);
@@ -2057,6 +2056,7 @@ str compileAllOptimizers(Client cntxt);
 str compileOptimizer(Client cntxt, const char *name);
 str compileString(Symbol *fcn, Client c, str s);
 str connectRef;
+str contextRef;
 str convertConstant(malType type, ValPtr vr);
 InstrPtr copyInstruction(InstrPtr p);
 MalBlkPtr copyMalBlk(MalBlkPtr mb);
@@ -2436,7 +2436,7 @@ str ntileRef;
 str oidRef;
 void oldmoveInstruction(InstrPtr dst, InstrPtr src);
 str oltpRef;
-str openProfilerStream(Client cntxt, stream *fd, int mode);
+str openProfilerStream(Client cntxt);
 str openRef;
 int open_block_stream(Stream *S, Stream *is);
 str open_block_streamwrap(Stream *S, Stream *is);
@@ -2595,10 +2595,10 @@ str sqlRef;
 str sqlcatalogRef;
 str startProfiler(Client cntxt);
 str startRef;
-str startTrace(Client cntxt, str path);
+str startTrace(Client cntxt);
 str starttraceRef;
 str stopProfiler(Client cntxt);
-str stopTrace(Client cntxt, str path);
+str stopTrace(Client cntxt);
 str stoptraceRef;
 void strAfterCall(ValPtr v, ValPtr bak);
 void strBeforeCall(ValPtr v, ValPtr bak);
diff --git a/clients/mapiclient/Tests/stethoscope--help.stable.err 
b/clients/mapiclient/Tests/stethoscope--help.stable.err
--- a/clients/mapiclient/Tests/stethoscope--help.stable.err
+++ b/clients/mapiclient/Tests/stethoscope--help.stable.err
@@ -18,7 +18,6 @@ stethoscope [options]
   -h | --host=<hostname>
   -c | --convert=<old formated file>
   -j | --json
-  -y | --pretty (implies --json)
   -o | --output=<file>
   -b | --beat=<delay> in milliseconds (default 50)
   -D | --debug
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -131,7 +131,6 @@ EXAMPLE:
 static void
 renderProfilerEvent(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, 
int start)
 {
-       (void)cntxt;
        char logbuffer[LOGLEN], *logbase;
        size_t loglen;
        str stmt, c;
@@ -166,6 +165,7 @@ renderProfilerEvent(Client cntxt, MalBlk
        logadd("\"version\":\""VERSION" (hg id: %s)\","PRETTIFY, 
mercurial_revision());
        logadd("\"source\":\"trace\","PRETTIFY);
 
+       logadd("\"oid\":"OIDFMT","PRETTIFY, cntxt->user);
        logadd("\"clk\":"LLFMT","PRETTIFY, usec);
        logadd("\"ctime\":%"PRIu64","PRETTIFY, microseconds);
        logadd("\"thread\":%d,"PRETTIFY, THRgettid());
diff --git a/monetdb5/modules/mal/profiler.mal 
b/monetdb5/modules/mal/profiler.mal
--- a/monetdb5/modules/mal/profiler.mal
+++ b/monetdb5/modules/mal/profiler.mal
@@ -22,10 +22,6 @@ pattern stoptrace():void
 address CMDstopTrace
 comment "Stop collecting trace information";
 
-pattern stoptrace(path:str):void
-address CMDstopTracePath
-comment "Stop collecting trace information";
-
 command setheartbeat(b:int):void
 address CMDsetHeartbeat
 comment "Set heart beat performance tracing";
diff --git a/monetdb5/modules/mal/querylog.c b/monetdb5/modules/mal/querylog.c
--- a/monetdb5/modules/mal/querylog.c
+++ b/monetdb5/modules/mal/querylog.c
@@ -378,6 +378,18 @@ QLOGdefineNaive(void *ret, str *qry, str
 }
 
 str
+QLOGcontextNaive(void *ret, str *release, str *version, str *revision, str 
*uri)
+{
+       // Nothing else to be done.
+       (void) ret;
+       (void) release;
+       (void) version;
+       (void) revision;
+       (void) uri;
+       return MAL_SUCCEED;
+}
+
+str
 QLOGcall(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        timestamp *tick1  = getArgReference_TYPE(stk,pci,1,timestamp);
diff --git a/monetdb5/modules/mal/querylog.h b/monetdb5/modules/mal/querylog.h
--- a/monetdb5/modules/mal/querylog.h
+++ b/monetdb5/modules/mal/querylog.h
@@ -22,6 +22,7 @@ mal_export str QLOGissetFcn(int *ret);
 mal_export str QLOGempty(void *ret);
 mal_export str QLOGappend(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 mal_export str QLOGdefineNaive(void *ret, str *qry, str *opt, int *nr);
+mal_export str QLOGcontextNaive(void *ret, str *release, str *version, str 
*revision, str *uri);
 mal_export str QLOGcall(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 
 #endif /* _QLOG_H */
diff --git a/monetdb5/modules/mal/querylog.mal 
b/monetdb5/modules/mal/querylog.mal
--- a/monetdb5/modules/mal/querylog.mal
+++ b/monetdb5/modules/mal/querylog.mal
@@ -34,6 +34,10 @@ command define(q:str, pipe:str, size:int
 address QLOGdefineNaive
 comment "Noop operation, just marking the query";
 
+command context(release:str, version:str, revision:str, uri:str)
+address QLOGcontextNaive
+comment "Noop operation, just marking the query";
+
 pattern call(tick1:timestamp, tick2:timestamp, arg:str, tuples:lng, xtime:lng, 
rtime:lng, cpu:int, iowait:int)
 address QLOGcall
 comment "Add a new query call to the query log";
diff --git a/monetdb5/optimizer/opt_garbageCollector.c 
b/monetdb5/optimizer/opt_garbageCollector.c
--- a/monetdb5/optimizer/opt_garbageCollector.c
+++ b/monetdb5/optimizer/opt_garbageCollector.c
@@ -25,7 +25,7 @@
 str
 OPTgarbageCollectorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
 {
-       int i, j, limit, slimit, vlimit;
+       int i, limit, slimit, vlimit;
        InstrPtr p, *old;
        int actions = 0;
        char buf[256];
@@ -33,23 +33,12 @@ OPTgarbageCollectorImplementation(Client
        str msg = MAL_SUCCEED;
        //str nme;
        char *used;
-       //int *varlnk, *stmtlnk;
 
        (void) pci;
        (void) cntxt;
        (void) stk;
        if ( mb->inlineProp)
                return 0;
-/*
-       varlnk = (int*) GDKzalloc(mb->vtop * sizeof(int));
-       if( varlnk == NULL)
-               return 0;
-       stmtlnk = (int*) GDKzalloc((mb->stop + 1) * sizeof(int));
-       if( stmtlnk == NULL){
-               GDKfree(varlnk);
-               return 0;
-       }
-*/
        
        used = (char*) GDKzalloc(sizeof(char) * mb->vtop);
        if ( used == NULL)
@@ -63,10 +52,10 @@ OPTgarbageCollectorImplementation(Client
        /* rename all temporaries used for ease of debugging and profile 
interpretation */
 
        for( i = 0; i < mb->vtop; i++)
-               if( sscanf(getVarName(mb,i),"X_%d", &j) == 1)
+               if (getVarName(mb,i)[0] == 'X' && getVarName(mb,i)[1] == '_')
                        snprintf(getVarName(mb,i),IDLENGTH,"X_%d",i);
                else
-               if( sscanf(getVarName(mb,i),"C_%d", &j) == 1)
+               if (getVarName(mb,i)[0] == 'C' && getVarName(mb,i)[1] == '_')
                        snprintf(getVarName(mb,i),IDLENGTH,"C_%d",i);
 
        // move SQL query definition to the front for event profiling tools
@@ -85,16 +74,6 @@ OPTgarbageCollectorImplementation(Client
        }
 
        // Actual garbage collection stuff
-       // Construct the linked list of variables based on end-of-scope
-/*
-       setVariableScope(mb);
-       for( i = 0; i < mb->vtop; i++){
-               assert(getEndScope(mb,i) >= 0);
-               assert(getEndScope(mb,i) <= mb->stop);
-         varlnk[i] = stmtlnk[getEndScope(mb,i)];
-         stmtlnk[getEndScope(mb,i)] = i;
-       }
-*/
 
        if ( newMalBlkStmt(mb,mb->ssize) < 0) 
                throw(MAL, "optimizer.garbagecollector", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
@@ -106,23 +85,6 @@ OPTgarbageCollectorImplementation(Client
                p->typechk = TYPE_UNKNOWN;
                /* Set the program counter to ease profiling */
                p->pc = i;
-               /* rename all temporaries used for ease of debugging and 
profile interpretation */
-/* lets check if this is the culprit for DS22 on april
- * Remove the use of 'used' and only looking at returns. 
- * It should be sufficient to look into the variable table
-               for( j = 0; j< p->retc; j++){
-                       arg = getArg(p,j);
-                       if( used[arg] ==0){
-                               nme = getVarName(mb,arg);
-                               if( nme[0] == 'X' && nme[1] == '_' )
-                                               snprintf(nme, IDLENGTH, "X_%d", 
arg);
-                               else
-                               if( nme[0] == 'C' && nme[1] == '_' )
-                                               snprintf(nme, IDLENGTH,"C_%d", 
arg);
-                               used[arg] ++;
-                       }
-               }
-*/
 
                if ( p->barrier == RETURNsymbol){
                        pushInstruction(mb, p);
diff --git a/monetdb5/optimizer/opt_prelude.c b/monetdb5/optimizer/opt_prelude.c
--- a/monetdb5/optimizer/opt_prelude.c
+++ b/monetdb5/optimizer/opt_prelude.c
@@ -79,6 +79,7 @@ str columnRef;
 str comment_onRef;
 str commitRef;
 str connectRef;
+str contextRef;
 str copy_fromRef;
 str copyRef;
 str count_no_nilRef;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to