Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1217

Modified Files:
        opt_garbageCollector.mx opt_mergetable.mx 
Log Message:
mergetable - reshuffle code to prepare for next experiment
garbageCollector - ignore variables marked explicitly to 'keep'


Index: opt_garbageCollector.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_garbageCollector.mx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- opt_garbageCollector.mx     17 Aug 2007 13:56:53 -0000      1.26
+++ opt_garbageCollector.mx     21 Aug 2007 10:41:34 -0000      1.27
@@ -94,6 +94,7 @@
 #include "mal_interpreter.h"   /* for showErrors() */
 #include "mal_builder.h"
 #include "opt_prelude.h"
+#include "mal_properties.h"
 
 @-
 There are two basic ways to release a BAT. The cheapest one is
@@ -147,6 +148,22 @@
        actions++;
 }
 @}
[EMAIL PROTECTED]
+Garbage collection is not always required, even unwanted.
+For example, the BATs used to assemble the pieces of
+an XML document should be released after it has been
+consumed in e.g. xml.str().
+
+Keeping variables around beyond their end-of-life-span
+can be marked with the proper 'keep'.
[EMAIL PROTECTED]
+static int
+OPTkeepVariable(MalBlkPtr mb, InstrPtr p, int idx){
+       static char *keep=0;
+       if( keep == 0)
+               keep= putName("keep",4);
+       return isPropertyDefined( getProps(mb, getArg(p,idx)),keep);
+}
 @c
 static int
 OPTgarbageCollectorImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
@@ -181,7 +198,7 @@
                                        if (getArg(p, j) == getArg(p, k))
                                                done++;
 
-                               if (done == 0 ){
+                               if (done == 0 && !OPTkeepVariable(mb,p,j)){
 #ifdef DEBUG_OPT_GARBAGE
                                printf("remove the variable %s at %d\n", 
getArgName(mb,p,j),i);
 #endif

Index: opt_mergetable.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_mergetable.mx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- opt_mergetable.mx   19 Aug 2007 19:07:52 -0000      1.15
+++ opt_mergetable.mx   21 Aug 2007 10:41:35 -0000      1.16
@@ -99,7 +99,7 @@
 scheduling decision.
 
 Alternative, the system could use MAT iterators to avoid it.
-At the cost of more complex program analysis.
+At the cost of more complex program analysis afterwards.
 
 @example
        ji:= bat.new(:oid,:int);
@@ -200,48 +200,15 @@
        }
        return cnt;
 }
-
-static int
-OPTmergetableImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){
-       InstrPtr *old=0, q,r, *mat;
-       int oldtop,fm,i,k,m,mtop=0, *mvar,tpe;
-       int size,match,actions=0;
-
-#ifdef DEBUG_OPT_MERGETABLE
-       stream_printf(GDKout,"Start MAT optimizer\n");
-       printFunction(GDKout, mb, 0);
-#endif
-
-       old = mb->stmt;
-       oldtop= mb->stop;
-       size = (mb->stop *1.2 < mb->ssize)? mb->ssize: (int) (mb->stop *1.2);
-       mb->stmt = (InstrPtr *) GDKzalloc(size  * sizeof(InstrPtr));
-       mb->ssize = size ;
-       mb->stop = 0;
-
-       /* the number of MATs is limited to the variable stack*/
-       mat= (InstrPtr*) alloca(mb->vtop * sizeof(InstrPtr));
-       memset((char*) mat, 0, mb->vtop * sizeof(InstrPtr));
-       mvar= (int*) alloca(mb->vtop * sizeof(int));
-       memset((char*) mvar, 0, mb->vtop * sizeof(InstrPtr));
-
-       for( i=0; i<oldtop; i++){
-               p= old[i];
-               if( (getModuleId(p)== matRef && getFunctionId(p)==newRef) ||
-                       (getModuleId(p)== matRef && getFunctionId(p)==packRef) 
){
-                       mat[mtop]= p;
-                       mvar[mtop] = getArg(p,0);
-                       mtop++;
-                       pushInstruction(mb,p);
-                       continue;
-               }
 @-
 A sql.bind() operation should be trapped to inspect the partition catalog
 for definitions. For now we simulate a partitioned table, comprised
 of the original base and an empty one.
 @c
-               if( (getModuleId(p)== sqlRef && getFunctionId(p)==bindRef)){
-                       InstrPtr p2;
+static InstrPtr
+MATpartitionTableDummy(MalBlkPtr mb, InstrPtr p)
+{
+                       InstrPtr q,r,p2;
                        int v= getArg(p,0);
 
                        freezeVarType(mb,getArg(p,0));
@@ -275,6 +242,46 @@
                        printInstruction(GDKout,mb,q,0);
                        printInstruction(GDKout,mb,r,0);
 #endif
+               return q;
+}
+
+static int
+OPTmergetableImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){
+       InstrPtr *old=0, q,r, *mat;
+       int oldtop,fm,i,k,m,mtop=0, *mvar,tpe;
+       int size,match,actions=0;
+
+#ifdef DEBUG_OPT_MERGETABLE
+       stream_printf(GDKout,"Start MAT optimizer\n");
+       printFunction(GDKout, mb, 0);
+#endif
+
+       old = mb->stmt;
+       oldtop= mb->stop;
+       size = (mb->stop *1.2 < mb->ssize)? mb->ssize: (int) (mb->stop *1.2);
+       mb->stmt = (InstrPtr *) GDKzalloc(size  * sizeof(InstrPtr));
+       mb->ssize = size ;
+       mb->stop = 0;
+
+       /* the number of MATs is limited to the variable stack*/
+       mat= (InstrPtr*) alloca(mb->vtop * sizeof(InstrPtr));
+       memset((char*) mat, 0, mb->vtop * sizeof(InstrPtr));
+       mvar= (int*) alloca(mb->vtop * sizeof(int));
+       memset((char*) mvar, 0, mb->vtop * sizeof(InstrPtr));
+
+       for( i=0; i<oldtop; i++){
+               p= old[i];
+               if( (getModuleId(p)== matRef && getFunctionId(p)==newRef) ||
+                       (getModuleId(p)== matRef && getFunctionId(p)==packRef) 
){
+                       mat[mtop]= p;
+                       mvar[mtop] = getArg(p,0);
+                       mtop++;
+                       pushInstruction(mb,p);
+                       continue;
+               }
+               if( (getModuleId(p)== sqlRef && getFunctionId(p)==bindRef)){
+                       int v= getArg(p,0);
+                       q= MATpartitionTableDummy(mb,p);
                        mat[mtop]= q;
                        mvar[mtop] = v;
                        mtop++;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to