Changeset: e098c8734b86 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e098c8734b86
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
Branch: sql_profiler
Log Message:
More genericEvents(sql layer). Missing transaction events.
diffs (276 lines):
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -208,10 +208,15 @@ MCexitClient(Client c)
c->fdin = NULL;
}
- genericEvent("End client connection.",
- (struct GenericEvent)
- { &c->idx, (oid)NULL, NULL, NULL, NULL },
- 1);
+ if(malProfileMode > 0)
+ genericEvent("End client connection.",
+ (struct GenericEvent)
+ { &c->idx,
+ (oid)NULL,
+ NULL,
+ NULL,
+ 0 },
+ 1);
setClientContext(NULL);
}
@@ -307,10 +312,15 @@ MCinitClient(oid user, bstream *fin, str
if (c) {
assert(NULL == setClientContext(c));
c = MCinitClientRecord(c, user, fin, fout);
- genericEvent("Start client connection.",
- (struct GenericEvent)
- { &c->idx, (oid)NULL, NULL, NULL, NULL
},
- 0);
+ if(malProfileMode > 0)
+ genericEvent("Start client connection.",
+ (struct GenericEvent)
+ { &c->idx,
+ (oid)NULL,
+ NULL,
+ NULL,
+ 0 },
+ 0);
}
MT_lock_unset(&mal_contextLock);
return c;
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
@@ -187,24 +187,27 @@ static str
prepareGenericEvent(str msg, struct GenericEvent e, int state)
{
struct logbuf logbuf = {0};
+ lng clk = GDKusec();
if (logadd(&logbuf,
- "{\""
- "msg\":\"%s\""
+ "{"
+ "\"clk\":"LLFMT
+ ",\"msg\":\"%s\""
",\"client_id\":\"%d\""
",\"tag\":\""OIDFMT
",\"transaction_id\":\"%d\""
",\"query\":\"%s\""
",\"error\":\"%s\""
- ",\"state\":\"%d\""
+ ",\"state\":\"%s\""
"}\n",
+ clk,
msg ? msg : "",
- e.clientId ? *(e.clientId) : -1,
+ e.client_id ? *(e.client_id) : -1,
e.tag ? e.tag : (oid)-1,
- e.transactionId ? *e.transactionId : 0,
- e.query ? e.query : "",
- e.error ? e.error : "",
- state))
+ e.transaction_id ? *e.transaction_id : 0,
+ e.query ? e.query : "none",
+ e.error ? "true" : "false",
+ state ? "done" : "start"))
return logbuf.logbuffer;
else {
logdel(&logbuf);
@@ -280,7 +283,7 @@ prepareProfilerEvent(Client cntxt, MalBl
logbuf = (struct logbuf) {0};
- usec= pci->clock;
+ usec = pci->clock;
microseconds = (uint64_t)usec - ((uint64_t)startup_time.tv_sec*1000000
- (uint64_t)startup_time.tv_usec);
/* make profile event tuple */
/* TODO: This could probably be optimized somehow to avoid the
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
@@ -21,11 +21,11 @@ typedef struct rusage Rusage;
#endif
struct GenericEvent {
- int* clientId;
+ int* client_id;
oid tag;
- int* transactionId;
+ int* transaction_id;
str query;
- str error;
+ int error;
};
mal_export int malProfileMode;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -129,17 +129,36 @@ sql_symbol2relation(backend *be, symbol
int profile = be->mvc->emode == m_plan;
Client c = getClientContext();
- genericEvent("Start SQL compiler",
- (struct GenericEvent)
- { &(c->idx), c->curprg->def->tag, NULL, NULL,
NULL },
- 0);
+ if(malProfileMode > 0 )
+ genericEvent("Start SQL compiler",
+ (struct GenericEvent)
+ { &(c->idx),
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ 0 },
+ 0);
rel = rel_semantic(query, sym);
- genericEvent("End SQL compiler",
- (struct GenericEvent)
- { &(c->idx), c->curprg->def->tag, NULL, NULL,
rel ? "Good" : "Error" },
- 1);
+ if(malProfileMode > 0 ) {
+ genericEvent("End SQL compiler",
+ (struct GenericEvent)
+ { &(c->idx),
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ rel ? 1 : 0 },
+ 1);
+ genericEvent("Start relational optimizer",
+ (struct GenericEvent)
+ { &(c->idx),
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ 0 },
+ 1);
+ }
storage_based_opt = value_based_opt && rel && !is_ddl(rel->op);
Tbegin = GDKusec();
@@ -151,7 +170,15 @@ sql_symbol2relation(backend *be, symbol
be->no_mitosis = 1;
be->reloptimizer = GDKusec() - Tbegin;
- // TODO PROFILER: EVENT("start of relational optimizer","program_id":
TYPE_int, be->c->curprg->def->tag, "error", TYPE_int, rel == NULL)
+ if(malProfileMode > 0)
+ genericEvent("End relational optimizer.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ rel ? 1 : 0},
+ 0);
return rel;
}
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
@@ -1109,7 +1109,16 @@ SQLparser(Client c)
tag = runtimeProfileSetTag(c);
assert(tag == c->curprg->def->tag);
(void) tag;
- // TODO PROFILER: EVENT("start of SQL parser", "client_id", TYPE_int,
c->id, "program_id": TYPE_int, log c->curprg->def->tag)
+
+ if(malProfileMode > 0)
+ genericEvent("Start SQL parser.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ 0 },
+ 0);
if ((err = sqlparse(m)) ||
/* Only forget old errors on transaction boundaries */
@@ -1137,7 +1146,15 @@ SQLparser(Client c)
be->q = NULL;
c->query = query_cleaned(m->sa, QUERY(m->scanner));
- // TODO PROFILER: EVENT("end of SQL parser", "program_id": TYPE_int,
log c->curprg->def->tag, "query": TYPE_str, c->query)
+ if(malProfileMode > 0)
+ genericEvent("End SQL parser.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ c->query ? c->query : NULL,
+ c->query ? 0 : 1, },
+ 1);
if (c->query == NULL) {
err = 1;
@@ -1194,12 +1211,30 @@ SQLparser(Client c)
}
}
- // TODO PROFILER: EVENT("start of MAL
compiler","program_id": TYPE_int, log c->curprg->def->tag, "query": TYPE_str,
c->query)
+ if(malProfileMode > 0)
+ genericEvent("Start MAL compiler.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ c->query ? c->query
: NULL,
+ c->query ? 0 : 1 },
+ 0);
+
if (backend_dumpstmt(be, c->curprg->def, r, !(m->emod &
mod_exec), 0, c->query) < 0)
err = 1;
else
opt = (m->emod & mod_exec) == 0;//1;
- // TODO PROFILER: EVENT("end of MAL
compiler","program_id": TYPE_int, log c->curprg->def->tag, "query": TYPE_str,
c->query, "error_code", TYPE_int, err)
+
+ if(malProfileMode > 0)
+ genericEvent("End MAL compiler.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ c->query ? c->query
: NULL,
+ c->query ? 0 : 1 },
+ 1);
} else {
char *q_copy = sa_strdup(m->sa, c->query);
@@ -1277,9 +1312,28 @@ SQLparser(Client c)
/* in case we had produced a non-cachable plan, the optimizer
should be called */
if (msg == MAL_SUCCEED && opt ) {
- // TODO PROFILER: EVENT("start of MAL
optimizer","program_id": TYPE_int, log c->curprg->def->tag)
+
+ if(malProfileMode > 0)
+ genericEvent("Start MAL optimizer.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ 0 },
+ 0);
+
msg = SQLoptimizeQuery(c, c->curprg->def);
- // TODO PROFILER: EVENT("end of MAL
optimizer","program_id": TYPE_int, log c->curprg->def->tag, "error_msg",
TYPE_str, msg)
+
+ if(malProfileMode > 0)
+ genericEvent("End MAL optimizer.",
+ (struct GenericEvent)
+ { &c->idx,
+ c->curprg->def->tag,
+ NULL,
+ NULL,
+ msg == MAL_SUCCEED ?
0 : 1 },
+ 1);
if (msg != MAL_SUCCEED) {
str other = c->curprg->def->errors;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]