Changeset: 73ac8b3e9be7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=73ac8b3e9be7
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
clients/mapiclient/eventparser.c
clients/mapiclient/eventparser.h
monetdb5/mal/mal_client.c
monetdb5/mal/mal_client.h
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
monetdb5/mal/mal_runtime.c
Branch: profiler
Log Message:
Add user name property to event stream.
diffs (200 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
@@ -40163,10 +40163,6 @@ command profiler.setheartbeat(b:int):voi
address CMDsetHeartbeat;
comment Set heart beat performance tracing
-pattern profiler.setpoolsize(pool:int):void
-address CMDsetProfilerPoolSize;
-comment Re-initialize the profiler pool
-
pattern profiler.stop():void
address CMDstopProfiler;
comment Stop offline performance profiling
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
@@ -51094,10 +51094,6 @@ command profiler.setheartbeat(b:int):voi
address CMDsetHeartbeat;
comment Set heart beat performance tracing
-pattern profiler.setpoolsize(pool:int):void
-address CMDsetProfilerPoolSize;
-comment Re-initialize the profiler pool
-
pattern profiler.stop():void
address CMDstopProfiler;
comment Stop offline performance profiling
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
@@ -2409,7 +2409,7 @@ str printRef;
void printSignature(stream *fd, Symbol s, int flg);
void printStack(stream *f, MalBlkPtr mb, MalStkPtr s);
str prodRef;
-void profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start);
+void profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start, str
usrname);
void profilerGetCPUStat(lng *user, lng *nice, lng *sys, lng *idle, lng
*iowait);
void profilerHeartbeatEvent(char *alter);
str profilerRef;
diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -106,6 +106,7 @@ resetEventRecord(EventRecord *ev)
if( ev->package) free(ev->package);
if( ev->function) free(ev->function);
+ if( ev->user) free(ev->user);
if( ev->time) free(ev->time);
if( ev->stmt) free(ev->stmt);
if( ev->fcn) free(ev->fcn);
@@ -226,6 +227,7 @@ keyvalueparser(char *txt, EventRecord *e
return 0;
}
if( strstr(key,"function")){ ev->function= strdup(val); return 0;}
+ if( strstr(key,"user")){ ev->user= strdup(val); return 0;}
if( strstr(key,"tag")){ ev->tag= atoi(val); return 0;}
if( strstr(key,"thread")){ ev->thread= atoi(val); return 0;}
if( strstr(key,"pc")){ ev->pc= atoi(val); return 0;}
diff --git a/clients/mapiclient/eventparser.h b/clients/mapiclient/eventparser.h
--- a/clients/mapiclient/eventparser.h
+++ b/clients/mapiclient/eventparser.h
@@ -78,6 +78,7 @@ typedef struct {
int index; // return/arg index
int state;
char *function; // name of MAL block
+ char *user;
int pc; // instruction counter in block
int tag; // unique MAL block invocation tag
lng eventnr;// serial event number
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
@@ -48,6 +48,7 @@
#include "mal_namespace.h"
#include "mal_private.h"
#include "mal_runtime.h"
+#include "mal_authorize.h"
#include <mapi.h> /* for PROMPT1 */
@@ -200,6 +201,7 @@ MCinitClientRecord(Client c, oid user, b
str prompt;
c->user = user;
+ c->username = 0;
c->scenario = NULL;
c->oldscenario = NULL;
c->srcFile = NULL;
@@ -243,6 +245,7 @@ MCinitClientRecord(Client c, oid user, b
/* create a recycler cache */
c->exception_buf_initialized = 0;
c->error_row = c->error_fld = c->error_msg = c->error_input = NULL;
+ (void) AUTHgetUsername(&c->username, c);
MT_sema_init(&c->s, 0, "Client->s");
return c;
}
@@ -373,6 +376,10 @@ freeClient(Client c)
c->qtimeout = 0;
c->stimeout = 0;
c->user = oid_nil;
+ if( c->username){
+ GDKfree(c->username);
+ c->username = 0;
+ }
c->mythread = 0;
c->mode = MCshutdowninprogress()? BLOCKCLIENT: FREECLIENT;
GDKfree(c->glb);
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
@@ -55,6 +55,7 @@ typedef struct CURRENT_INSTR{
typedef struct CLIENT {
int idx; /* entry in mal_clients */
oid user; /* user id in the auth administration */
+ str username; /* for event processor */
/*
* The actions for a client is separated into several stages:
* parsing, strategic optimization, tactical optimization, and
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
@@ -110,7 +110,7 @@ EXAMPLE:
}
*/
static void
-renderProfilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start)
+renderProfilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start, str
usrname)
{
char logbuffer[LOGLEN], *logbase;
int loglen;
@@ -144,6 +144,8 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
tbuf[19]=0;
/* there should be less than 10^6 == 1M usecs in 1 sec */
assert(clock.tv_usec >= 0 && clock.tv_usec < 1000000);
+ if( usrname)
+ logadd("\"user\":\"%s\",\n",usrname);
logadd("\"clk\":"LLFMT",\n",GDKusec());
logadd("\"ctime\":\"%s.%06ld\",\n", tbuf+11, (long)clock.tv_usec);
logadd("\"thread\":%d,\n", THRgettid());
@@ -413,7 +415,7 @@ profilerHeartbeatEvent(char *alter)
}
void
-profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start)
+profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start, str
usrname)
{
if (stk == NULL) return;
if (pci == NULL) return;
@@ -424,7 +426,7 @@ profilerEvent(MalBlkPtr mb, MalStkPtr st
cachedProfilerEvent(mb, stk, pci);
if( eventstream) {
- renderProfilerEvent(mb, stk, pci, start);
+ renderProfilerEvent(mb, stk, pci, start, usrname);
if ( start && pci->pc ==0)
profilerHeartbeatEvent("ping");
if ( !start && pci->token == ENDsymbol)
@@ -461,7 +463,7 @@ openProfilerStream(stream *fd, int mode)
for(j = 0; j <THREADS; j++)
if( c->inprogress[j].mb)
/* show the event */
- profilerEvent(c->inprogress[j].mb,
c->inprogress[j].stk, c->inprogress[j].pci, 1);
+ profilerEvent(c->inprogress[j].mb,
c->inprogress[j].stk, c->inprogress[j].pci, 1, c->username);
}
}
return MAL_SUCCEED;
diff --git a/monetdb5/mal/mal_profiler.h b/monetdb5/mal/mal_profiler.h
--- a/monetdb5/mal/mal_profiler.h
+++ b/monetdb5/mal/mal_profiler.h
@@ -26,7 +26,7 @@ typedef struct Mallinfo Mallinfo;
mal_export str openProfilerStream(stream *fd, int mode);
mal_export str closeProfilerStream(void);
-mal_export void profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int
start);
+mal_export void profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int
start, str usrname);
mal_export str startProfiler(void);
mal_export str stopProfiler(void);
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
@@ -173,7 +173,7 @@ runtimeProfileBegin(Client cntxt, MalBlk
/* emit the instruction upon start as well */
if(malProfileMode > 0)
- profilerEvent(mb, stk, pci, TRUE);
+ profilerEvent(mb, stk, pci, TRUE, cntxt->username);
}
void
@@ -199,7 +199,7 @@ runtimeProfileExit(Client cntxt, MalBlkP
pci->wbytes += getVolume(stk, pci, 1);
if (pci->recycle)
pci->rbytes += getVolume(stk, pci, 0);
- profilerEvent(mb, stk, pci, FALSE);
+ profilerEvent(mb, stk, pci, FALSE, cntxt->username);
}
if( malProfileMode < 0){
/* delay profiling until you encounter start of MAL function */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list