Changeset: 0db04e1b0482 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0db04e1b0482 Modified Files: clients/mapiclient/eventparser.c monetdb5/mal/mal_profiler.c Branch: default Log Message:
Add ctime back to the mal profiler output This time however we don't use the gettimeofday for every MAL instruction. We call it at server startup and compute the offset using GDKusec. This should be accurate to a few nanoseconds. diffs (115 lines): diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -112,6 +112,8 @@ resetEventRecord(EventRecord *ev) if( ev->stmt) free(ev->stmt); if( ev->fcn) free(ev->fcn); if( ev->numa) free(ev->numa); + if(ev->beauty) free(ev->beauty); + if(ev->prereq) free(ev->prereq); memset( (char*) ev, 0, sizeof(EventRecord)); ev->eventnr = -1; clearArguments(); @@ -173,7 +175,7 @@ int keyvalueparser(char *txt, EventRecord *ev) { char *c, *s, *key, *val; - struct tm stm; + //struct tm stm; c= txt; @@ -205,20 +207,35 @@ keyvalueparser(char *txt, EventRecord *e } else val =c; if( strstr(key,"clk")){ - ev->clk = atol(val); + ev->clk = atol(val); return 0; } if( strstr(key,"ctime")){ - /* convert time to epoch in seconds*/ - ev->time= strdup(val); - memset(&stm, 0, sizeof(struct tm)); - c = strptime(val + 1, "%H:%M:%S", &stm); - ev->clkticks = (((lng) stm.tm_hour * 60 + stm.tm_min) * 60 + stm.tm_sec) * 1000000; - c= strchr(val,'.'); + long sec; + struct tm curr_time; + + c = strchr(val,'.'); + if (c != NULL) { + *c = '\0'; + c++; + } + + sec = atol(val); +#ifdef HAVE_LOCALTIME_R + (void)localtime_r(&sec, &curr_time); +#else + curr_time = *localtime(&sec); +#endif + ev->time = malloc(26*sizeof(char)); + snprintf(ev->time, 26, "%d/%02d/%02d %02d:%02d:%02d.%s", + curr_time.tm_year + 1900, curr_time.tm_mon, curr_time.tm_mday, + curr_time.tm_hour, curr_time.tm_min, curr_time.tm_sec, + c); + ev->clkticks = sec * 1000000; if (c != NULL) { lng usec; /* microseconds */ - usec = strtoll(c + 1, NULL, 10); + usec = strtoll(c, NULL, 10); assert(usec >= 0 && usec < 1000000); ev->clkticks += usec; } 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 @@ -22,6 +22,8 @@ #include "mal_debugger.h" #include "mal_resource.h" +#include <sys/time.h> + static void cachedProfilerEvent(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); stream *eventstream = 0; @@ -36,6 +38,8 @@ static int highwatermark = 5; // conserv static int TRACE_init = 0; int malProfileMode = 0; /* global flag to indicate profiling mode */ +static struct timeval startup_time; + static volatile ATOMIC_TYPE hbdelay = 0; #ifdef HAVE_SYS_RESOURCE_H @@ -107,7 +111,12 @@ renderProfilerEvent(MalBlkPtr mb, MalStk str stmt, c; str stmtq; lng usec= GDKusec(); + lng sec = (lng)startup_time.tv_sec + usec/1000000; + long microseconds = (long)startup_time.tv_usec + (usec % 1000000); + assert (microseconds / 1000000 >= 0 && microseconds / 1000000 < 2); + sec += (microseconds / 1000000); + microseconds %= 1000000; // ignore generation of events for instructions that are called too often if(highwatermark && highwatermark + (start == 0) < pci->calls) @@ -120,6 +129,7 @@ renderProfilerEvent(MalBlkPtr mb, MalStk if( usrname) logadd("\"user\":\"%s\",%s",usrname, prettify); logadd("\"clk\":"LLFMT",%s",usec,prettify); + logadd("\"ctime\":"LLFMT".%06ld,%s", sec, microseconds, prettify); logadd("\"thread\":%d,%s", THRgettid(),prettify); logadd("\"function\":\"%s.%s\",%s", getModuleId(getInstrPtr(mb, 0)), getFunctionId(getInstrPtr(mb, 0)), prettify); @@ -1022,6 +1032,7 @@ void setHeartbeat(int delay) void initProfiler(void) { + gettimeofday(&startup_time, NULL); if( mal_trace) openProfilerStream(mal_clients[0].fdout,0); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list