Changeset: fede457f3893 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fede457f3893
Modified Files:
clients/mapiclient/Makefile.ag
clients/mapiclient/eventparser.c
clients/mapiclient/eventparser.h
clients/mapiclient/stethoscope.c
monetdb5/mal/mal_listing.c
monetdb5/mal/mal_profiler.c
Branch: compactprofiler
Log Message:
Major cleanup of the profiler generated events and simplified summary.
In the end I kept Instruction2str() because it is easier.
More BAT properties are dumpped and some stuff is removed: eventcounter, rss ,
short, prereq, source
Renaming:
ctime->mclk
user_id ->user
To simplify the eventparser, the elements of an argument structure are
separated with a hard \t.
The -j option simply dumps the lines received
diffs (truncated from 1328 to 300 lines):
diff --git a/clients/mapiclient/Makefile.ag b/clients/mapiclient/Makefile.ag
--- a/clients/mapiclient/Makefile.ag
+++ b/clients/mapiclient/Makefile.ag
@@ -38,21 +38,22 @@ bin_stethoscope = {
$(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
}
-bin_tachograph = {
- SOURCES = tachograph.c
- LIBS = libmcutil ../../common/utils/libmutils \
- ../mapilib/libmapi \
- ../../common/stream/libstream \
- $(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
-}
-
-bin_tomograph = {
- SOURCES = tomograph.c
- LIBS = libmcutil ../../common/utils/libmutils \
- ../mapilib/libmapi \
- ../../common/stream/libstream \
- $(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
-}
+# disabled: the console should be enough
+#bin_tachograph = {
+# SOURCES = tachograph.c
+# LIBS = libmcutil ../../common/utils/libmutils \
+# ../mapilib/libmapi \
+# ../../common/stream/libstream \
+# $(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
+#}
+#
+#bin_tomograph = {
+# SOURCES = tomograph.c
+# LIBS = libmcutil ../../common/utils/libmutils \
+# ../mapilib/libmapi \
+# ../../common/stream/libstream \
+# $(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
+#}
# disabled: it's not really a tool for users, more to debug mapi
# problems, or measure performance
diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -11,192 +11,164 @@
#include "monetdb_config.h"
#include "eventparser.h"
-char *statenames[]= {"","start","done","action","ping","wait","system"};
-
-char *maltypes[MAXMALARGS];
-char *malvariables[MAXMALARGS];
-char *malvalues[MAXMALARGS];
-int malcount[MAXMALARGS];
-int malargc;
-int malretc;
-
-int malsize;
int debug=0;
-char *currentquery=0;
-int eventcounter = 0;
#define DATETIME_CHAR_LENGTH 27
-static void
-clearArguments(void)
-{
- int i;
-
- if( currentquery){
- free(currentquery);
- currentquery = 0;
- }
-
- for(i = 0; i < MAXMALARGS; i++){
- if( malvariables[i]){
- free(malvariables[i]);
- malvariables[i] = 0;
- }
- if( malvalues[i]){
- free(malvalues[i]);
- malvalues[i] = 0;
- }
- if( maltypes[i]){
- free(maltypes[i]);
- maltypes[i] = 0;
- }
- }
-}
+#define FREE(X) if(X){ free(X); X= 0;}
static void
-dumpArguments(void)
-{
- int i;
- for( i=0; i < MAXMALARGS; i++)
- if( maltypes[i])
- printf("[%d] variable %s value %s type %s\n", i,
(malvariables[i]?malvariables[i]:""), malvalues[i], maltypes[i]);
-}
+resetEventRecord(EventRecord *ev)
+{ int i;
+
+ FREE(ev->version);
-char *
-stripQuotes(char *currentquery)
-{
- const char *c;
- char *q, *qry;
- if( currentquery ==0)
- return NULL;
- q = qry = (char *) malloc(strlen(currentquery) * 2);
- if( q == NULL){
- fprintf(stderr,"Could not allocate query buffer of size %zu\n",
strlen(currentquery) * 2);
- exit(-1);
+ // event state
+ FREE(ev->version);
+ FREE(ev->user);
+ FREE(ev->session);
+ FREE(ev->function);
+ FREE(ev->module);
+ FREE(ev->instruction);
+ FREE(ev->state);
+ FREE(ev->stmt);
+ FREE(ev->time);
+ for(i=0; i< ev->maxarg; i++){
+ FREE(ev->args[i].alias);
+ FREE(ev->args[i].name);
+ FREE(ev->args[i].type);
+ FREE(ev->args[i].view);
+ FREE(ev->args[i].parent);
+ FREE(ev->args[i].persistence);
+ FREE(ev->args[i].file);
+ FREE(ev->args[i].seqbase);
+ FREE(ev->args[i].sorted);
+ FREE(ev->args[i].revsorted);
+ FREE(ev->args[i].nonil);
+ FREE(ev->args[i].nil);
+ FREE(ev->args[i].key);
+ FREE(ev->args[i].unique);
+ FREE(ev->args[i].value);
+ FREE(ev->args[i].debug);
}
- c= currentquery;
- if( *c == '"') c++;
- for (; *c; ){
- if ( strncmp(c,"\\\\t",3) == 0){
- *q++ = '\t';
- c+=3;
- } else
- if ( strncmp(c,"\\\\n",3) == 0){
- *q++ = '\n';
- c+=3;
- } else if ( strncmp(c,"\\\"",2) == 0){
- *q++= '"';
- c+=2;
- } else if ( strncmp(c,"\\\\",2) == 0){
- c+= 2;
- } else *q++ = *c++;
- }
- *q =0;
- return qry;
-}
-
-
-void
-resetEventRecord(EventRecord *ev)
-{
- if( ev->version) free(ev->version);
- if( ev->release) free(ev->release);
- if( ev->memory) free(ev->memory);
- if( ev->threads) free(ev->threads);
- if( ev->host) free(ev->host);
- if( ev->package) free(ev->package);
-
- if( ev->function) free(ev->function);
- if( ev->user) free(ev->user);
- if( ev->time) free(ev->time);
- 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);
- *ev = (EventRecord) {
- .eventnr = -1,
- };
- clearArguments();
+ ev->maxarg = 0;
}
/* simple json key:value object parser for event record.
- * each event pair on a single row, which is required for dealing with string
values
- * It avoids lots of escaped charactor recognition, simply take with mserver
delivers
+ * It is a restricted json parser, which uses the knowledge of the mal
profiler.
* Returns 1 if the closing bracket is found. 0 to continue, -1 upon error
*/
-#define skipto(C) { while(*c && *c != C) c++; if (*c != C) return -1;}
-#define skipstr() { while (*c && *c !='"') {if (*c =='\\') c++;if(*c)c++;} if
(*c != '"') return -1;}
+#define skipto(H,C) { while(*H && *H != C) H++;}
+#define skipstr() { while (*c && *c !='"') {if (*c =='\\') c++;if(*c)c++;} }
/*
- * The decomposition of the argument components is postponed
- * We just keep the concatenated json string
+ * Also parse the argument array structure
*/
-static int
-parseArgument(char *txt, EventRecord *ev)
-{
- char *s,*t;
- int i=0;
- // assume single strictly formatted key-value list line
- (void) txt;
+static char *
+getstr(char *val){
+ val[strlen(val) -1] = 0;
+ return strdup(val + 1);
+}
+
+static int
+argparser(char *txt, EventRecord *ev){
+ char *c, *key,*val;
+ int cnt = 0, arg = -1;
+ c = txt;
+
(void) ev;
- s= strstr(txt,"index\":\"");
- if( s){
- i = atoi(s + 8);
- if( i <0 || i >= MAXMALARGS )
- return 0;
+ (void) key;
+ /* First determine the number arguments to deal with */
+ while( *c){
+ skipto(c, '\t');
+ if(*c){
+ c++;
+ if( *c == '}')
+ cnt ++;
+ }
}
- t= strstr(txt,"name\":\"");
- s= strstr(txt,"\",value\":\"");
- if( s && t){
- t+= 7;
- *s =0;
- malvariables[i] = strdup(t);
- s+= 10;
+
+ /* Allocate the space for their properties */
+ if(ev->args) free(ev->args);
+ ev->args = (Argrecord*) malloc(cnt * sizeof(Argrecord));
+ memset(ev->args, 0, cnt * sizeof(Argrecord));
+ ev->maxarg = cnt;
+
+ /* parse the event argument structures, using the \t field separator */
+ c= txt + 1;
+ while( *c){
+ if( *c == '{' || *c == '[')
+ c++;
+ if( *c == '}' || *c == ']')
+ break;
+
+ skipto(c, '"');
+ key = ++c;
+ skipstr();
+ *c++ = 0;
+ skipto(c, ':');
+ c++;
+ val = c;
+ /* we know that the value is terminated with a hard tab */
+ skipto(c, '\t');
+ if(*c){ --c; *c = 0; c++;}
+
+ /* These components should be the first */
+ if( strstr(key,"ret")) {
+ arg = atoi(val);
+ ev->args[arg].kind = MDB_RET;
+ continue;
+ }
+ if( strstr(key,"arg")) {
+ arg = atoi(val);
+ ev->args[arg].kind = MDB_ARG;
+ continue;
+ }
+ assert(arg> -1 && arg < ev->maxarg);
+ if( strstr(key,"bid")) { ev->args[arg].bid = atoi(val);
continue;}
+ if( strstr(key,"alias")) { ev->args[arg].alias = getstr(val);
continue;}
+ if( strstr(key,"name")) { ev->args[arg].name = getstr(val);
continue;}
+ if( strstr(key,"type")) { ev->args[arg].type =
getstr(val);continue;}
+ if( strstr(key,"view")) { ev->args[arg].view = getstr(val);
continue;}
+ if( strstr(key,"parent")) { ev->args[arg].parent = getstr(val);
continue;}
+ if( strstr(key,"persistence")) { ev->args[arg].persistence =
getstr(val); continue;}
+ if( strstr(key,"file")) { ev->args[arg].file = getstr(val);
continue;}
+ if( strstr(key,"seqbase")) { ev->args[arg].seqbase =
getstr(val); continue;}
+ if( strstr(key,"sorted")) { ev->args[arg].sorted = getstr(val);
continue;}
+ if( strstr(key,"revsorted")) { ev->args[arg].revsorted =
getstr(val); continue;}
+ if( strstr(key,"nonil")) { ev->args[arg].nonil = getstr(val);
continue;}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list