Changeset: 6aca1509b533 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6aca1509b533
Modified Files:
clients/Tests/exports.stable.out
clients/mapiclient/stethoscope.c
clients/mapiclient/tachograph.c
clients/mapiclient/tomograph.c
monetdb5/mal/mal.c
monetdb5/mal/mal_client.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
monetdb5/mal/mal_runtime.c
monetdb5/modules/mal/profiler.c
monetdb5/modules/mal/profiler.h
monetdb5/modules/mal/profiler.mal
sql/backends/monet5/sql_scenario.c
Branch: profiler
Log Message:
Wrap up interface
Split tracing to file and table. Both can happen at the same time.
Initialize the trace pool each time you restart the streamer.
Drop the user check, to be handled at a different level.
diffs (truncated from 426 to 300 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
@@ -1102,12 +1102,9 @@ str CMDsetHeartbeat(void *res, int *ev);
str CMDsetProfilerPoolSize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
str CMDsetoid(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDstartProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str CMDstethoscope(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDstopProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDstr2qgrams(bat *ret, str *val);
str CMDstrlength(int *ret, str *v);
-str CMDtachograph(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str CMDtomograph(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDvarABS(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDvarADD(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDvarADDsignal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
@@ -2392,7 +2389,7 @@ str not_uniqueRef;
int notnilProp;
str oidRef;
void oldmoveInstruction(InstrPtr dst, InstrPtr src);
-str openProfilerStream(stream *fd);
+str openProfilerStream(stream *fd, int mode);
str openRef;
int open_block_stream(Stream *S, Stream *is);
str open_block_streamwrap(Stream *S, Stream *is);
@@ -2426,7 +2423,7 @@ str printRef;
void printSignature(stream *fd, Symbol s, int flg);
void printStack(stream *f, MalBlkPtr mb, MalStkPtr s);
str prodRef;
-void profilerEvent(oid usr, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int
start);
+void profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start);
void profilerGetCPUStat(lng *user, lng *nice, lng *sys, lng *idle, lng
*iowait);
void profilerHeartbeatEvent(char *alter);
str profilerRef;
@@ -2556,7 +2553,7 @@ int sqlblob_tostr(str *tostr, int *l, co
int sqlfunctionProp;
str srvpoolRef;
int stableProp;
-str startProfiler(oid user, int mode, int beat);
+str startProfiler(void);
str startRef;
str stopProfiler(void);
str stopRef;
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -303,7 +303,7 @@ main(int argc, char **argv)
fprintf(stderr,"-- %s\n",buf);
doQ(buf);
- snprintf(buf, BUFSIZ, " profiler.openstream();");
+ snprintf(buf, BUFSIZ, " profiler.openstream(1);");
if( debug)
fprintf(stderr,"--%s\n",buf);
doQ(buf);
diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c
--- a/clients/mapiclient/tachograph.c
+++ b/clients/mapiclient/tachograph.c
@@ -513,7 +513,7 @@ main(int argc, char **argv)
fprintf(stderr,"-- %s\n",buf);
doQ(buf);
- snprintf(buf, BUFSIZ, " profiler.openstream();");
+ snprintf(buf, BUFSIZ, " profiler.openstream(0);");
if( debug)
fprintf(stderr,"-- %s\n",buf);
doQ(buf);
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -1858,7 +1858,7 @@ main(int argc, char **argv)
fprintf(stderr,"-- %s\n",buf);
doQ(buf);
- snprintf(buf,BUFSIZ,"profiler.openstream();");
+ snprintf(buf,BUFSIZ,"profiler.openstream(0);");
if( debug)
fprintf(stderr,"-- %s\n",buf);
doQ(buf);
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -98,8 +98,7 @@ int mal_init(void){
/* set up the profiler if needed, output sent to console */
/* Use the same shortcuts as stethoscope */
if ( mal_trace ) {
- openProfilerStream(mal_clients[0].fdout);
- startProfiler(mal_clients[0].user,1,0);
+ openProfilerStream(mal_clients[0].fdout,0);
}
return 0;
}
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
@@ -571,7 +571,8 @@ MCreadClient(Client c)
str
PROFinitClient(Client c){
- startProfiler(c->idx,0,0);
+ (void) c;
+ startProfiler();
return MAL_SUCCEED;
}
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
@@ -28,7 +28,6 @@ stream *eventstream = 0;
static int offlineProfiling = FALSE;
static int sqlProfiling = FALSE;
static str myname = 0; // avoid tracing the profiler module
-static oid user = 0;
static int eventcounter = 0;
static int TRACE_init = 0;
@@ -525,9 +524,8 @@ profilerHeartbeatEvent(char *alter)
}
void
-profilerEvent(oid usr, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start)
+profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int start)
{
- if (usr != user) return;
if (stk == NULL) return;
if (pci == NULL) return;
if (getModuleId(pci) == myname) // ignore profiler commands from
monitoring
@@ -536,20 +534,48 @@ profilerEvent(oid usr, MalBlkPtr mb, Mal
if( sqlProfiling)
cachedProfilerEvent(mb, stk, pci);
- renderProfilerEvent(mb, stk, pci, start);
- if ( start && pci->pc ==0)
- profilerHeartbeatEvent("ping");
- if ( !start && pci->token == ENDsymbol)
- profilerHeartbeatEvent("ping");
+ if( eventstream) {
+ renderProfilerEvent(mb, stk, pci, start);
+ if ( start && pci->pc ==0)
+ profilerHeartbeatEvent("ping");
+ if ( !start && pci->token == ENDsymbol)
+ profilerHeartbeatEvent("ping");
+ }
}
+/* The first scheme dumps the events
+ * on a stream (and in the pool)
+ */
str
-openProfilerStream(stream *fd)
+openProfilerStream(stream *fd, int mode)
{
+ int i,j;
+ Client c;
+
+#ifdef HAVE_SYS_RESOURCE_H
+ getrusage(RUSAGE_SELF, &infoUsage);
+ prevUsage = infoUsage;
+#endif
+ if (myname == 0){
+ myname = putName("profiler", 8);
+ eventcounter = 0;
+ }
if( eventstream)
closeProfilerStream();
+ setprofilerpoolsize(poolSize);
malProfileMode = -1;
eventstream = fd;
+ /* show all in progress instructions for stethoscope startup */
+ if( mode > 0){
+ for (i = 0; i < MAL_MAXCLIENTS; i++) {
+ c = mal_clients+i;
+ if ( c->active )
+ 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);
+ }
+ }
return MAL_SUCCEED;
}
@@ -561,53 +587,27 @@ closeProfilerStream(void)
return MAL_SUCCEED;
}
-/*
- * When we receive the message to start profiling, we
- * should wait for the next instruction the stream
- * is initiated. This is controlled by a delay-switch
+/* the second scheme is to collect the profile
+ * events in a local table for direct SQL inspection
*/
-
str
-startProfiler(oid usr, int mode, int beat)
+startProfiler(void)
{
- Client c;
- int i,j;
-
#ifdef HAVE_SYS_RESOURCE_H
getrusage(RUSAGE_SELF, &infoUsage);
prevUsage = infoUsage;
#endif
- if (myname == 0)
- myname = putName("profiler", 8);
- setprofilerpoolsize(poolSize);
MT_lock_set(&mal_profileLock, "startProfiler");
-
- // enable the streaming of events
- if (eventstream != NULL) {
- offlineProfiling = TRUE;
- if( beat >= 0)
- setHeartbeat(beat);
+ if (myname == 0){
+ myname = putName("profiler", 8);
+ eventcounter = 0;
}
-
+ malProfileMode = 1;
+ offlineProfiling = TRUE;
sqlProfiling = TRUE;
- malProfileMode = mode;
- eventcounter = 0;
- user = usr;
MT_lock_unset(&mal_profileLock, "startProfiler");
- /* show all in progress instructions for stethoscope startup */
- if( mode > 0){
- for (i = 0; i < MAL_MAXCLIENTS; i++) {
- c = mal_clients+i;
- if ( c->active )
- for(j = 0; j <THREADS; j++)
- if( c->inprogress[j].mb)
- /* show the event */
- profilerEvent(i, c->inprogress[j].mb,
c->inprogress[j].stk, c->inprogress[j].pci, 1);
- }
- }
-
return MAL_SUCCEED;
}
@@ -618,7 +618,6 @@ stopProfiler(void)
malProfileMode = 0;
setHeartbeat(0); // stop heartbeat
closeProfilerStream();
- user = 0;
MT_lock_unset(&mal_profileLock, "stopProfiler");
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
@@ -23,12 +23,12 @@ typedef struct rusage Rusage;
typedef struct tms Tms;
typedef struct Mallinfo Mallinfo;
-mal_export str openProfilerStream(stream *fd);
+mal_export str openProfilerStream(stream *fd, int mode);
mal_export str closeProfilerStream(void);
-mal_export void profilerEvent(oid usr, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci, int start);
+mal_export void profilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int
start);
-mal_export str startProfiler(oid user, int mode, int beat);
+mal_export str startProfiler(void);
mal_export str stopProfiler(void);
mal_export void setHeartbeat(int delay);
mal_export str setprofilerpoolsize(int size);
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
@@ -172,7 +172,7 @@ runtimeProfileBegin(Client cntxt, MalBlk
/* emit the instruction upon start as well */
if(malProfileMode > 0)
- profilerEvent(cntxt->user, mb, stk, pci, TRUE);
+ profilerEvent(mb, stk, pci, TRUE);
}
void
@@ -198,7 +198,7 @@ runtimeProfileExit(Client cntxt, MalBlkP
pci->wbytes += getVolume(stk, pci, 1);
if (pci->recycle)
pci->rbytes += getVolume(stk, pci, 0);
- profilerEvent(cntxt->user, mb, stk, pci, FALSE);
+ profilerEvent(mb, stk, pci, FALSE);
}
if( malProfileMode < 0){
/* delay profiling until you encounter start of MAL function */
diff --git a/monetdb5/modules/mal/profiler.c b/monetdb5/modules/mal/profiler.c
--- a/monetdb5/modules/mal/profiler.c
+++ b/monetdb5/modules/mal/profiler.c
@@ -42,7 +42,7 @@ CMDopenProfilerStream(Client cntxt, MalB
(void) mb;
(void) stk;
(void) pc;
- return openProfilerStream(cntxt->fdout);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list