Changeset: 7fff4453df14 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7fff4453df14
Modified Files:
clients/Tests/exports.stable.out
clients/mapiclient/stethoscope.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/mal/profiler.c
monetdb5/modules/mal/profiler.h
monetdb5/modules/mal/profiler.mal
Branch: profiler
Log Message:
Remove serverside profiler pool
- profiler pool not needed for MPM
- use TCP stream instead of UDP
diffs (255 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
@@ -1095,7 +1095,6 @@ str CMDscience_bat_flt_sqrt(bat *ret, co
str CMDscience_bat_flt_tan(bat *ret, const bat *bid);
str CMDscience_bat_flt_tanh(bat *ret, const bat *bid);
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 CMDstopProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -323,6 +323,8 @@ main(int argc, char **argv)
conn = mapi_get_from(dbh);
while ((n = mnstr_read(conn, buffer + len, 1, buflen - len-1)) >= 0) {
buffer[len + n] = 0;
+ if(debug)
+ printf("%s",buffer);
if( trace)
fprintf(trace,"%s",buffer);
response = buffer;
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
@@ -49,71 +49,6 @@ static struct{
//static MT_Lock mal_beatLock MT_LOCK_INITIALIZER("beatLock");
//#endif
-/*
- * Profiler trace cache
- * The trace information for a limited collection of queries is retained in
- * a profiler cache, located in the database directory profiler_logs.
- * It can be used for post-mortem analysis. It actually should be a
profiler_vault.
- *
- * The cache file name is simply derived from the MAL block invocation tag,
- * which is assured to be unique.
- *
- * The JSON structures are also sent to the single stream upon request.
- *
- * The old profiler cache structures are removed when you
- * start of the profiler.
- */
-
-#define MAXJSONEVENTS (1000000) /* cut off large JSON traces */
-#define DEFAULTPOOLSIZE 10
-
-typedef struct {
- int tag;
- int cnt; // number of events in this bucket
- lng start,finish;
- char fname[BUFSIZ];
- stream *trace;
-} ProfilerRecord;
-
-ProfilerRecord *profilerPool;
-static int poolSize= DEFAULTPOOLSIZE;
-
-static void
-clearPool(void)
-{ int i;
-
- // remove old profiler traces
- if( profilerPool )
- for( i = 0; i < poolSize; i++){
- if ( profilerPool[i].trace)
- close_stream(profilerPool[i].trace);
- if( profilerPool[i].fname[0])
- (void) unlink(profilerPool[i].fname);
- }
-}
-
-// setting the poolsize re-initializes the pool
-str
-setprofilerpoolsize(int size)
-{
- if( size < 1)
- throw(MAL,"profiler.setPool", "invalid pool size");
- MT_lock_set(&mal_profileLock, "profilerpool");
- // Always cleanout the past before you set the new pool size
- if (profilerPool){
- clearPool();
- poolSize = 0;
- GDKfree(profilerPool);
- profilerPool = 0;
- }
- profilerPool = GDKzalloc(size * sizeof(ProfilerRecord));
- MT_lock_unset(&mal_profileLock, "profilerpool");
- if( profilerPool == 0)
- throw(MAL,"profiler.setPool", MAL_MALLOC_FAIL);
- poolSize = size;
- return MAL_SUCCEED;
-}
-
#define LOGLEN 8192
#define lognew() loglen = 0; logbase = logbuffer; *logbase = 0;
@@ -125,20 +60,21 @@ setprofilerpoolsize(int size)
// The heart beat events should be sent to all outstanding channels.
-static void logjsonInternal(int k, char *logbuffer, InstrPtr p)
+static void logjsonInternal(char *logbuffer)
{
char buf[BUFSIZ], *s;
size_t len, lenhdr;
- snprintf(buf,BUFSIZ,"%d",eventcounter);
s = strchr(logbuffer,(int) ':');
if( s == NULL){
return;
}
- strncpy(s+1, buf,strlen(buf));
len = strlen(logbuffer);
MT_lock_set(&mal_profileLock, "logjson");
+ snprintf(buf,BUFSIZ,"%d",eventcounter);
+ strncpy(s+1, buf,strlen(buf));
+
if (eventstream) {
// upon request the log record is sent over the profile stream
if( eventcounter == 0){
@@ -149,59 +85,10 @@ static void logjsonInternal(int k, char
(void) mnstr_write(eventstream, logbuffer, 1, len);
(void) mnstr_flush(eventstream);
}
-
- // all queries are assembled in a performance trace pool
- if( profilerPool){
- if( profilerPool[k].trace == NULL){
- if( profilerPool[k].fname[0]== 0)
- (void) mkdir("profiler_logs", 0755);
- if( profilerPool[k].fname[0]== 0)
- snprintf(profilerPool[k].fname,
BUFSIZ,"profiler_logs/%d.json",k);
-
- profilerPool[k].trace =
open_wastream(profilerPool[k].fname);
- if( profilerPool[k].trace == NULL){
- GDKerror("could not create profiler file");
- MT_lock_unset(&mal_profileLock, "logjson");
- return;
- }
- profilerPool[k].start = GDKusec();
- snprintf(buf,BUFSIZ,"%s\n",monetdb_characteristics);
- (void) mnstr_write(profilerPool[k].trace, buf, 1,
strlen(buf));
- }
- if( profilerPool[k].trace){
- (void)
mnstr_write(profilerPool[k].trace,logbuffer,1,len);
- (void) mnstr_flush(profilerPool[k].trace);
- }
- if ( profilerPool[k].trace && (( p && p->barrier == ENDsymbol
&& strstr(logbuffer,"done")) || profilerPool[k].cnt > MAXJSONEVENTS) ){
- (void) mnstr_flush(profilerPool[k].trace);
- (void) close_stream(profilerPool[k].trace);
- profilerPool[k].cnt = 0;
- profilerPool[k].trace = NULL;
- profilerPool[k].finish = GDKusec();
- }
- }
eventcounter++;
MT_lock_unset(&mal_profileLock, "logjson");
}
-static void logjson(MalBlkPtr mb, MalStkPtr stk, InstrPtr p, char *logbuffer)
-{
- int i,k;
-
- (void) mb;
- if (stk){
- logjsonInternal( k = stk->tag % poolSize, logbuffer,p);
- if (profilerPool)
- profilerPool[k].tag = stk->tag;
- } else if (profilerPool) {
-// The heart beat events should be sent to all outstanding channels.
-// But only once to the stream
- for(i=0; i< poolSize; i++)
- if (profilerPool[i].trace)
- logjsonInternal( i, logbuffer, 0);
- }
-}
-
/* JSON rendering method of performance data.
* The eventparser may assume this layout for ease of parsing
EXAMPLE:
@@ -403,7 +290,7 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
#endif
}
logadd("}\n"); // end marker
- logjson(mb,stk,pci,logbuffer);
+ logjsonInternal(logbuffer);
}
static int
@@ -521,7 +408,7 @@ profilerHeartbeatEvent(char *alter)
logadd("\"state\":\"%s\",\n",alter);
logadd("\"cpuload\":\"%s\",\n",cpuload);
logadd("}\n"); // end marker
- logjson(0,0,0,logbuffer);
+ logjsonInternal(logbuffer);
}
void
@@ -563,7 +450,6 @@ openProfilerStream(stream *fd, int mode)
}
if( eventstream)
closeProfilerStream();
- setprofilerpoolsize(poolSize);
malProfileMode = -1;
eventstream = fd;
/* show all in progress instructions for stethoscope startup */
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
@@ -52,17 +52,6 @@ CMDcloseProfilerStream(void *res)
return closeProfilerStream();
}
-str
-CMDsetProfilerPoolSize (Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci)
-{
- int poolsize = *getArgReference_int(stk,pci,1);
- (void) mb; /* fool compiler */
- (void) cntxt;
- if( poolsize < 0)
- throw(MAL,"profiler","Trace pool size should be positive");
- return setprofilerpoolsize(poolsize);
-}
-
// initialize SQL tracing
str
CMDstartProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc)
diff --git a/monetdb5/modules/mal/profiler.h b/monetdb5/modules/mal/profiler.h
--- a/monetdb5/modules/mal/profiler.h
+++ b/monetdb5/modules/mal/profiler.h
@@ -42,7 +42,6 @@ profiler_export str CMDstartProfiler(Cli
profiler_export str CMDstopProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
profiler_export str CMDnoopProfiler(void *res);
profiler_export str CMDsetHeartbeat(void *res, int *ev);
-profiler_export str CMDsetProfilerPoolSize(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr pci);
profiler_export str CMDopenProfilerStream(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr pci);
profiler_export str CMDcloseProfilerStream(void *res);
profiler_export str CMDcleanup(void *ret);
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
@@ -14,10 +14,6 @@ pattern stop():void
address CMDstopProfiler
comment "Stop offline performance profiling";
-pattern setpoolsize(pool:int)
-address CMDsetProfilerPoolSize
-comment "Re-initialize the profiler pool";
-
command setheartbeat(b:int):void
address CMDsetHeartbeat
comment "Set heart beat performance tracing";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list