Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11707
Modified Files:
mal_interpreter.mx mal_recycle.mx
Log Message:
mal_interpreter= recover accidental loss of instruction
mal_recycler = step towards using previous select results
Index: mal_recycle.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_recycle.mx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mal_recycle.mx 3 Mar 2008 13:21:47 -0000 1.7
+++ mal_recycle.mx 4 Mar 2008 09:20:08 -0000 1.8
@@ -95,8 +95,7 @@
static sht reusePolicy = 0; /* recycle reuse policy
0: baseline, keeps stat, no retain, no reuse
1: exact covering
- 2: reuse smallest covering
- 3: reuse closest covering */
+ 2: reuse smallest select covering */
static sht rcachePolicy = 0; /* recycle cache management policy
0: baseline, do nothing
1: throw LRU
@@ -292,21 +291,31 @@
@-
Searching for useful recycle instructions is the real challenge.
There are two major approaches. The first approach is to search
-for an identical operation as the target under investigation.
+for an identical operation as the target under investigation and
+reuse its result if possible.
The second approach uses the semantics of operations and
-replaces the arguments. For example, a previous result of a scan
-may be used instead.
+replaces the arguments of the target to make it cheaper to execute.
+For example, a previous result of a scan may be used instead
+or it can be small compared to the target.
@c
-int
-RECYCLEfindEntry(int start, MalBlkPtr mb, MalStkPtr s, InstrPtr p)
+static int
+RECYCLEreuse(MalBlkPtr mb, MalStkPtr s, InstrPtr p)
{
int i, j, ridx;
InstrPtr q;
+ static str selectRef;
+ static str uselectRef;
+ if( selectRef == 0) selectRef= getName("select",6);
+ if( uselectRef == 0) uselectRef= getName("uselect",7);
+#ifdef _DEBUG_RECYCLE_
+ stream_printf(GDKout,"RECYCLEreuse policy %d recycleBlk %d\n",
+ reusePolicy, recycleBlk==0);
+#endif
if( recycleBlk == 0)
- return -1;
+ return 0;
- for (i = start; i < recycleBlk->stop; i++){
+ for (i = 0; i < recycleBlk->stop; i++){
q = getInstrPtr(recycleBlk,i);
if((p->argc != q->argc) ||
(getModuleId(p) != getFunctionId(q)) ||
@@ -316,7 +325,7 @@
switch(reusePolicy){
case 0:
/* 0: baseline, keeps stat, no retain, no reuse*/
- return -1;
+ break;
case 1:
/* 1: exact covering */
for (j = p->retc; j < p->argc; j++){
@@ -329,16 +338,22 @@
goto notfound;
}
/* found an exact match */
- return i;
+ return 1;
notfound: continue;
case 2:
- /* 2: reuse smallest covering */
- case 3:
- /* 3: reuse closest covering */
- return -1;
+ /* 2: reuse smallest range covering */
+ if( (getFunctionId(p)== selectRef ||
+ getFunctionId(p)== uselectRef) )
+ {
+#ifdef _DEBUG_RECYCLE_
+ stream_printf(GDKout,"RECYCLEreuse found %d %d\n",
+ mb->var[getArg(p,1)]->recycle,getArg(q,1) );
+ printInstruction(GDKout,mb,p, LIST_MAL_ALL);
+#endif
+ }
}
}
- return -1;
+ return 0;
}
@-
@@ -368,15 +383,10 @@
VALcopy(lhs,rhs);
if( lhs->vtype == TYPE_bat)
BBPincref(lhs->val.br.id, TRUE);
- } else
- if( isVarRecycled(mb, getArg(p,i))){
- int start=0;
- start= RECYCLEfindEntry(start,mb,stk,p);
-#ifdef _DEBUG_RECYCLE_
- stream_printf(GDKout,"RECYCLEentry search %d\n",start);
-#endif
- /* and from here we should decide how to reuse it */
- }
+ }
+
+ if( cnt != p->retc && RECYCLEreuse(mb,stk,p) )
+ cnt= p->retc;
stk->clk= GDKusec();
return cnt == p->retc;
}
@@ -392,6 +402,9 @@
int i,keepit= FALSE;
lng clk = 0;
+#ifdef _DEBUG_RECYCLE_
+ stream_printf(GDKout,"RECYCLEexit policy %d \n",retainPolicy);
+#endif
for(i=0; i<p->retc; i++)
if( isVarRecycled(mb, getArg(p,i)) && !isVarKept(mb,getArg(p,i))){
#ifdef _DEBUG_RECYCLE_
Index: mal_interpreter.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_interpreter.mx,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- mal_interpreter.mx 2 Mar 2008 11:20:51 -0000 1.215
+++ mal_interpreter.mx 4 Mar 2008 09:20:07 -0000 1.216
@@ -468,9 +468,9 @@
pci = getInstrPtr(mb,stkpc);
if( malProfileMode + cntxt->itrace)
goto workslow;
- @:MALrecyclerStart@ {
+ @:MALrecycleStart@ {
@:MALinterpret(FAST)@
- @:MALrecyclerExit@
+ @:MALrecycleExit@
}
@:MALflowofcontrol(FAST)@
}
@@ -500,9 +500,9 @@
}
@:beginProfile@
- @:MALrecyclerStart@ {
+ @:MALrecycleStart@ {
@:MALinterpret(SLOW)@
- @:MALrecyclerExit@
+ @:MALrecycleExit@
}
@:MALflowofcontrol(SLOW)@
@:endProfile@
@@ -1465,9 +1465,9 @@
as much as possible.
The recycler works for any variable and relies on policy functions
registered.
[EMAIL PROTECTED] MALrecyclerStart
[EMAIL PROTECTED] MALrecycleStart
if( !pci->recycle || !mb->version || !RECYCLEentry(mb,stk,pci) )
[EMAIL PROTECTED] MALrecyclerExit
[EMAIL PROTECTED] MALrecycleExit
if( pci->recycle && mb->version )
RECYCLEexit(mb,stk,pci);
@}
@@ -1616,6 +1616,7 @@
{
ppc= stkpc;
stk->clk= GDKusec();
+ mb->profiler[ppc].clk= stk->clk;
time(&stk->clock);
mb->profiler[ppc].clock= stk->clock;
#ifdef HAVE_TIMES
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins