Changeset: 442f23ba3025 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=442f23ba3025
Modified Files:
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
monetdb5/mal/mal_runtime.c
monetdb5/mal/mal_runtime.h
Branch: default
Log Message:
Introduce the temporary space and drop mdb profiler
The runtime operations also get the instruction and maintain
the total space allocated during a MAL block execution.
The olf fashioned performance profiling in the MAL debugger
has been turned off, as we have better tools for that nowadays
(stethoscope, --trace, and tomograph)
diffs (truncated from 405 to 300 lines):
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
@@ -376,7 +376,7 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
runtimeProfileBegin(cntxt, mb, stk, 0, &runtimeProfile, 1);
ret = runMALsequence(cntxt, mb, 1, 0, stk, env, 0);
runtimeProfile.ppc = 0; /* also finalize function call event */
- runtimeProfileExit(cntxt, mb, stk, &runtimeProfile);
+ runtimeProfileExit(cntxt, mb, stk, 0, &runtimeProfile);
/* pass the new debug mode to the caller */
if (stk->cmd && env && stk->cmd != 'f')
@@ -468,7 +468,7 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS
runtimeProfileBegin(cntxt, mb, stk, 0, &runtimeProfile, 1);
ret = runMALsequence(cntxt, mb, 1, 0, stk, 0, 0);
runtimeProfile.ppc = 0; /* also finalize function call event */
- runtimeProfileExit(cntxt, mb, stk, &runtimeProfile);
+ runtimeProfileExit(cntxt, mb, stk, pci, &runtimeProfile);
break;
case FACTORYsymbol:
case FACcall:
@@ -507,8 +507,8 @@ str runMALsequence(Client cntxt, MalBlkP
int garbages[16], *garbage;
lng oldtimer = 0;
int stkpc = 0;
- MT_Lock *lock = NULL;
- int tid = 0;
+ //MT_Lock *lock = NULL;
+ //int tid = 0;
RuntimeProfileRecord runtimeProfile, runtimeProfileFunction;
runtimeProfileInit(mb, &runtimeProfile, cntxt->flags & memoryFlag);
@@ -729,7 +729,7 @@ str runMALsequence(Client cntxt, MalBlkP
ret = shutdownFactory(cntxt, mb);
if (oldtimer)
cntxt->timer = oldtimer;
- runtimeProfileExit(cntxt, mb, stk,
&runtimeProfile);
+ runtimeProfileExit(cntxt, mb, stk, pci,
&runtimeProfile);
if (pcicaller && garbageControl(getInstrPtr(mb,
0)))
garbageCollector(cntxt, mb, stk, TRUE);
runtimeProfile.ppc = 0; /* also finalize
function call event */
@@ -758,8 +758,8 @@ str runMALsequence(Client cntxt, MalBlkP
/* monitoring information should reflect the input
arguments,
which may be removed by garbage collection */
- runtimeProfileExit(cntxt, mb, stk, &runtimeProfile);
- runtimeTiming(cntxt, mb, stk, pci, tid, lock,
&runtimeProfile);
+ runtimeProfileExit(cntxt, mb, stk, pci,
&runtimeProfile);
+ //runtimeTiming(cntxt, mb, stk, pci, tid, lock,
&runtimeProfile);
/* check for strong debugging after each MAL statement
*/
if ( pci->token != FACcall && ret== MAL_SUCCEED) {
if (GDKdebug & (CHECKMASK|PROPMASK) &&
exceptionVar < 0) {
@@ -882,7 +882,7 @@ str runMALsequence(Client cntxt, MalBlkP
/* unknown exceptions lead to propagation */
if (exceptionVar == -1) {
- runtimeProfileExit(cntxt, mb, stk,
&runtimeProfile);
+ runtimeProfileExit(cntxt, mb, stk, pci,
&runtimeProfile);
if (cntxt->qtimeout && time(NULL) -
stk->clock.tv_usec > cntxt->qtimeout)
ret= createException(MAL,
"mal.interpreter", RUNTIME_QRY_TIMEOUT);
stkpc = mb->stop;
@@ -1116,7 +1116,7 @@ str runMALsequence(Client cntxt, MalBlkP
}
if (stkpc == mb->stop) {
runtimeProfile.ppc = 0; /* also finalize
function call event */
- runtimeProfileExit(cntxt, mb, stk,
&runtimeProfile);
+ runtimeProfileExit(cntxt, mb, stk, pci,
&runtimeProfile);
break;
}
if (stkpc == mb->stop)
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
@@ -417,7 +417,7 @@ offlineProfilerEvent(int idx, MalBlkPtr
*/
}
if (profileCounter[PROFfootprint].status) {
- logadd(LLFMT",\t", getFootPrint(mb,stk)/1024/1024);
+ logadd(LLFMT",\t", stk->tmpspace);
}
#ifdef HAVE_SYS_RESOURCE_H
if ((profileCounter[PROFreads].status ||
@@ -864,22 +864,17 @@ TRACEcreate(str hnme, str tnme, int tt)
snprintf(buf, 128, "trace_%s_%s", hnme, tnme);
b = BATdescriptor(BBPindex(buf));
- if (b) {
- if (b->htype == TYPE_int)
- /* old code */
- BBPreclaim(b);
- else
- return b;
- }
+ if (b)
+ return b;
b = BATnew(TYPE_void, tt, 1 << 16);
if (b == NULL)
return NULL;
+ BATmode(b, PERSISTENT);
BATseqbase(b, 0);
BATkey(b, TRUE);
BBPrename(b->batCacheid, buf);
- BATmode(b, PERSISTENT);
BATcommit(b);
return b;
}
@@ -1275,9 +1270,9 @@ static int getCPULoad(char cpuload[BUFSI
s +=3;
if ( *s == ' ') {
s++;
- goto skip;
- }
- cpu = atoi(s);
+ cpu = 255; // the cpu totals stored here
+ } else
+ cpu = atoi(s);
s= strchr(s,' ');
if ( s== 0) goto skip;
@@ -1287,7 +1282,7 @@ static int getCPULoad(char cpuload[BUFSI
goto skip;
newload = (user - corestat[cpu].user + nice -
corestat[cpu].nice + system - corestat[cpu].system);
if ( newload)
- corestat[cpu].load = (double) newload /
(newload + idle - corestat[cpu].idle);
+ corestat[cpu].load = (double) newload /
(newload + idle - corestat[cpu].idle + iowait - corestat[cpu].iowait);
corestat[cpu].user = user;
corestat[cpu].nice = nice;
corestat[cpu].system = system;
@@ -1299,7 +1294,8 @@ static int getCPULoad(char cpuload[BUFSI
s= cpuload;
len = BUFSIZ;
- for ( cpu = 0; cpu < 256 && corestat[cpu].user; cpu++) {
+ // identify core processing
+ for ( cpu = 0; cpuload && cpu < 255 && corestat[cpu].user; cpu++) {
snprintf(s, len, " %.2f ",corestat[cpu].load);
len -= (int)strlen(s);
s += (int) strlen(s);
@@ -1307,6 +1303,16 @@ static int getCPULoad(char cpuload[BUFSI
return 0;
}
+void profilerGetCPUStat(lng *user, lng *nice, lng *sys, lng *idle, lng *iowait)
+{
+ (void) getCPULoad(0);
+ *user = corestat[255].user;
+ *nice = corestat[255].nice;
+ *sys = corestat[255].system;
+ *idle = corestat[255].idle;
+ *iowait = corestat[255].iowait;
+}
+
void profilerHeartbeatEvent(str msg)
{
char logbuffer[LOGLEN], *logbase;
@@ -1398,9 +1404,8 @@ void profilerHeartbeatEvent(str msg)
logadd("%ld,\t", infoUsage.ru_oublock - prevUsage.ru_oublock);
prevUsage = infoUsage;
}
- if (profileCounter[PROFfootprint].status) {
- logadd(LLFMT",\t", getFootPrint(0,0)/1024/1024);
- }
+ if (profileCounter[PROFfootprint].status)
+ logadd("0,\t");
if (profileCounter[PROFprocess].status && delayswitch < 0) {
logadd("%ld,\t", infoUsage.ru_minflt - prevUsage.ru_minflt);
logadd("%ld,\t", infoUsage.ru_majflt - prevUsage.ru_majflt);
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
@@ -101,6 +101,7 @@ mal_export lng getDiskReads(void);
mal_export lng getDiskWrites(void);
mal_export lng getUserTime(void);
mal_export lng getSystemTime(void);
+mal_export void profilerGetCPUStat(lng *user, lng *nice, lng *sys, lng *idle,
lng *iowait);
mal_export void _initTrace(void);
#endif
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
@@ -56,12 +56,12 @@ void
runtimeProfileBegin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int stkpc,
RuntimeProfile prof, int start)
{
if (malProfileMode == 0)
- /* mostly true */;
- else
+ return; /* mostly true */
+
if (stk && mb->profiler != NULL) {
prof->newclk = stk->clk = GDKusec();
if (mb->profiler[stkpc].trace) {
- MT_lock_set(&mal_contextLock, "DFLOWdelay");
+ MT_lock_set(&mal_delayLock, "DFLOWdelay");
gettimeofday(&stk->clock, NULL);
prof->ppc = stkpc;
mb->profiler[stkpc].clk = 0;
@@ -75,92 +75,50 @@ runtimeProfileBegin(Client cntxt, MalBlk
mb->profiler[stkpc].timer = stk->timer;
#endif
mb->profiler[stkpc].clk = stk->clk;
- MT_lock_unset(&mal_contextLock, "DFLOWdelay");
+ MT_lock_unset(&mal_delayLock, "DFLOWdelay");
}
}
}
void
-runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, RuntimeProfile
prof)
+runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
RuntimeProfile prof)
{
- int stkpc = prof->ppc;
+ int i,j,fnd, stkpc = prof->ppc;
+
+ if (cntxt->flags & footprintFlag && 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 */
+ fnd= 0;
+ for ( j= pci->retc; j< pci->argc; j++)
+ if ( isaBatType(getArgType(mb,pci,j)))
+ fnd+=
stk->stk[getArg(pci,i)].val.bval == stk->stk[getArg(pci,j)].val.bval;
+ if (fnd == 0 )
+ updateFootPrint(mb,stk,getArg(pci,i));
+ }
+ }
+
if (malProfileMode == 0)
- /* mostly true */;
- else if (stk != NULL && prof->ppc >= 0 && mb->profiler != NULL &&
mb->profiler[stkpc].trace && mb->profiler[stkpc].clk)
+ return; /* mostly true */
+ if (stk != NULL && prof->ppc >= 0 && mb->profiler != NULL &&
mb->profiler[stkpc].trace && mb->profiler[stkpc].clk)
{
+ MT_lock_set(&mal_contextLock, "DFLOWdelay");
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;
- if (stkpc) {
- mb->profiler[stkpc].rbytes = getVolume(stk,
getInstrPtr(mb, stkpc), 0);
- mb->profiler[stkpc].wbytes = getVolume(stk,
getInstrPtr(mb, stkpc), 1);
+ if (pci) {
+ mb->profiler[stkpc].rbytes = getVolume(stk, pci, 0);
+ mb->profiler[stkpc].wbytes = getVolume(stk, pci, 1);
}
profilerEvent(cntxt->idx, mb, stk, stkpc, 0);
prof->ppc = -1;
+ MT_lock_unset(&mal_contextLock, "DFLOWdelay");
}
}
-void
-runtimeTiming(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int
tid, MT_Lock *lock, RuntimeProfile prof)
-{
- str line;
- if (cntxt->flags && stk->cmd != '\0' && stk->cmd != 't' && stk->cmd !=
'C') {
- if (lock)
- MT_lock_set(lock, "timing");
- mnstr_printf(cntxt->fdout, "= "); /* single column rendering
*/
- if (cntxt->flags & timerFlag) {
- char buf[32];
- snprintf(buf, sizeof(buf), LLFMT, GDKusec() -
cntxt->timer);
- mnstr_printf(cntxt->fdout, "%8s usec ", buf);
- }
- if (cntxt->flags & threadFlag)
- mnstr_printf(cntxt->fdout, "@%d ", tid);
-#ifdef HAVE_SYS_RESOURCE_H
- if (cntxt->flags & ioFlag) {
- struct rusage resource;
- getrusage(RUSAGE_SELF, &resource);
- mnstr_printf(cntxt->fdout, " %3ld R",
- resource.ru_inblock);
- mnstr_printf(cntxt->fdout, " %3ld W ",
- resource.ru_oublock);
- }
-#endif
- if (cntxt->flags & memoryFlag) {
- struct Mallinfo memory;
- memory = MT_mallinfo();
- if (memory.arena)
- mnstr_printf(cntxt->fdout, " " SZFMT " bytes ",
- (size_t) (memory.arena -
prof->memory.arena));
- prof->memory.arena = memory.arena;
- }
- if (cntxt->flags & flowFlag) {
- /* calculate the read/write byte flow */
- displayVolume(cntxt, getVolume(stk, pci, 0));
- mnstr_printf(cntxt->fdout, "/");
- displayVolume(cntxt, getVolume(stk, pci, 1));
- mnstr_printf(cntxt->fdout, " ");
- }
- if (cntxt->flags & footprintFlag)
- displayVolume(cntxt, getFootPrint(mb,stk));
- if (cntxt->flags & cntFlag) {
- char buf[32];
- snprintf(buf, sizeof(buf), OIDFMT, cntxt->cnt);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list