Changeset: 2de4e6285792 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2de4e6285792
Modified Files:
monetdb5/mal/mal_client.h
monetdb5/mal/mal_instruction.h
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
monetdb5/mal/mal_runtime.c
monetdb5/mal/mal_stack.h
monetdb5/modules/mal/batExtensions.c
monetdb5/modules/mal/profiler.c
monetdb5/modules/mal/profiler.mal
Branch: mutation
Log Message:
Merge with Default
diffs (truncated from 304 to 300 lines):
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -89,10 +89,9 @@ typedef struct CLIENT {
* For program debugging we need information on the timer and memory
* usage patterns.
*/
- sht flags; /* resource tracing flags */
+ sht flags; /* resource tracing flags, should be done using
profiler */
BUN cnt; /* bat count */
-#define footprintFlag 16
time_t login;
time_t lastcmd; /* set when input is received */
lng qtimeout; /* query abort after x milliseconds */
diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h
--- a/monetdb5/mal/mal_instruction.h
+++ b/monetdb5/mal/mal_instruction.h
@@ -107,9 +107,9 @@ typedef struct PERF {
struct tms timer; /* timing information */
#endif
struct timeval clock; /* clock */
- lng clk; /* microseconds clock */
+ lng clk; /* time when
instruction started */
lng ticks; /* micro seconds spent
on last call */
- lng totalticks; /* accumulate micro seconds
send on this call */
+ lng totalticks; /* accumulate micro seconds
send on this instruction */
int calls; /* number of calls seen
*/
bit trace; /* facilitate
filter-based profiling */
lng rbytes; /* bytes read by an
instruction */
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -492,6 +492,7 @@ str runMALsequence(Client cntxt, MalBlkP
int exceptionVar;
str ret = 0, localGDKerrbuf= GDKerrbuf;
int stamp = -1;
+ lng clk=0;
ValRecord backups[16];
ValPtr backup;
int garbages[16], *garbage;
@@ -544,7 +545,7 @@ str runMALsequence(Client cntxt, MalBlkP
runtimeProfileBegin(cntxt, mb, stk, stkpc, &runtimeProfile, 1);
if (pci->recycle > 0)
- stk->clk = GDKms();
+ clk = GDKms();
if (!RECYCLEentry(cntxt, mb, stk, pci)){
/* The interpreter loop
* The interpreter is geared towards execution a MAL procedure together
@@ -758,7 +759,7 @@ str runMALsequence(Client cntxt, MalBlkP
/* If needed recycle intermediate result */
if (pci->recycle > 0) {
- RECYCLEexit(cntxt, mb, stk, pci,
stk->clk);
+ RECYCLEexit(cntxt, mb, stk, pci, clk);
}
/* general garbage collection */
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
@@ -65,29 +65,6 @@ static int profileAll = 0; /* all instr
static int delayswitch = 0; /* to wait before sending the profile info */
static int eventcounter = 0;
-#define PROFevent 0
-#define PROFtime 1
-#define PROFthread 2
-#define PROFpc 3
-#define PROFfunc 4
-#define PROFticks 5
-#define PROFcpu 6
-#define PROFmemory 7
-#define PROFreads 8
-#define PROFwrites 9
-#define PROFrbytes 10
-#define PROFwbytes 11
-#define PROFstmt 12
-#define PROFaggr 13
-#define PROFprocess 14
-#define PROFuser 15
-#define PROFstart 16
-#define PROFtype 17
-#define PROFdot 18
-#define PROFflow 19
-#define PROFping 20 /* heartbeat ping messages */
-#define PROFfootprint 21
-
static struct {
str name; /* which logical counter is needed */
int status; /* trace it or not */
@@ -117,6 +94,11 @@ static struct {
/* 21 */ { 0, 0}
};
+int
+getProfileCounter(int idx){
+ return profileCounter[idx].status ==1;
+}
+
/*
* The counters can be set individually.
*/
diff --git a/monetdb5/mal/mal_profiler.h b/monetdb5/mal/mal_profiler.h
--- a/monetdb5/mal/mal_profiler.h
+++ b/monetdb5/mal/mal_profiler.h
@@ -57,8 +57,32 @@ typedef struct RECSTAT {
int RPreset0; /* Number of instructions evicted from RP by reset()
due to updates*/
} *RecPtr, RecStat;
+#define PROFevent 0
+#define PROFtime 1
+#define PROFthread 2
+#define PROFpc 3
+#define PROFfunc 4
+#define PROFticks 5
+#define PROFcpu 6
+#define PROFmemory 7
+#define PROFreads 8
+#define PROFwrites 9
+#define PROFrbytes 10
+#define PROFwbytes 11
+#define PROFstmt 12
+#define PROFaggr 13
+#define PROFprocess 14
+#define PROFuser 15
+#define PROFstart 16
+#define PROFtype 17
+#define PROFdot 18
+#define PROFflow 19
+#define PROFping 20 /* heartbeat ping messages */
+#define PROFfootprint 21
+
mal_export str activateCounter(str name);
mal_export str deactivateCounter(str name);
+mal_export int getProfileCounter(int idx);
mal_export str openProfilerStream(stream *fd);
mal_export str closeProfilerStream(void);
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
@@ -127,33 +127,42 @@ runtimeProfileFinish(Client cntxt, MalBl
void
runtimeProfileBegin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int stkpc,
RuntimeProfile prof, int start)
{
+ if ( mb->profiler == NULL)
+ return;
+
/* always collect the MAL instruction execution time */
- if ( mb->profiler)
- mb->profiler[stkpc].ticks = GDKusec();
prof->stkpc = stkpc;
+ mb->profiler[stkpc].clk = GDKusec();
if (malProfileMode == 0)
return; /* mostly true */
- if (stk && mb->profiler != NULL && mb->profiler[stkpc].trace) {
+ if (stk && mb->profiler[stkpc].trace) {
gettimeofday(&mb->profiler[stkpc].clock, NULL);
/* emit the instruction upon start as well */
profilerEvent(cntxt->idx, mb, stk, stkpc, start);
#ifdef HAVE_TIMES
- times(&stk->timer);
- mb->profiler[stkpc].timer = stk->timer;
+ times(&mb->profiler[stkpc].timer);
#endif
- mb->profiler[stkpc].clk = mb->profiler[stkpc].ticks;
}
}
-
void
runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
RuntimeProfile prof)
{
- int i,j,fnd, stkpc = prof->stkpc;
+ int i,j,fnd, stkpc;
- if (cntxt->flags & footprintFlag && pci){
+ if ( mb->profiler == NULL)
+ return;
+
+ /* always collect the MAL instruction execution time */
+ stkpc= prof->stkpc;
+ mb->profiler[stkpc].ticks = GDKusec() - mb->profiler[stkpc].clk;
+
+ if (malProfileMode == 0)
+ return; /* mostly true */
+
+ if (getProfileCounter(PROFfootprint) && pci){
for (i = 0; i < pci->retc; i++)
if ( isaBatType(getArgType(mb,pci,i)) &&
stk->stk[getArg(pci,i)].val.bval){
/* avoid simple alias operations */
@@ -166,21 +175,16 @@ 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 ) {
+ if (stk != NULL && stkpc >= 0 && mb->profiler[stkpc].trace ) {
gettimeofday(&mb->profiler[stkpc].clock, NULL);
mb->profiler[stkpc].calls++;
mb->profiler[stkpc].totalticks += mb->profiler[stkpc].ticks;
- 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);
+ // it is a potential expensive operation
+ if (getProfileCounter(PROFrbytes))
+ mb->profiler[stkpc].rbytes = getVolume(stk,
pci, 0);
+ if (getProfileCounter(PROFwbytes))
+ mb->profiler[stkpc].wbytes = getVolume(stk,
pci, 1);
}
profilerEvent(cntxt->idx, mb, stk, stkpc, 0);
}
diff --git a/monetdb5/mal/mal_stack.h b/monetdb5/mal/mal_stack.h
--- a/monetdb5/mal/mal_stack.h
+++ b/monetdb5/mal/mal_stack.h
@@ -55,11 +55,7 @@ typedef struct MALSTK {
* It is handy to administer the timing in the stack frame
* for use in profiling and recylcing instructions.
*/
-#ifdef HAVE_TIMES
- struct tms timer; /* timing information */
-#endif
struct timeval clock; /* time this stack was created */
- lng clk; /* micro seconds, used by ? */
char cmd; /* debugger and runtime communication */
char status; /* srunning 'R' uspended 'S', quiting 'Q' */
int pcup; /* saved pc upon a recursive all */
diff --git a/monetdb5/modules/mal/batExtensions.c
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -261,7 +261,7 @@ CMDbatpartition2(Client cntxt, MalBlkPtr
else
hval = lval+step;
bn = BATslice(b, lval,hval);
- BATseqbase(bn, lval);
+ BATseqbase(bn, lval + b->hseqbase) ;
if (bn== NULL){
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.partition", INTERNAL_OBJ_CREATE);
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
@@ -358,26 +358,6 @@ CMDgetSystemTime(lng *ret)
}
str
-CMDsetFootprintFlag( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){
- (void) mb;
- (void) stk;
- (void) pci;
- cntxt->flags |= footprintFlag;
- return MAL_SUCCEED;
-}
-
-str
-CMDgetFootprint( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){
- lng *l= getArgReference(stk,pci,0);
-
- (void) cntxt;
- (void) mb;
- *l = stk->tmpspace;
- cntxt->flags &= ~footprintFlag; // clear it as well
- return MAL_SUCCEED;
-}
-
-str
CMDtomograph(int *ret)
{
(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
@@ -119,20 +119,6 @@ command getSystemTime():lng
address CMDgetSystemTime
comment "Obtain the user timing information.";
-pattern setFootprintFlag{unsafe}():void
-address CMDsetFootprintFlag
-comment "Trace memory footprint of BATs during query";
-pattern setMemoryFlag{unsafe}():void
-address CMDsetMemoryFlag
-comment "Trace memory accress";
-
-pattern getFootprint():lng
-address CMDgetFootprint
-comment "Get the memory footprint and reset the flag";
-pattern getMemory():lng
-address CMDgetMemory
-comment "Get the amount of memory claimed and reset the flag";
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list