Changeset: a8e201d5e2b4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8e201d5e2b4
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
monetdb5/modules/mal/profiler.c
monetdb5/modules/mal/profiler.h
monetdb5/modules/mal/profiler.mal
monetdb5/optimizer/opt_prelude.c
monetdb5/optimizer/opt_prelude.h
sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:
Fix concurrent sql trace and stethoscope
Both can run at the same time, becaue the SQL part simply
keeps the trace for later inspection in a table.
Furthermore, you can not 'steal' a profiler stream anymore.
diffs (234 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -39756,6 +39756,14 @@ command profiler.setheartbeat(b:int):voi
address CMDsetHeartbeat;
comment Set heart beat performance tracing
+command profiler.stoptrace():void
+address CMDstopTrace;
+comment Stop collecting trace information
+
+command profiler.starttrace():void
+address CMDstartTrace;
+comment Start collecting trace information
+
pattern profiler.stop():void
address CMDstopProfiler;
comment Stop offline performance profiling
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -50615,6 +50615,14 @@ command profiler.setheartbeat(b:int):voi
address CMDsetHeartbeat;
comment Set heart beat performance tracing
+command profiler.stoptrace():void
+address CMDstopTrace;
+comment Stop collecting trace information
+
+command profiler.starttrace():void
+address CMDstartTrace;
+comment Start collecting trace information
+
pattern profiler.stop():void
address CMDstopProfiler;
comment Stop offline performance profiling
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1055,7 +1055,9 @@ str CMDscience_bat_flt_tanh(bat *ret, co
str CMDsetHeartbeat(void *res, int *ev);
str CMDsetoid(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str CMDstartProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str CMDstartTrace(void *res);
str CMDstopProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str CMDstopTrace(void *res);
str CMDstr2qgrams(bat *ret, str *val);
str CMDstrlength(int *ret, str *v);
str CMDvarABS(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
@@ -2455,8 +2457,12 @@ int sqlblob_tostr(str *tostr, int *l, co
str srvpoolRef;
str startProfiler(void);
str startRef;
+str startTrace(void);
+str starttraceRef;
str stopProfiler(void);
str stopRef;
+str stopTrace(void);
+str stoptraceRef;
void strAfterCall(ValPtr v, ValPtr bak);
void strBeforeCall(ValPtr v, ValPtr bak);
str strEpilogue(void *ret);
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
@@ -484,13 +484,15 @@ startProfiler(void)
prevUsage = infoUsage;
#endif
+ if( eventstream){
+ throw(MAL,"profiler.start","Profiler already running, stream
not available");
+ }
MT_lock_set(&mal_profileLock );
if (myname == 0){
myname = putName("profiler", 8);
eventcounter = 0;
}
malProfileMode = 1;
- sqlProfiling = TRUE;
MT_lock_unset(&mal_profileLock);
logjsonInternal(monet_characteristics);
// reset the trace table
@@ -499,6 +501,24 @@ startProfiler(void)
return MAL_SUCCEED;
}
+/* SQL queries can be traced without obstructing the stream */
+str
+startTrace(void)
+{
+ malProfileMode = 1;
+ sqlProfiling = TRUE;
+ clearTrace();
+ return MAL_SUCCEED;
+}
+
+str
+stopTrace(void)
+{
+ malProfileMode = eventstream != NULL;
+ sqlProfiling = FALSE;
+ return MAL_SUCCEED;
+}
+
str
stopProfiler(void)
{
@@ -978,7 +998,7 @@ void setHeartbeat(int delay)
MT_join_thread(hbthread);
return;
}
- if (delay <= 10)
+ if ( delay > 0 && delay <= 10)
delay = 10;
ATOMIC_SET(hbdelay, (ATOMIC_TYPE) delay, mal_beatLock);
}
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
@@ -31,6 +31,8 @@ mal_export void profilerEvent(MalBlkPtr
mal_export str startProfiler(void);
mal_export str stopProfiler(void);
+mal_export str startTrace(void);
+mal_export str stopTrace(void);
mal_export void setHeartbeat(int delay);
mal_export str setprofilerpoolsize(int size);
mal_export void initHeartbeat(void);
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
@@ -75,6 +75,20 @@ CMDstopProfiler(Client cntxt, MalBlkPtr
}
str
+CMDstartTrace(void *res)
+{
+ (void) res;
+ return startTrace();
+}
+
+str
+CMDstopTrace(void *res)
+{
+ (void) res;
+ return stopTrace();
+}
+
+str
CMDnoopProfiler(void *res)
{
(void) res; /* fool compiler */
diff --git a/monetdb5/modules/mal/profiler.h b/monetdb5/modules/mal/profiler.h
--- a/monetdb5/modules/mal/profiler.h
+++ b/monetdb5/modules/mal/profiler.h
@@ -40,6 +40,8 @@
profiler_export str CMDstartProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
profiler_export str CMDstopProfiler(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+profiler_export str CMDstartTrace(void *res);
+profiler_export str CMDstopTrace(void *res);
profiler_export str CMDnoopProfiler(void *res);
profiler_export str CMDsetHeartbeat(void *res, int *ev);
profiler_export str CMDopenProfilerStream(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr pci);
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
@@ -14,6 +14,14 @@ pattern stop():void
address CMDstopProfiler
comment "Stop offline performance profiling";
+command starttrace()
+address CMDstartTrace
+comment "Start collecting trace information";
+
+command stoptrace():void
+address CMDstopTrace
+comment "Stop collecting trace information";
+
command setheartbeat(b:int):void
address CMDsetHeartbeat
comment "Set heart beat performance tracing";
diff --git a/monetdb5/optimizer/opt_prelude.c b/monetdb5/optimizer/opt_prelude.c
--- a/monetdb5/optimizer/opt_prelude.c
+++ b/monetdb5/optimizer/opt_prelude.c
@@ -203,7 +203,9 @@ str sqlRef;
str srvpoolRef;
str streamsRef;
str startRef;
+str starttraceRef;
str stopRef;
+str stoptraceRef;
str strRef;
str sumRef;
str subsumRef;
@@ -413,7 +415,9 @@ void optimizerInit(void)
srvpoolRef = putName("srvpool",7);
streamsRef = putName("streams",7);
startRef = putName("start",5);
+ starttraceRef = putName("starttrace",10);
stopRef = putName("stop",4);
+ stoptraceRef = putName("stoptrace",9);
strRef = putName("str",3);
sumRef = putName("sum",3);
subsumRef = putName("subsum",6);
diff --git a/monetdb5/optimizer/opt_prelude.h b/monetdb5/optimizer/opt_prelude.h
--- a/monetdb5/optimizer/opt_prelude.h
+++ b/monetdb5/optimizer/opt_prelude.h
@@ -197,7 +197,9 @@ opt_export str sqlRef;
opt_export str srvpoolRef;
opt_export str streamsRef;
opt_export str startRef;
+opt_export str starttraceRef;
opt_export str stopRef;
+opt_export str stoptraceRef;
opt_export str strRef;
opt_export str sumRef;
opt_export str subsumRef;
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -871,10 +871,10 @@ SQLsetTrace(backend *be, Client cntxt, b
(void) be;
if (onoff) {
- (void) newStmt(mb, "profiler", "start");
+ (void) newStmt(mb, "profiler", "starttrace");
initTrace();
} else {
- (void) newStmt(mb, "profiler", "stop");
+ (void) newStmt(mb, "profiler", "stoptrace");
/* cook a new resultSet instruction */
resultset = newInstruction(mb,ASSIGNsymbol);
setModuleId(resultset, sqlRef);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list