Changeset: a042c361d218 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a042c361d218
Added Files:
        monetdb5/optimizer/opt_profiler.c
        monetdb5/optimizer/opt_profiler.h
Modified Files:
        clients/mapiclient/eventparser.c
        clients/mapiclient/tachograph.c
        monetdb5/mal/mal_profiler.c
Branch: profiler
Log Message:

Reduce and reshuffle functionality.
Tachograph now only provides progressbar. MAL analysis belongs to profiler 
itself.


diffs (truncated from 728 to 300 lines):

diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -225,6 +225,7 @@ resetEventRecord(EventRecord *ev)
        if( ev->fcn) free(ev->fcn);
        if( ev->numa) free(ev->numa);
        memset( (char*) ev, 0, sizeof(EventRecord));
+       clearArguments();
 }
 
 /* simple json key:value object parser for event record.
@@ -233,7 +234,7 @@ resetEventRecord(EventRecord *ev)
  * Returns 1 if the closing bracket is found. 0 to continue, -1 upon error
  */
 #define skipto(C) { while(*c && *c != C) c++; if (*c != C) return -1;}
-#define skipstr() { c= strrchr(c, (int) '"'); if (*c != '"') return -1;}
+#define skipstr() { while (*c && *c !='"') {if (*c =='\\') c++;c++;} if (*c != 
'"') return -1;}
 int
 keyvalueparser(char *txt, EventRecord *ev)
 {
@@ -315,11 +316,12 @@ keyvalueparser(char *txt, EventRecord *e
        if( strstr(key,"majflt")) { ev->majflt= atol(val); return 0;}
        if( strstr(key,"swaps")) { ev->swaps= atol(val); return 0;}
        if( strstr(key,"nvcsw")) { ev->csw= atol(val); return 0;}
-       if( strstr(key,"stmt")) { ev->stmt= strdup(val); 
+       if( strstr(key,"stmt")) { 
+               ev->stmt= strdup(val); 
+               ev->fcn = strdup(val);
                c = ev->stmt;
-               parseArguments((*c ==')'?c++:c),-1);
+               parseArguments((*c =='('?c++:c),-1);
                malretc = malargc;
-               ev->fcn = strdup(val);
                c = strchr(ev->fcn, (int) '(');
                if (c) {
                        parseArguments(c+1,1);
diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c
--- a/clients/mapiclient/tachograph.c
+++ b/clients/mapiclient/tachograph.c
@@ -67,13 +67,10 @@
 
 static stream *conn = NULL;
 static char hostname[128];
-static char *prefix = "tachograph";
 static char *dbname;
-static int beat = 5000;
 static int delay = 0; // ms
 static Mapi dbh;
 static MapiHdl hdl = NULL;
-static int interactive = 1;
 static int capturing=0;
 static int lastpc;
 static int pccount;
@@ -96,61 +93,6 @@ typedef struct {
 Source *sources;       // original column name
 int srctop, srcmax;
 
-static void
-addSource(char *varname, char *sch, char *tbl, char *col)
-{
-       char buf[BUFSIZ];
-
-       if(srctop == srcmax){
-               if( srcmax == 0)
-                       sources = (Source *) malloc(2048 * sizeof(Source));
-               else
-                       sources = (Source *) realloc(sources, srcmax+2048);
-               srcmax+= 2048;
-       }
-       assert(sources);
-       sources[srctop].varname = strdup(varname);
-       snprintf(buf,BUFSIZ,"%s%s%s%s%s", (strcmp(sch,"sys")== 0? "": sch), 
(strcmp(sch,"sys")== 0? "": "."), tbl,(col?".":""),col?col:"");
-       sources[srctop].source = strdup(buf);
-       //fprintf(stderr,"addSource %s at %d  %s\n",varname, srctop, buf);
-       srctop++;
-}
-
-static void
-addSourcePair(char *varname, char *name)
-{
-       int i;
-
-       if( name ==0 ) return;
-       if( varname ==0 ) return;
-
-       if(srctop == srcmax){
-               if( srcmax == 0)
-                       sources = (Source *) malloc(1024 * sizeof(Source));
-               else
-                       sources = (Source *) realloc((void *)sources, 
(srcmax+1024) * sizeof(Source));
-               srcmax+= 1024;
-       }
-       for( i=0; i< srctop; i++)
-       if( strcmp(name, sources[i].varname)==0){
-               sources[srctop].varname = strdup(varname);
-               sources[srctop].source = strdup(sources[i].source);
-               srctop++;
-               return;
-       }
-}
-static char *
-fndSource(char *varname)
-{
-       int i;
-
-       if(debug)
-               fprintf(stderr,"fndSource %s\n",varname);
-       for( i=0; i< srctop; i++)
-       if( strcmp(varname, sources[i].varname)==0)
-               return strdup(sources[i].source);
-       return strdup(varname);
-}
 /*
  * Parsing the argument list of a MAL call to obtain un-quoted string values
  */
@@ -163,9 +105,6 @@ usageTachograph(void)
     fprintf(stderr, "  -u | --user=<user>\n");
     fprintf(stderr, "  -p | --port=<portnr>\n");
     fprintf(stderr, "  -h | --host=<hostname>\n");
-       fprintf(stderr, "  -b | --beat=<delay> in milliseconds (default 
5000)\n");
-       fprintf(stderr, "  -i | --interactive=<o | 1> show trace on stdout\n");
-    fprintf(stderr, "  -o | --output=<webfile>\n");
     fprintf(stderr, "  -w | --wait=<delay time> in milliseconds\n");
     fprintf(stderr, "  -? | --help\n");
        exit(-1);
@@ -204,9 +143,6 @@ size_t txtlength=0;
 static int querypool = QUERYPOOL;
 int queryid= 0;
 
-static FILE *tachomal;
-static FILE *tachostmt;
-
 static void resetTachograph(void){
        int i;
        if (debug)
@@ -229,10 +165,6 @@ static void resetTachograph(void){
        starttime = 0;
        finishtime = 0;
        duration =0;
-       fclose(tachomal);
-       tachomal = 0;
-       fclose(tachostmt);
-       tachostmt = 0;
        prevprogress = 0;
        txtlength =0;
        prevlevel=0;
@@ -265,191 +197,12 @@ rendertime(lng ticks, int flg)
 
 #define MSGLEN 100
 
-/*
- * Render the output of the stethoscope into a more user-friendly format.
- * This involves removal of MAL variables and possibly renaming the MAL 
functions
- * by more general alternatives.
- * If mode is set then we go for a minimal base-table related display
- */
-static struct{
-       char *name;
-       int length;
-       char *alias;
-       int newl;
-       int mode;
-}mapping[]={
-       {"algebra.leftfetchjoinPath", 25, "join",4, 0},
-       {"algebra.thetasubselect", 22, "select",6, 0},
-       {"algebra.leftfetchjoin", 21, "join",4, 0},
-       {"dataflow.language", 17,       "parallel", 8, 0},
-       {"algebra.subselect", 17, "select",6, 0},
-       {"sql.projectdelta", 16, "project",7, 0},
-       {"algebra.subjoin", 15, "join",4, 0},
-       {"language.pass(nil)", 18,      "release", 7, 0},
-       {"mat.packIncrement", 17, "pack",4, 0},
-       {"language.pass", 13,   "release", 7, 0},
-       {"aggr.subcount", 13,   "count", 5, 0},
-       {"sql.subdelta", 12, "project",7, 0},
-       {"bat.append", 10,      "append", 6, 0},
-       {"aggr.subavg", 11,     "average", 7, 0},
-       {"aggr.subsum", 11,     "sum", 3, 0},
-       {"aggr.submin", 11,     "minimum", 7, 0},
-       {"aggr.submax", 11,     "maximum", 7, 0},
-       {"aggr.count", 10,      "count", 5, 0},
-       {"calc.lng", 8, "long", 4, 0},
-       {"sql.bind", 8, "bind", 4, 0},
-       {"batcalc.hge", 11, "hugeint", 7, 0},
-       {"batcalc.dbl", 11, "real", 4, 0},
-       {"batcalc.flt", 11, "real", 4, 0},
-       {"batcalc.lng", 11, "bigint",6, 0},
-       {"batcalc.", 8, "", 0, 0},
-       {"calc.", 5, "", 0, 0},
-       {"sql.", 4,     "", 0, 0},
-       {"bat.", 4,     "", 0, 0},
-       {"aggr.", 5,    "", 0, 0},
-       {"group.sub", 9,        "", 0, 0},
-       {"group.", 6,   "", 0, 0},
-       {"mtime.", 6,   "", 0, 0},
-       {0,0,0,0,0}};
-
-static void
-renderArgs(char *c,  char *l, size_t len)
-{
-       char varname[BUFSIZ]={0}, *v=0;
-       char *limit = l + len-1;
-       int i;
-
-       // we always start at a parameter list
-       for(; *c && *c !=')' && l < limit; ){
-               varname[0] = 0;
-               if( *c == ',')*l++ = *c++;
-               // take out the variable name
-               if(isalpha((int)*c) || *c == '_' ){ 
-                       for( i = 0; i < BUFSIZ-1 && *c && (isalnum((int)*c) || 
*c=='_') ; i++)
-                               varname[i] = *c++;
-                       varname[i]=0;
-               }
-               // handle value part
-               if( *c == '=') c++;
-               // BAT result
-               if( *c == '<'){
-                       while(*c && *c !='>') c++;
-                       if(*c) c++;
-                       if (varname[0]){
-                               v= fndSource(varname);
-                               l+= snprintf(l, limit - l-2,"%s",v);
-                               free(v);
-                       }
-                       // copy the count
-                       while(*c && *c !=']' && l < limit -2) *l++ = *c++;
-                       while(*c && *c != ']') c++;
-                       if( *c == ']' ) *l++ = *c++;
-                       while(*c && *c != ':') c++;
-               } else
-               // string constant
-               if (*c == '"' ) {
-                       *l++ = *c++;
-                       while(*c && *c !='"' && *(c-1) !='\\' && l < limit-2 ) 
*l++ =*c++;
-                       while(*c && *c !='"') c++;
-               }  else{
-               // all else
-                       while(*c && *c !=':' && *c !=',' && l < limit-2) *l++ = 
*c++;
-                       while(*c && *c !=':' && *c !=',' )  c++;
-               }
-               // skip type descriptor
-               if (*c == ':'){
-                       if( strncmp(c,":bat",4)== 0){
-                               while(*c && *c !=']') c++;
-                               if( *c == ']') c++;
-                       } 
-                       while(*c && *c != ',' && *c != '{' && *c != ')') c++;
-               }
-
-               // copy the literals
-               if( strcmp(varname,"nil") == 0 || strcmp(varname,"true")==0 || 
strcmp(varname,"false")==0)
-                       for(v = varname; *v; ) *l++ = *v++;
-               // drop the properties
-               if( *c == '{'){
-                       while(*c && *c !='}') c++;
-                       if(*c) c++;
-               }
-       }
-       if(*c) *l++ = *c;
-       *l=0;
-}
-
-static void
-renderCall(char *line, int len, char *stmt, int state, int mode)
-{
-       char *limit= line + len, *l = line, *c = stmt, *s;
-       int i;
-
-       (void) state;
-       // skip MAL keywords
-       if( strncmp(c,"function ",10) == 0 ) {
-               while( *c && l < limit -1) *l++ = *c++;
-               *l = 0;
-               return;
-       }
-       if( strncmp(c,"end ",4) == 0 ) {
-               while( *c && l < limit -1) *l++ = *c++;
-               *l = 0;
-               return;
-       }
-       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;
-       stmt = c;
-       // look for assignment
-       c = strstr(c," :=");
-       if( c) {
-               if(state){
-                       // for finished instructions show the result targets too
-                       *c =0;
-                       s = stmt;
-                       while(*s && isspace((int) *s)) s++;
-                       if( *s == '(') *l++ = *s++;
-                       renderArgs(s, l, limit - l);
-                       while(*l) l++;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to