Changeset: 174770a15c74 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=174770a15c74
Modified Files:
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_runtime.h
Branch: default
Log Message:

Collect timing information when profiler structure exists
This is a preparatory step for adaptive parallelism, where
we need the timing always, without issuing full profiler events.


diffs (105 lines):

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
@@ -389,7 +389,7 @@ offlineProfilerEvent(int idx, MalBlkPtr 
                logadd("%d,\t", getPC(mb, pci));
        }
        if (profileCounter[PROFticks].status) {
-               logadd(LLFMT ",\t", mb->profiler[pc].ticks);
+               logadd(LLFMT ",\t", start? 0: mb->profiler[pc].ticks);
        }
 #ifdef HAVE_TIMES
        if (profileCounter[PROFcpu].status && delayswitch < 0) {
@@ -690,13 +690,16 @@ setFilterOnBlock(MalBlkPtr mb, str mod, 
        InstrPtr p;
 
        initProfiler(mb);
+       if ( profileAll )
+               for (k = 0; k < mb->stop; k++)
+                       mb->profiler[k].trace = 1;
+       else
        for (k = 0; k < mb->stop; k++) {
                p = getInstrPtr(mb, k);
                cnt = 0;
                for (i = 0; i < topFilter; i++)
                        cnt += instrFilter(p, modFilter[i], fcnFilter[i]);
-               mb->profiler[k].trace = profileAll || cnt ||
-                                                               (mod && fcn && 
instrFilter(p, mod, fcn));
+               mb->profiler[k].trace = cnt || (mod && fcn && instrFilter(p, 
mod, fcn));
        }
 }
 
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
@@ -63,7 +63,7 @@ runtimeProfileInit(Client cntxt, MalBlkP
        int i;
        str q;
 
-       if (malProfileMode)
+       if ( malProfileMode )
                setFilterOnBlock(mb, 0, 0);
 
        MT_lock_set(&mal_delayLock, "sysmon");
@@ -127,14 +127,15 @@ runtimeProfileFinish(Client cntxt, MalBl
 void
 runtimeProfileBegin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int stkpc, 
RuntimeProfile prof, int start)
 {
+       /* always collect the MAL instruction execution time */
+       if ( mb->profiler)
+               mb->profiler[stkpc].ticks = GDKusec();
+
        if (malProfileMode == 0)
                return; /* mostly true */
        
        prof->stkpc = stkpc;
        if (stk && mb->profiler != NULL && mb->profiler[stkpc].trace) {
-               prof->newclk = stk->clk = GDKusec();
-               mb->profiler[stkpc].clk = 0;
-               mb->profiler[stkpc].ticks = 0;
                gettimeofday(&mb->profiler[stkpc].clock, NULL);
                /* emit the instruction upon start as well */
                profilerEvent(cntxt->idx, mb, stk, stkpc, start);
@@ -142,7 +143,7 @@ runtimeProfileBegin(Client cntxt, MalBlk
                times(&stk->timer);
                mb->profiler[stkpc].timer = stk->timer;
 #endif
-               mb->profiler[stkpc].clk = prof->newclk;
+               mb->profiler[stkpc].clk = mb->profiler[stkpc].ticks;
        }
 }
 
@@ -165,16 +166,18 @@ runtimeProfileExit(Client cntxt, MalBlkP
                        }
        }
 
+       /* always collect the MAL instruction execution time */
+       if ( mb->profiler)
+               mb->profiler[stkpc].ticks = GDKusec() - 
mb->profiler[stkpc].ticks;
+
        if (malProfileMode == 0)
                return; /* mostly true */
 
-       if (stk != NULL && prof->stkpc >= 0 && mb->profiler != NULL && 
-               mb->profiler[stkpc].trace && mb->profiler[stkpc].clk) {
+       if (stk != NULL && prof->stkpc >= 0 && mb->profiler != NULL && 
mb->profiler[stkpc].trace ) {
                gettimeofday(&mb->profiler[stkpc].clock, NULL);
                mb->profiler[stkpc].counter++;
-               mb->profiler[stkpc].ticks = GDKusec() - prof->newclk;
                mb->profiler[stkpc].totalticks += mb->profiler[stkpc].ticks;
-               mb->profiler[stkpc].clk += mb->profiler[stkpc].clk;
+               mb->profiler[stkpc].clk += mb->profiler[stkpc].ticks;
                if (pci) {
                        mb->profiler[stkpc].rbytes = getVolume(stk, pci, 0);
                        mb->profiler[stkpc].wbytes = getVolume(stk, pci, 1);
diff --git a/monetdb5/mal/mal_runtime.h b/monetdb5/mal/mal_runtime.h
--- a/monetdb5/mal/mal_runtime.h
+++ b/monetdb5/mal/mal_runtime.h
@@ -29,7 +29,6 @@
  * We need to maintain some state from ProfileBegin
 */
 typedef struct{
-       lng newclk;
        int stkpc;      
 } *RuntimeProfile, RuntimeProfileRecord;
 
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to