Changeset: 3e3cf3ef9c33 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3e3cf3ef9c33
Modified Files:
        clients/mapiclient/eventparser.c
        clients/mapiclient/eventparser.h
        clients/mapiclient/tachograph.c
        clients/mapiclient/tomograph.c
        monetdb5/mal/mal_profiler.c
Branch: default
Log Message:

Clean up and some re-naming.


diffs (300 lines):

diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -10,7 +10,7 @@
 
 #include "eventparser.h"
 
-char *statenames[]= 
{"","start","done","action","ping","wait","iostat","gccollect"};
+char *statenames[]= {"","start","done","action","ping","wait","system"};
 
 char *malarguments[MAXMALARGS];
 int malargtop;
@@ -148,10 +148,14 @@ eventparser(char *row, EventRecord *ev)
                return -3;
 
        /* skip pc tag */
-       {       // decode pc
+       {       // decode qry[pc]tag
+               char *nme = c;
                c= strchr(c+1,'[');
                if( c == 0)
                        return -4;
+               *c = 0;
+               ev->blk= strdup(nme);
+               *c = '[';
                ev->pc = atoi(c+1);
                c= strchr(c+1,']');
                if ( c == 0)
@@ -170,19 +174,19 @@ eventparser(char *row, EventRecord *ev)
        if (c == 0)
                return -5;
        if (strncmp(c + 1, "start", 5) == 0) {
-               ev->state = START;
+               ev->state = MDB_START;
                c += 6;
        } else if (strncmp(c + 1, "done", 4) == 0) {
-               ev->state = DONE;
+               ev->state = MDB_DONE;
                c += 5;
        } else if (strncmp(c + 1, "ping", 4) == 0) {
-               ev->state = PING;
+               ev->state = MDB_PING;
                c += 5;
-       } else if (strncmp(c + 1, "stat", 4) == 0) {
-               ev->state = IOSTAT;
-               c += 6;
+       } else if (strncmp(c + 1, "system", 6) == 0) {
+               ev->state = MDB_SYSTEM;
+               c += 5;
        } else if (strncmp(c + 1, "wait", 4) == 0) {
-               ev->state = WAIT;
+               ev->state = MDB_WAIT;
                c += 5;
        } else {
                ev->state = 0;
diff --git a/clients/mapiclient/eventparser.h b/clients/mapiclient/eventparser.h
--- a/clients/mapiclient/eventparser.h
+++ b/clients/mapiclient/eventparser.h
@@ -58,31 +58,32 @@
 #define MAXTHREADS 1048
 #define MAXBOX 32678    /* should be > MAXTHREADS */
 
-#define START 1
-#define DONE 2
-#define ACTION 3
-#define PING 4
-#define WAIT 5
-#define IOSTAT 6
-#define GCOLLECT 7
+#define  MDB_START 1
+#define  MDB_DONE 2
+#define  MDB_PING 3
+#define  MDB_WAIT 4
+#define  MDB_SYSTEM 5
+
 extern char *statenames[];
 
+// the break down of a profiler event message
 typedef struct  {
        int state;
-       int pc;
-       int tag;
-       lng eventnr;
-       int thread;
+       char *blk;      // name of MAL block
+       int pc;         // instruction counter in block
+       int tag;        // unique MAL block invocation tag
+       lng eventnr;// serial event number
+       int thread;     // worker thread involved
        lng clkticks;
        lng ticks;
        lng memory;
-       lng tmpspace;
+       lng tmpspace;   // size of temporary produced
        lng inblock;
        lng oublock;
        lng majflt;
        lng swaps;
        lng csw;
-       char *stmt;
+       char *stmt;     // MAL statement, cpu loads or commentary
        char *fcn;
        char *numa;
 } EventRecord;
diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c
--- a/clients/mapiclient/tachograph.c
+++ b/clients/mapiclient/tachograph.c
@@ -511,7 +511,7 @@ update(EventRecord *ev)
        char number[BUFSIZ]={0};
  
        /* handle a ping event, keep the current instruction in focus */
-       if (ev->state >= PING ) {
+       if (ev->state >= MDB_PING ) {
                // All state events are ignored
                return;
        }
@@ -541,7 +541,7 @@ update(EventRecord *ev)
        }
 
        /* monitor top level function brackets, we restrict ourselves to SQL 
queries */
-       if (!capturing && ev->state == START && ev->fcn && strncmp(ev->fcn, 
"function", 8) == 0) {
+       if (!capturing && ev->state == MDB_START && ev->fcn && strncmp(ev->fcn, 
"function", 8) == 0) {
                if( (i = sscanf(ev->fcn + 9,"user.s%d_%d",&uid,&qid)) != 2){
                        if( debug)
                                fprintf(stderr,"Start phase parsing %d, uid %d 
qid %d\n",i,uid,qid);
@@ -567,7 +567,7 @@ update(EventRecord *ev)
                return;
 
        /* start of instruction box */
-       if (ev->state == START ) {
+       if (ev->state == MDB_START ) {
                if(ev->fcn && strstr(ev->fcn,"querylog.define") ){
                        // extract a string argument
                        currentquery = malarguments[0];
@@ -682,7 +682,7 @@ update(EventRecord *ev)
                return;
        }
        /* end the instruction box */
-       if (ev->state == DONE ){
+       if (ev->state == MDB_DONE ){
                        
                if( ev->tag != currenttag)
                        return; // forget all except one query
@@ -720,7 +720,7 @@ update(EventRecord *ev)
                events[ev->pc].actual= ev->ticks;
                clearArguments();
        }
-       if (ev->state == DONE && ev->fcn && strncmp(ev->fcn, "function", 8) == 
0) {
+       if (ev->state == MDB_DONE && ev->fcn && strncmp(ev->fcn, "function", 8) 
== 0) {
                if (currentfunction && strcmp(currentfunction, ev->fcn+9) == 0) 
{
                        if( capturing == 0){
                                free(currentfunction);
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -772,11 +772,11 @@ showcpu(void)
        fprintf(gnudata, "set xrange ["LLFMT".0:"LLFMT".0]\n", startrange, 
(endrange? endrange:lastclktick - starttime));
        fprintf(gnudata, "set yrange [0:%d]\n", cpus);
        for (i = 0; i < topbox; i++)
-               j+=(box[i].state == PING);
+               j+=(box[i].state == MDB_PING);
        if( debug)
                fprintf(stderr,"Pings for cpu heat:%d\n",j);
        for (i = 0; i < topbox; i++)
-               if (box[i].state == PING) {
+               if (box[i].state == MDB_PING) {
                        // decode the cpu heat
                        j = 0;
                        s = box[i].stmt +1;
@@ -811,7 +811,7 @@ showio(void)
        lng max = 0;
 
        for (i = 0; i < topbox; i++)
-               if (box[i].clkend && box[i].state >= PING) {
+               if (box[i].clkend && box[i].state >= MDB_PING) {
                        if (box[i].inblock > max)
                                max = box[i].inblock;
                        if (box[i].oublock > max)
@@ -1122,7 +1122,7 @@ createTomogram(void)
 
        /* detect all different threads and assign them a row */
        for (i = 0; i < topbox; i++){
-               if (box[i].clkend && box[i].state != PING) {
+               if (box[i].clkend && box[i].state != MDB_PING) {
                        for (j = 0; j < top; j++)
                                if (rows[j] == box[i].thread)
                                        break;
@@ -1132,7 +1132,7 @@ createTomogram(void)
                                        fprintf(stderr,"Assign thread %d to 
%d\n", box[i].thread, top);
                                rows[top++] = box[i].thread;
                        }
-                       if( box[i].state != WAIT)
+                       if( box[i].state != MDB_WAIT)
                                updmap(i);
                }
        }
@@ -1178,16 +1178,12 @@ createTomogram(void)
                                        fprintf(gnudata, "set object %d 
rectangle from "LLFMT".0, %d.0 to "LLFMT".0, %d fillcolor rgb \"%s\" fillstyle 
solid 1.0 \n",
                                                object++, box[i].clkstart, 
box[i].row * 2 * h, box[i].clkend, box[i].row * 2 * h + h, 
colors[box[i].color].col);
                                break;
-                       case PING:
+                       case MDB_PING:
                                break;
-                       case WAIT:
+                       case MDB_WAIT:
                                fprintf(gnudata, "set object %d rectangle from 
"LLFMT".0, %d.0 to %.2f,%.2f front fillcolor rgb \"red\" fillstyle solid 1.0\n",
                                        object++, box[i].clkstart, box[i].row * 
2 * h+h/3, box[i].clkstart+ w /25.0, box[i].row *2 *h + h - 0.3 * h);
                                break;
-                       case GCOLLECT:
-                               fprintf(gnudata, "set object %d rectangle from 
"LLFMT".0, %d.0 to "LLFMT".0, %d fillcolor rgb \"green\" fillstyle solid 1.0 
\n",
-                                       object++, box[i].clkstart, box[i].row * 
2 * h +h/3, box[i].clkend, box[i].row * 2 * h + h-h/3);
-                               break;
                        }
 
 
@@ -1252,8 +1248,8 @@ update(char *line, EventRecord *ev)
                exit(0);
        }
        /* handle a ping event, keep the current instruction in focus */
-       if (ev->state >= PING ) {
-               if (cpus == 0 && ev->state == PING) {
+       if (ev->state >= MDB_PING ) {
+               if (cpus == 0 && ev->state == MDB_PING) {
                        char *s;
                        if( (s= ev->stmt,'[')) 
                                s++;
@@ -1278,8 +1274,6 @@ update(char *line, EventRecord *ev)
                box[idx].thread = ev->thread;
                //lastclk[thread] = clkticks-starttime;
                box[idx].clkend = box[idx].clkstart = ev->clkticks-starttime;
-               if (ev->state == GCOLLECT)
-                       box[idx].clkstart -= ev->ticks;
                box[idx].memend = box[idx].memstart = ev->memory;
                box[idx].footstart = box[idx].tmpspace = ev->tmpspace;
                box[idx].inblock = ev->inblock;
@@ -1296,7 +1290,7 @@ update(char *line, EventRecord *ev)
                        ping = idx;
                        return;
                }
-               box[idx].fcn = ev->state == PING? 
strdup("profiler.ping"):strdup("profiler.wait");
+               box[idx].fcn = ev->state == MDB_PING? 
strdup("profiler.ping"):strdup("profiler.wait");
                threads[ev->thread] = ++topbox;
                idx = threads[ev->thread];
                box[idx] = b;
@@ -1330,7 +1324,7 @@ update(char *line, EventRecord *ev)
        }
 
        /* monitor top level function brackets, we restrict ourselves to SQL 
queries */
-       if (!capturing && ev->state == START && ev->fcn && strncmp(ev->fcn, 
"function", 8) == 0) {
+       if (!capturing && ev->state == MDB_START && ev->fcn && strncmp(ev->fcn, 
"function", 8) == 0) {
                if( (i = sscanf(ev->fcn + 9,"user.s%d_%d",&uid,&qid)) != 2){
                        if( debug)
                                fprintf(stderr,"Start phase parsing %d, uid %d 
qid %d\n",i,uid,qid);
@@ -1361,7 +1355,7 @@ update(char *line, EventRecord *ev)
        if( tracefd)
                fprintf(tracefd,"%s\n",line);
        /* start of instruction box */
-       if (ev->state == START ) {
+       if (ev->state == MDB_START ) {
                if(debug)
                        fprintf(stderr, "Start box %s clicks "LLFMT" stmt %s 
thread %d idx %d box %d\n", (ev->fcn?ev->fcn:""), ev->clkticks,currentfunction, 
ev->thread,idx,topbox);
                box[idx].state = ev->state;
@@ -1409,7 +1403,7 @@ update(char *line, EventRecord *ev)
                return;
        }
        /* end the instruction box */
-       if (ev->state == DONE && ev->fcn && strncmp(ev->fcn, "function", 8) == 
0) {
+       if (ev->state == MDB_DONE && ev->fcn && strncmp(ev->fcn, "function", 8) 
== 0) {
                if (currentfunction && strcmp(currentfunction, ev->fcn+9) == 0) 
{
                        if( capturing == 0){
                                free(currentfunction);
@@ -1431,7 +1425,7 @@ update(char *line, EventRecord *ev)
                        return;
                }
        }
-       if (ev->state == DONE ){
+       if (ev->state == MDB_DONE ){
                if( box[idx].clkstart == 0){
                        // ignore incorrect pairs
                        if(debug) fprintf(stderr, "INCORRECT START\n");
@@ -1444,7 +1438,7 @@ update(char *line, EventRecord *ev)
                box[idx].memend = ev->memory;
                box[idx].tmpspace = ev->tmpspace;
                box[idx].ticks = ev->ticks;
-               box[idx].state = ACTION;
+               box[idx].state = MDB_DONE;
                box[idx].inblock = ev->inblock;
                box[idx].oublock = ev->oublock;
                box[idx].majflt = ev->majflt;
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
@@ -22,7 +22,6 @@
 #include "mal_debugger.h"
 
 stream *eventstream = 0;
-stream *progressstream = 0;
 
 static int offlineProfiling = FALSE;
 static int cachedProfiling = FALSE;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to