Changeset: 5c23515c4b2c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5c23515c4b2c
Modified Files:
MonetDB5/src/mal/mal_interpreter.mx
MonetDB5/src/mal/mal_recycle.mx
MonetDB5/src/modules/mal/trader.mx
MonetDB5/src/optimizer/opt_recycler.mx
sql/src/backends/monet5/sql.mx
Branch: default
Log Message:
Octopus improvements and fixes:
- the dataflow wrapup hook function has access to the original instruction
pointer;
- recycler extended to remotely cache and reuse index bats
- added logging of the bidding process.
diffs (197 lines):
diff -r 1f7579df262a -r 5c23515c4b2c MonetDB5/src/mal/mal_interpreter.mx
--- a/MonetDB5/src/mal/mal_interpreter.mx Tue Jul 13 16:02:34 2010 +0200
+++ b/MonetDB5/src/mal/mal_interpreter.mx Tue Jul 13 17:24:57 2010 +0200
@@ -1066,11 +1066,11 @@
We don't allow sequential flow control here.
@c
switch (pci->token){
- case ASSIGNsymbol: @:assignStmt(FAST,fs->pc = -1;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
- case PATcall: @:patterncall(FAST,fs->pc = -1;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
- case CMDcall: @:commandcall(FAST,fs->pc = -1;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
- case FACcall: @:factorycall(FAST,fs->pc = -1;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
- case FCNcall: @:functioncall(FAST,fs->pc = -1;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
+ case ASSIGNsymbol: @:assignStmt(FAST,fs->pc = -fs->pc;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
+ case PATcall: @:patterncall(FAST,fs->pc = -fs->pc;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
+ case CMDcall: @:commandcall(FAST,fs->pc = -fs->pc;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
+ case FACcall: @:factorycall(FAST,fs->pc = -fs->pc;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
+ case FCNcall: @:functioncall(FAST,fs->pc = -fs->pc;
updMemoryUsed(stk,pci,argclaim); DFLOWadmission(-argclaim,-retclaim,-hotclaim);
return ret,t)@ break;
case NOOPsymbol:
case REMsymbol:
break;
@@ -1087,7 +1087,7 @@
}
@:endProfile(t)@
if (ret)
- fs->pc = -1;
+ fs->pc = -fs->pc;
return ret;
}
@@ -1296,8 +1296,8 @@
while(queued){
PARDEBUG stream_printf(GDKstdout,"#waiting for results, queued
%d\n", queued);
f = q_dequeue(flow->done);
- if ( f->flow->stk->wrapup && f->pc >= 0 ) /* clean up whatever
is called for */
- (*f->flow->stk->wrapup)(f->flow->cntxt, f->flow->mb,
f->flow->stk, getInstrPtr(flow->mb, f->pc));
+ if ( f->flow->stk->wrapup ) /* clean up whatever is called for
*/
+ (*f->flow->stk->wrapup)(f->flow->cntxt, f->flow->mb,
f->flow->stk, getInstrPtr(flow->mb, abs(f->pc)));
f->status = DFLOWwrapup;
queued--;
if (f->pc < 0) {
@@ -1308,7 +1308,7 @@
/* dequeue the remainders in case of an error */
while(queued-- > 0) {
if ( f->flow->stk->wrapup ) /* clean up
whatever is called for */
-
(*f->flow->stk->wrapup)(f->flow->cntxt, f->flow->mb, f->flow->stk,
getInstrPtr(flow->mb, f->pc));
+
(*f->flow->stk->wrapup)(f->flow->cntxt, f->flow->mb, f->flow->stk,
getInstrPtr(flow->mb, abs(f->pc)));
(void)q_dequeue(flow->done);
}
return f->error;
diff -r 1f7579df262a -r 5c23515c4b2c MonetDB5/src/mal/mal_recycle.mx
--- a/MonetDB5/src/mal/mal_recycle.mx Tue Jul 13 16:02:34 2010 +0200
+++ b/MonetDB5/src/mal/mal_recycle.mx Tue Jul 13 17:24:57 2010 +0200
@@ -2018,18 +2018,20 @@
{
int i, j;
InstrPtr q;
- static str octopusRef = 0, bindRef = 0;
+ static str octopusRef = 0, bindRef = 0, bindidxRef = 0;
if (octopusRef == 0)
octopusRef = putName("octopus",7);
if (bindRef == 0)
bindRef = putName("bind",4);
+ if (bindidxRef == 0)
+ bindidxRef = putName("bind_idxbat",11);
mal_set_lock(recycleLock,"recycle");
for (i = 0; i < recycleBlk->stop; i++){
q = getInstrPtr(recycleBlk,i);
if ( getModuleId(q) != octopusRef ||
- getFunctionId(q) != bindRef ) continue;
+ (getFunctionId(q) != bindRef && getFunctionId(q) !=
bindidxRef) ) continue;
if (p->argc < q->argc-1) continue;
/* sub-range instructions can be subsumed from entire table */
@@ -2083,7 +2085,7 @@
bat bid= -1, nbid= -1;
InstrPtr q;
static str selectRef = 0, like_selectRef = 0, thetaselectRef = 0,
- octopusRef = 0, bindRef = 0;
+ octopusRef = 0, bindRef = 0, bindidxRef = 0;
bit gluse = FALSE;
lng ticks = GDKusec();
@@ -2097,12 +2099,15 @@
octopusRef = putName("octopus",7);
if (bindRef == 0)
bindRef = putName("bind",4);
+ if (bindidxRef == 0)
+ bindidxRef = putName("bind_idxbat",11);
if( recycleBlk == 0 || reusePolicy == 0)
return -1;
- /* separate matching of data transfer instructions: octopus.bind() */
- if ( getModuleId(p) == octopusRef && getFunctionId(p) == bindRef )
+ /* separate matching of data transfer instructions: octopus.bind(),
octopus.bind_idxbat() */
+ if ( getModuleId(p) == octopusRef &&
+ ( getFunctionId(p) == bindRef || getFunctionId(p) == bindidxRef
))
return RECYCLEdataTransfer(cntxt, s, p);
mal_set_lock(recycleLock,"recycle");
diff -r 1f7579df262a -r 5c23515c4b2c MonetDB5/src/modules/mal/trader.mx
--- a/MonetDB5/src/modules/mal/trader.mx Tue Jul 13 16:02:34 2010 +0200
+++ b/MonetDB5/src/modules/mal/trader.mx Tue Jul 13 17:24:57 2010 +0200
@@ -70,6 +70,7 @@
#include <mal_module.h>
#include <mal_recycle.h>
#include "trader.h"
+#include <time.h>
/*
static lng estimateSavings0(MalBlkPtr mb, sht bidtype)
@@ -89,6 +90,7 @@
lng savedInstr = 0, savedKB = 0;
static str octopusRef = 0, bindRef = 0;
+
if (octopusRef == 0)
octopusRef = putName("octopus",7);
if (bindRef == 0)
@@ -192,6 +194,12 @@
str fnname = *(str *) getArgReference(stk,pci,1);
sht bidtype = *(sht *) getArgReference(stk,pci,2);
Symbol sym;
+ static char fname[BUFSIZ] = "";
+ static str biddingLog = NULL;
+ stream *s;
+ time_t now;
+ struct tm *nowtm;
+ char timestr[20];
(void) mb;
sym = findSymbol(cntxt->nspace, putName("octopus",7), fnname);
@@ -200,6 +208,24 @@
*c = estimateSavings(sym->def, bidtype);
+ /* log bidding */
+ if ( biddingLog == NULL) {
+
sprintf(fname,"%s/%s/bidding.log",GDKgetenv("gdk_dbfarm"),GDKgetenv("gdk_dbname"));
+ biddingLog = fname;
+ }
+ s = append_wastream(biddingLog);
+ if (s == NULL )
+ throw(MAL,"trader.makeBid", RUNTIME_FILE_NOT_FOUND
"%s", biddingLog);
+ if (stream_errnr(s)) {
+ stream_close(s);
+ throw(MAL,"trader.makeBid", RUNTIME_FILE_NOT_FOUND
"%s", biddingLog);
+ }
+ now = time(NULL);
+ nowtm = localtime(&now);
+ strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", nowtm);
+ stream_printf(s,"%s\t%s\t%1d\t" LLFMT "\n",timestr, fnname, bidtype,
*c);
+ close_stream(s);
+
return MAL_SUCCEED;
}
diff -r 1f7579df262a -r 5c23515c4b2c MonetDB5/src/optimizer/opt_recycler.mx
--- a/MonetDB5/src/optimizer/opt_recycler.mx Tue Jul 13 16:02:34 2010 +0200
+++ b/MonetDB5/src/optimizer/opt_recycler.mx Tue Jul 13 17:24:57 2010 +0200
@@ -344,7 +344,7 @@
}
*/
if (getModuleId(p) == octopusRef &&
- getFunctionId(p) == bindRef ) {
+ ( getFunctionId(p) == bindRef || getFunctionId(p) ==
bindidxRef) ) {
recycled[getArg(p,0)] = 1;
p->recycle = recycleMaxInterest;
marks++;
diff -r 1f7579df262a -r 5c23515c4b2c sql/src/backends/monet5/sql.mx
--- a/sql/src/backends/monet5/sql.mx Tue Jul 13 16:02:34 2010 +0200
+++ b/sql/src/backends/monet5/sql.mx Tue Jul 13 17:24:57 2010 +0200
@@ -932,6 +932,22 @@
return bind_idxbat:= b;
end octopus.bind_idxbat;
+function octopus.bind_idxbat(conn:str, sch:str, tab:str, index:str,
access:int, low:oid, hgh:oid, version:int):bat[:oid,:oid];
+ m := nil:ptr;
+ rm := remote.put(conn,m);
+ rm := remote.exec(conn,"sql","mvc");
+ s := remote.put(conn,sch);
+ t := remote.put(conn,tab);
+ i := remote.put(conn,index);
+ a := remote.put(conn,access);
+ l := remote.put(conn,low);
+ h := remote.put(conn,hgh);
+ bh:= remote.put(conn,bind_idxbat);
+ bh:= remote.exec(conn,"sql","bind_idxbat",rm,s,t,i,a,l,h);
+ b:bat[:oid,:oid]:= remote.get(conn,bh);
+ return bind_idxbat:= b;
+end octopus.bind_idxbat;
+
function octopus.getVariable(conn:str,name:str):any_1;
s := remote.put(conn,name);
bh:= remote.exec(conn,"sql","getVariable",s);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list