Changeset: cdc10f3a7dbd for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cdc10f3a7dbd
Added Files:
sql/scripts/46_profiler.sql
Modified Files:
clients/Tests/exports.stable.out
clients/mapiclient/eventparser.c
clients/mapiclient/eventparser.h
clients/mapiclient/stethoscope.c
clients/mapiclient/tachograph.c
clients/mapiclient/tomograph.c
monetdb5/mal/mal.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
monetdb5/modules/mal/profiler.c
monetdb5/modules/mal/profiler.h
monetdb5/modules/mal/profiler.mal
Branch: profiler
Log Message:
Generate json profiler events
- replace tuple format with (strictly structured) json
- stethoscope, tachograph, and tomograph work from the json structure
- eventparser is rigid, using the structure
- events are collected per query in a pool at the server side as well
Freezing the state, because it shows a concurrency problem
in the cachedProfilerEvent code section.
An attempt is made to update the same bat in two threads
while the bat is subject to a resize.
diffs (truncated from 2442 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
@@ -1122,7 +1122,6 @@ str CMDconvertsignal_str(Client cntxt, M
str CMDconvertsignal_wrd(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
str CMDcpuloadPercentage(int *cycles, int *io, lng *user, lng *nice, lng *sys,
lng *idle, lng *iowait);
str CMDcpustats(lng *user, lng *nice, lng *sys, lng *idle, lng *iowait);
-str CMDdumpTrace(void *res);
str CMDevalFile(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDgetBATlrefcnt(int *res, bat *bid);
str CMDgetBATrefcnt(int *res, bat *bid);
@@ -1181,9 +1180,9 @@ 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 CMDsetProfilerFile(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
str CMDsetProfilerStream(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);
@@ -1245,7 +1244,6 @@ str GROUPmulticolumngroup(Client cntxt,
str GRPsubgroup1(bat *ngid, bat *next, bat *nhis, const bat *bid);
str GRPsubgroup2(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat
*gid);
str GRPsubgroup4(bat *ngid, bat *next, bat *nhis, const bat *bid, const bat
*gid, const bat *eid, const bat *hid);
-double HeartbeatCPUload(void);
str IDentifier(identifier *retval, str *in);
int IDfromString(str src, int *len, identifier *retval);
str IDprelude(void *ret);
@@ -1718,7 +1716,6 @@ str PCREquote(str *r, const str *v);
str PCREreplace_bat_wrap(bat *res, const bat *or, const str *pat, const str
*repl, const str *flags);
str PCREreplace_wrap(str *res, const str *or, const str *pat, const str *repl,
const str *flags);
str PCREsql2pcre(str *ret, const str *pat, const str *esc);
-str PROFclearcache(void);
sht PropertyIndex(str name);
str PropertyName(sht idx);
prop_op_t PropertyOperator(str s);
@@ -2062,7 +2059,6 @@ str ZORDdecode_int_oid_x(int *x, oid *z)
str ZORDdecode_int_oid_y(int *y, oid *z);
str ZORDencode_int_oid(oid *z, int *x, int *y);
str ZORDslice_int(bat *r, int *xb, int *yb, int *xt, int *yt);
-void _initTrace(void);
str abortRef;
str addOptimizerPipe(Client cntxt, MalBlkPtr mb, str name);
str addPipeDefinition(Client cntxt, str name, str pipe);
@@ -2116,7 +2112,7 @@ void chkFlow(stream *out, MalBlkPtr mb);
int chkInstruction(stream *out, Module s, MalBlkPtr mb, InstrPtr p);
void chkProgram(stream *out, Module s, MalBlkPtr mb);
void chkTypes(stream *out, Module s, MalBlkPtr mb, int silent);
-str cleanupProfiler(void);
+str cleanupTraces(void);
void clearStack(MalStkPtr s);
void clearTrace(void);
void clearVariable(MalBlkPtr mb, int varid);
@@ -2255,15 +2251,12 @@ int getOidConstant(MalBlkPtr mb, oid val
int getPC(MalBlkPtr mb, InstrPtr p);
str getPipeCatalog(bat *nme, bat *def, bat *stat);
str getPipeDefinition(str name);
-int getProfileCounter(int idx);
-stream *getProfilerStream(void);
str getRef;
str getScenarioLanguage(Client c);
int getShtConstant(MalBlkPtr mb, sht val);
int getStrConstant(MalBlkPtr mb, str val);
lng getSystemTime(void);
BAT *getTrace(const char *ev);
-int getTraceType(const char *nme);
malType getType(MalBlkPtr mb, str nme);
str getTypeIdentifier(malType tpe);
int getTypeIndex(str nme, int len, int deftpe);
@@ -2536,7 +2529,7 @@ void printStack(stream *f, MalBlkPtr mb,
str prodRef;
void profilerEvent(oid usr, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int
start);
void profilerGetCPUStat(lng *user, lng *nice, lng *sys, lng *idle, lng
*iowait);
-void profilerHeartbeatEvent(char *msg);
+void profilerHeartbeatEvent(char *alter);
str profilerRef;
str projectRef;
str projectdeltaRef;
@@ -2628,20 +2621,17 @@ str seriesRef;
str setAccessRef;
void setArgType(MalBlkPtr mb, InstrPtr p, int i, int tpe);
InstrPtr setArgument(MalBlkPtr mb, InstrPtr p, int idx, int varid);
-str setEndPoint(Module cntxt, const char *mod, const char *fcn);
void setHeartbeat(int delay);
Lifespan setLifespan(MalBlkPtr mb);
-str setLogFile(stream *fd, Module cntxt, const char *fname);
-str setLogStream(Module cntxt, const char *host, int port);
-str setLogStreamStream(Module cntxt, stream *s);
void setModuleJump(str nme, Module cur);
void setPolymorphic(InstrPtr p, int tpe, int force);
+str setProfilerStream(Module cntxt, const char *host, int port);
void setReturnArgument(InstrPtr p, int varid);
str setScenario(Client c, str nme);
-str setStartPoint(Module cntxt, const char *mod, const char *fcn);
void setVarName(MalBlkPtr mb, int i, str nme);
void setVarType(MalBlkPtr mb, int i, int tpe);
str setWriteModeRef;
+str setprofilerpoolsize(int size);
str shortStmtRendering(MalBlkPtr mb, MalStkPtr stl, InstrPtr p);
void showAllScenarios(stream *f);
void showCurrentScenario(void);
@@ -2673,10 +2663,8 @@ int sqlfunctionProp;
str srvpoolRef;
int stableProp;
str startProfiler(oid user, int mode, int beat);
-str startProfilerCache(void);
str startRef;
str stopProfiler(void);
-str stopProfilerCache(void);
str stopRef;
void strAfterCall(ValPtr v, ValPtr bak);
void strBeforeCall(ValPtr v, ValPtr bak);
diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -12,54 +12,69 @@
char *statenames[]= {"","start","done","action","ping","wait","system"};
-char *malarguments[MAXMALARGS];
char *maltypes[MAXMALARGS];
-int malpc[MAXMALARGS];
-int malcount[MAXMALARGS];
-int malargc;
-int malretc;
char *malvariables[MAXMALARGS];
-int malvartop;
+char *malvalues[MAXMALARGS];
+
+int malsize;
int debug=0;
-char *monetdb_characteristics;
+char *currentquery=0;
#ifndef HAVE_STRPTIME
extern char *strptime(const char *, const char *, struct tm *);
#include "strptime.c"
#endif
-void
+static void
clearArguments(void)
{
int i;
- for(i = 0; i < malargc; i++)
- if( malarguments[i]){
- free(malarguments[i]);
- malarguments[i] = 0;
+
+ if( currentquery){
+ free(currentquery);
+ currentquery = 0;
}
- malargc = 0;
- malretc = 0;
- for(i = 0; i < malvartop; i++)
- if( malvariables[i]){
- free(malvariables[i]);
- malvariables[i] = 0;
- free(maltypes[i]);
- maltypes[i] = 0;
+
+ for(i = 0; i < MAXMALARGS; i++){
+ if( malvariables[i]){
+ free(malvariables[i]);
+ malvariables[i] = 0;
+ }
+ if( malvalues[i]){
+ free(malvalues[i]);
+ malvalues[i] = 0;
+ }
+ if( maltypes[i]){
+ free(maltypes[i]);
+ maltypes[i] = 0;
+ }
}
- malvartop = 0;
+}
+
+static void
+dumpArguments(void)
+{
+ int i;
+ for( i=0; i < MAXMALARGS; i++)
+ if( maltypes[i])
+ printf("[%d] variable %s value %s type %s\n", i,
(malvariables[i]?malvariables[i]:""), malvalues[i], maltypes[i]);
}
char *
-stripQuotes(const char *currentquery)
+stripQuotes(char *currentquery)
{
const char *c;
char *q, *qry;
+ if( currentquery ==0)
+ return NULL;
q = qry = (char *) malloc(strlen(currentquery) * 2);
if( q == NULL){
fprintf(stderr,"Could not allocate query buffer of size
"SZFMT"\n", strlen(currentquery) * 2);
exit(-1);
}
- for (c= currentquery; *c; ){
+ c= currentquery;
+ if( *c == '"') c++;
+ for (; *c; ){
if ( strncmp(c,"\\\\t",3) == 0){
*q++ = '\t';
c+=3;
@@ -80,136 +95,6 @@ stripQuotes(const char *currentquery)
void
-eventdump(void)
-{ int i;
- fprintf(stderr,"Event analysis\n");
- for(i=0; i < malargc; i++)
- fprintf(stderr,"arg[%d] %s %s %d\n",i,malarguments[i],
maltypes[i], malcount[i]);
- for(i=0; i < malvartop; i++)
- fprintf(stderr,"var[%d] %s\n",i,malvariables[i]);
-}
-
-static void
-parseArguments(char *call, int m)
-{
- int argc= m < 0? -1:0;
- char *c = call, *l, ch;
- char *v, *w;
-
- if( debug)
- fprintf(stderr,"%s\n",call);
- // skip MAL keywords
- if( strncmp(c,"function ",10) == 0 ) c +=10;
- if( strncmp(c,"end ",4) == 0 ) c +=4;
- if( strncmp(c,"barrier ",8) == 0 ) c +=8;
- if( strncmp(c,"redo ",5) == 0 ) c +=5;
- if( strncmp(c,"leave ",6) == 0 ) c +=6;
- if( strncmp(c,"return ",7) == 0 ) c +=7;
- if( strncmp(c,"yield ",6) == 0 ) c +=6;
- if( strncmp(c,"catch ",6) == 0 ) c +=6;
- if( strncmp(c,"raise ",6) == 0 ) c +=6;
-
- if( *c == '(') c++;
- if (*c !=')')
- for( ; c && *c && malargc < MAXMALARGS; c++){
- if(isalpha((int)*c) && strncmp(c,"nil",3) &&
strncmp(c,"true",4) && strncmp(c,"false",5) ){
- // remember variable in its own structure, it ends with
=
- v= c;
- c= strchr(c,'=');
- if( c == 0)
- break;
- *c = 0;
- malvariables[malvartop++] = strdup(v);
- if( malvariables[malvartop-1] == NULL){
- fprintf(stderr,"Could not allocate memory\n");
- exit(-1);
- }
- *c = '=';
- c++;
- }
- // all arguments have a value
- if (*c && *c== '\\' && *(c+1) =='"'){
- c++; c++;
- // parse string skipping escapes
- for(l=c; *l; l++){
- if( *l =='\\' && *(l+1) =='\\' && *(l+2)
=='\\' && *(l+3) =='"') { l+=3; continue;}
- if( *l =='\\' && *(l+1) =='\\') { l++;
continue;}
- if( *l =='\\' && *(l+1) =='n') { l++;
continue;}
- if( *l =='\\' && *(l+1) =='t') { l++;
continue;}
- if( *l =='\\' && *(l+1) =='"') break;
- }
- *l= 0;
- malarguments[malargc] = strdup(c);
- if( malarguments[malargc] == NULL){
- fprintf(stderr,"Could not allocate memory\n");
- exit(-1);
- }
- c= l+1;
- // we skip to the type or end of term
- while( *c && *c != ':' && *c !=',' && *c !=')' && *c !=
';') c++;
- } else if(*c =='<') {
- // extract BAT count
- l=c;
- while(*c && *c != '>') c++;
- c++;
- *c =0;
- malarguments[malargc] = strdup(l);
- if( malarguments[malargc] == NULL){
- fprintf(stderr,"Could not allocate memory\n");
- exit(-1);
- }
- *c = '[';
- malcount[malargc]=atoi(c+1);
- while( *c && *c != ':' && *c !=',' && *c !=')' && *c !=
';') c++;
- if( *c == ';') break;
- } else if(*c) {
- l=c;
- while( *c && *c != ':' && *c !=',' && *c !=')' && *c !=
';') c++;
- ch = *c;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list