Changeset: 48aa18ba7e8d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/48aa18ba7e8d
Modified Files:
        monetdb5/optimizer/opt_bincopyfrom.c
        monetdb5/optimizer/opt_fastpath.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
Branch: default
Log Message:

Small optimization step


diffs (141 lines):

diff --git a/monetdb5/optimizer/opt_bincopyfrom.c 
b/monetdb5/optimizer/opt_bincopyfrom.c
--- a/monetdb5/optimizer/opt_bincopyfrom.c
+++ b/monetdb5/optimizer/opt_bincopyfrom.c
@@ -30,8 +30,6 @@ OPTbincopyfromImplementation(Client cntx
        (void)stk;
        (void)pci;
 
-       const char *importTableRef = putName("importTable");
-
        int found_at = -1;
        for (int i = 0; i < mb->stop; i++) {
                InstrPtr p = getInstrPtr(mb, i);
diff --git a/monetdb5/optimizer/opt_fastpath.c 
b/monetdb5/optimizer/opt_fastpath.c
--- a/monetdb5/optimizer/opt_fastpath.c
+++ b/monetdb5/optimizer/opt_fastpath.c
@@ -44,6 +44,8 @@
 #include "opt_wlc.h"
 #include "optimizer_private.h"
 #include "mal_interpreter.h"
+#include "mal_profiler.h"
+#include "opt_prelude.h"
 
 str
 OPTminimalfastImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr p)
@@ -52,20 +54,32 @@ OPTminimalfastImplementation(Client cntx
        char buf[256];
        lng usec = GDKusec();
        str msg = MAL_SUCCEED;
+       InstrPtr q;
+       int i, bincopy = 0, generator = 0, multiplex = 0;
 
        (void)cntxt;
        (void)stk;
        (void) p;
 
+       /* perform a single scan through the plan to determine which optimizer 
steps to skip */
+       for( i=0; i<mb->stop; i++){
+               q = getInstrPtr(mb,i);
+               if (q->modname == sqlRef && q->fcnname == importTableRef) 
+                       bincopy= 1;
+               if( getModuleId(q) == generatorRef)
+                       generator = 1;
+               if ( getFunctionId(q) == multiplexRef)
+                       multiplex = 1;
+       }
 
        msg = OPTinlineImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTremapImplementation(cntxt, mb, stk, p);
-       if( msg == MAL_SUCCEED) msg = OPTbincopyfromImplementation(cntxt, mb, 
stk, p);
+       if( bincopy && msg == MAL_SUCCEED) msg = 
OPTbincopyfromImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTdeadcodeImplementation(cntxt, mb, stk, 
p);
-       if( msg == MAL_SUCCEED) msg = OPTmultiplexImplementation(cntxt, mb, 
stk, p);
-       if( msg == MAL_SUCCEED) msg = OPTgeneratorImplementation(cntxt, mb, 
stk, p);
-       if( msg == MAL_SUCCEED) msg = OPTprofilerImplementation(cntxt, mb, stk, 
p);
-       //if( msg == MAL_SUCCEED) msg = OPTcandidatesImplementation(cntxt, mb, 
stk, p);
+       if( multiplex && msg == MAL_SUCCEED) msg = 
OPTmultiplexImplementation(cntxt, mb, stk, p);
+       if( generator &&  msg == MAL_SUCCEED) msg = 
OPTgeneratorImplementation(cntxt, mb, stk, p);
+       if( malProfileMode &&  msg == MAL_SUCCEED) msg = 
OPTprofilerImplementation(cntxt, mb, stk, p);
+       if( malProfileMode &&  msg == MAL_SUCCEED) msg = 
OPTcandidatesImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTgarbageCollectorImplementation(cntxt, 
mb, stk, p);
 
        /* Defense line against incorrect plans  handled by optimizer steps */
@@ -86,12 +100,24 @@ OPTdefaultfastImplementation(Client cntx
        char buf[256];
        lng usec = GDKusec();
        str msg = MAL_SUCCEED;
+    InstrPtr q;
+    int i, bincopy = 0, generator = 0, multiplex = 0;
 
        (void)cntxt;
        (void)stk;
        (void) p;
 
 
+       /* perform a single scan through the plan to determine which optimizer 
steps to skip */
+       for( i=0; i<mb->stop; i++){
+               q = getInstrPtr(mb,i);
+               if (q->modname == sqlRef && q->fcnname == importTableRef) 
+                       bincopy= 1;
+               if( getModuleId(q) == generatorRef)
+                       generator = 1;
+               if ( getFunctionId(q) == multiplexRef)
+                       multiplex = 1;
+       }
        msg = OPTinlineImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTremapImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTcostModelImplementation(cntxt, mb, 
stk, p);
@@ -104,7 +130,7 @@ OPTdefaultfastImplementation(Client cntx
        if( msg == MAL_SUCCEED) msg = OPTaliasesImplementation(cntxt, mb, stk, 
p);
        if( msg == MAL_SUCCEED) msg = OPTmitosisImplementation(cntxt, mb, stk, 
p);
        if( msg == MAL_SUCCEED) msg = OPTmergetableImplementation(cntxt, mb, 
stk, p);
-       if( msg == MAL_SUCCEED) msg = OPTbincopyfromImplementation(cntxt, mb, 
stk, p);
+       if( bincopy && msg == MAL_SUCCEED) msg = 
OPTbincopyfromImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTaliasesImplementation(cntxt, mb, stk, 
p);
        if( msg == MAL_SUCCEED) msg = OPTconstantsImplementation(cntxt, mb, 
stk, p);
        if( msg == MAL_SUCCEED) msg = OPTcommonTermsImplementation(cntxt, mb, 
stk, p);
@@ -114,10 +140,10 @@ OPTdefaultfastImplementation(Client cntx
        if( msg == MAL_SUCCEED) msg = OPTmatpackImplementation(cntxt, mb, stk, 
p);
        if( msg == MAL_SUCCEED) msg = OPTdataflowImplementation(cntxt, mb, stk, 
p);
        if( msg == MAL_SUCCEED) msg = OPTquerylogImplementation(cntxt, mb, stk, 
p);
-       if( msg == MAL_SUCCEED) msg = OPTmultiplexImplementation(cntxt, mb, 
stk, p);
-       if( msg == MAL_SUCCEED) msg = OPTgeneratorImplementation(cntxt, mb, 
stk, p);
-       if( msg == MAL_SUCCEED) msg = OPTprofilerImplementation(cntxt, mb, stk, 
p);
-       if( msg == MAL_SUCCEED) msg = OPTcandidatesImplementation(cntxt, mb, 
stk, p);
+       if( multiplex && msg == MAL_SUCCEED) msg = 
OPTmultiplexImplementation(cntxt, mb, stk, p);
+       if( generator && msg == MAL_SUCCEED) msg = 
OPTgeneratorImplementation(cntxt, mb, stk, p);
+       if( malProfileMode &&  msg == MAL_SUCCEED) msg = 
OPTprofilerImplementation(cntxt, mb, stk, p);
+       if( malProfileMode &&  msg == MAL_SUCCEED) msg = 
OPTcandidatesImplementation(cntxt, mb, stk, p);
        if( msg == MAL_SUCCEED) msg = OPTdeadcodeImplementation(cntxt, mb, stk, 
p);
        if( msg == MAL_SUCCEED) msg = OPTpostfixImplementation(cntxt, mb, stk, 
p);
        // if( msg == MAL_SUCCEED) msg = OPTjitImplementation(cntxt, mb, stk, 
p);
diff --git a/monetdb5/optimizer/opt_prelude.c b/monetdb5/optimizer/opt_prelude.c
--- a/monetdb5/optimizer/opt_prelude.c
+++ b/monetdb5/optimizer/opt_prelude.c
@@ -152,6 +152,7 @@ const char *hgeRef;
 const char *identityRef;
 const char *ifthenelseRef;
 const char *importColumnRef;
+const char *importTableRef;
 const char *intersectcandRef;
 const char *intersectRef;
 const char *intRef;
@@ -459,6 +460,7 @@ void optimizerInit(void)
        identityRef = putName("identity");
        ifthenelseRef = putName("ifthenelse");
        importColumnRef = putName("importColumn");
+       importTableRef = putName("importTable");
        intersectcandRef= putName("intersectcand");
        intersectRef = putName("intersect");
        intRef = putName("int");
diff --git a/monetdb5/optimizer/opt_prelude.h b/monetdb5/optimizer/opt_prelude.h
--- a/monetdb5/optimizer/opt_prelude.h
+++ b/monetdb5/optimizer/opt_prelude.h
@@ -149,6 +149,7 @@ mal_export  const char *hgeRef;
 mal_export  const char *identityRef;
 mal_export  const char *ifthenelseRef;
 mal_export  const char *importColumnRef;
+mal_export  const char *importTableRef;
 mal_export  const char *intersectcandRef;
 mal_export  const char *intersectRef;
 mal_export  const char *intRef;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to