Changeset: 6f927bc116af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6f927bc116af
Modified Files:
monetdb5/mal/mal_profiler.c
Branch: default
Log Message:
Emit sync events only with trace or heartbeat events
This is solution is not going to be used, but is committed as
part of the history of the project.
diffs (127 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
@@ -27,6 +27,7 @@
#endif
#include <string.h>
+#include <stdbool.h>
static void cachedProfilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
@@ -46,6 +47,8 @@ static struct timeval startup_time;
static volatile ATOMIC_TYPE hbdelay = 0;
+static bool send_sync = true;
+
#ifdef HAVE_SYS_RESOURCE_H
struct rusage infoUsage;
static struct rusage prevUsage;
@@ -116,6 +119,41 @@ truncate_string(char *inp)
return ret;
}
+str
+syncEvent(void)
+{
+ send_sync = true;
+ return MAL_SUCCEED;
+}
+
+static void
+renderSyncEvent(void)
+{
+ char logbuffer[LOGLEN], *logbase;
+ int loglen;
+ struct timeval curr_time;
+ lng usec = GDKusec();
+ uint64_t clock_time;
+
+ gettimeofday(&curr_time, NULL);
+ clock_time = curr_time.tv_sec*1000000 + (curr_time.tv_usec == -1 ? 0 :
curr_time.tv_usec);
+
+ if (myname == 0){
+ myname = putName("profiler");
+ }
+ lognew();
+ logadd("{%s", prettify);
+ logadd("\"source\":\"sync\",%s", prettify);
+ if(mal_session_uuid)
+ logadd("\"session\":\"%s\",%s", mal_session_uuid, prettify);
+ // the state field is not really needed, but marvin 1.0 explicitly
+ // searches for it.
+ logadd("\"state\":\"callback\",%s", prettify);
+ logadd("\"clk\":"LLFMT",%s", usec, prettify);
+ logadd("\"time\":%"PRIu64"%s", clock_time, prettify);
+ logadd("}\n");
+ logjsonInternal(logbuffer);
+}
/* JSON rendering method of performance data.
* The eventparser may assume this layout for ease of parsing
EXAMPLE:
@@ -156,6 +194,11 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
if(highwatermark && highwatermark + (start == 0) < pci->calls)
return;
+ if (send_sync) {
+ send_sync = false;
+ renderSyncEvent();
+ }
+
/* make profile event tuple */
lognew();
logadd("{%s",prettify); // fill in later with the event counter
@@ -453,6 +496,11 @@ profilerHeartbeatEvent(char *alter)
if ( getCPULoad(cpuload) )
return;
+ if (send_sync) {
+ send_sync = false;
+ renderSyncEvent();
+ }
+
lognew();
logadd("{%s",prettify); // fill in later with the event counter
logadd("\"source\":\"heartbeat\",%s", prettify);
@@ -540,8 +588,6 @@ openProfilerStream(stream *fd, int mode)
profilerEvent(c->inprogress[j].mb,
c->inprogress[j].stk, c->inprogress[j].pci, 1, c->username);
}
}
- /* Syncronize at start up */
- syncEvent();
return MAL_SUCCEED;
}
@@ -1080,31 +1126,3 @@ void initHeartbeat(void)
ATOMIC_SET(hbrunning, 0, mal_beatLock);
}
}
-
-str
-syncEvent(void)
-{
- char logbuffer[LOGLEN], *logbase;
- int loglen;
- struct timeval curr_time;
- lng usec = GDKusec();
- uint64_t clock_time;
-
- gettimeofday(&curr_time, NULL);
- clock_time = curr_time.tv_sec*1000000 + (curr_time.tv_usec == -1 ? 0 :
curr_time.tv_usec);
-
- lognew();
- logadd("{%s", prettify);
- logadd("\"source\":\"sync\",%s", prettify);
- if(mal_session_uuid)
- logadd("\"session\":\"%s\",%s", mal_session_uuid, prettify);
- // the state field is not really needed, but marvin 1.0 explicitly
- // searches for it.
- logadd("\"state\":\"callback\",%s", prettify);
- logadd("\"clk\":"LLFMT",%s", usec, prettify);
- logadd("\"time\":%"PRIu64",%s", clock_time, prettify);
- logadd("}\n");
- logjsonInternal(logbuffer);
-
- return MAL_SUCCEED;
-}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list