Changeset: afdeeeb3bbbb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/afdeeeb3bbbb
Modified Files:
        clients/Tests/exports.stable.out
        clients/odbc/tests/ODBCmetadata.c
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_namespace.c
        monetdb5/mal/mal_namespace.h
        monetdb5/optimizer/opt_fastpath.c
        monetdb5/optimizer/opt_matpack.c
        monetdb5/optimizer/opt_mergetable.c
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_reorder.c
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
        sql/backends/monet5/sql_optimizer.c
Branch: default
Log Message:

Fix default_fast pipeline, and use it instead of default_pipe pipeline.
Also, no_mitosis_pipe now uses the default_fast pipeline since it has a
no_mitosis option.


diffs (truncated from 345 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -899,6 +899,7 @@ const char dblRef[];
 void debugFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int flg, int 
first, int size);
 const char decompressRef[];
 int defConstant(MalBlkPtr mb, int type, ValPtr cst);
+const char defaultfastRef[];
 const char defineRef[];
 void delArgument(InstrPtr p, int varid);
 const char deleteRef[];
diff --git a/clients/odbc/tests/ODBCmetadata.c 
b/clients/odbc/tests/ODBCmetadata.c
--- a/clients/odbc/tests/ODBCmetadata.c
+++ b/clients/odbc/tests/ODBCmetadata.c
@@ -1535,7 +1535,7 @@ main(int argc, char **argv)
        compareResult(stmt, ret, "EXPLAIN SELECT * from odbctst.\"LINES\"",
            nrServerThreads > 1 ?
                "Resultset with 1 columns\n"
-               "Resultset with 46 rows\n"
+               "Resultset with 17 rows\n"
                "mal\n"
                "WLONGVARCHAR(174)\n"
                "function user.main():void;\n"
@@ -1553,13 +1553,10 @@ main(int argc, char **argv)
                "\n"
                "    X_37:int := sql.resultSet(X_38:bat[:str], X_39:bat[:str], 
X_40:bat[:str], X_41:bat[:int], X_42:bat[:int], X_33:bat[:int], X_34:bat[:int], 
X_35:bat[:int], X_36:bat[:int]);\n"
                "end user.main;\n"
-               "\n\n\n\n\n\n\n\n\n\n"
-               "\n\n\n\n\n\n\n\n\n\n"
-               "\n\n\n\n\n\n\n\n\n\n"
-               "\n"
+               "\n\n"
            :
                "Resultset with 1 columns\n"
-               "Resultset with 44 rows\n"
+               "Resultset with 15 rows\n"
                "mal\n"
                "WLONGVARCHAR(174)\n"
                "function user.main():void;\n"
@@ -1575,10 +1572,7 @@ main(int argc, char **argv)
                "    X_42:bat[:int] := bat.pack(0:int, 0:int, 0:int, 3:int);\n"
                "    X_37:int := sql.resultSet(X_38:bat[:str], X_39:bat[:str], 
X_40:bat[:str], X_41:bat[:int], X_42:bat[:int], X_33:bat[:int], X_34:bat[:int], 
X_35:bat[:int], X_36:bat[:int]);\n"
                "end user.main;\n"
-               "\n\n\n\n\n\n\n\n\n\n"
-               "\n\n\n\n\n\n\n\n\n\n"
-               "\n\n\n\n\n\n\n\n\n\n"
-               "\n");
+               "\n\n");
 
        // test TRACE SELECT query.
        // This will return two resultsets: first with the query results and 
next with the trace results
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -69,6 +69,7 @@ typedef struct CLIENT {
        exit_client exitClient;
        /* if set to 'S' it will put the process to sleep */
        bool sqlprofiler;                       /* control off-line sql 
performance monitoring */
+       bool no_mitosis;                        /* don't use mitosis optimizer 
*/
        /*
         * Each session comes with resource limitations and predefined settings.
         */
diff --git a/monetdb5/mal/mal_namespace.c b/monetdb5/mal/mal_namespace.c
--- a/monetdb5/mal/mal_namespace.c
+++ b/monetdb5/mal/mal_namespace.c
@@ -152,6 +152,7 @@ const char cume_distRef[] = "cume_dist";
 const char dataflowRef[] = "dataflow";
 const char dblRef[] = "dbl";
 const char decompressRef[] = "decompress";
+const char defaultfastRef[] = "defaultfast";
 const char defineRef[] = "define";
 const char deleteRef[] = "delete";
 const char deltaRef[] = "delta";
@@ -418,6 +419,7 @@ initNamespace(void)
        fixName(dataflowRef);
        fixName(dblRef);
        fixName(decompressRef);
+       fixName(defaultfastRef);
        fixName(defineRef);
        fixName(deleteRef);
        fixName(deltaRef);
diff --git a/monetdb5/mal/mal_namespace.h b/monetdb5/mal/mal_namespace.h
--- a/monetdb5/mal/mal_namespace.h
+++ b/monetdb5/mal/mal_namespace.h
@@ -77,6 +77,7 @@ mal_export const char cume_distRef[];
 mal_export const char dataflowRef[];
 mal_export const char dblRef[];
 mal_export const char decompressRef[];
+mal_export const char defaultfastRef[];
 mal_export const char defineRef[];
 mal_export const char deleteRef[];
 mal_export const char deltaRef[];
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,14 +44,12 @@
 #include "optimizer_private.h"
 #include "mal_interpreter.h"
 
-#define optcall(TEST, OPT)                                                     
                                        \
+#define optcall(OPT)                                                           
                                        \
        do {                                                                    
                                                        \
-               if (TEST) {                                                     
                                                        \
-                       if ((msg = OPT(cntxt, mb, stk, pci)) != MAL_SUCCEED)    
        \
-                               goto bailout;                                   
                                                \
-                       actions += *(int*)getVarValue(mb, getArg(pci, pci->argc 
- 1)); \
-                       delArgument(pci, pci->argc - 1); /* keep number of argc 
low, so 'pci' is not reallocated */ \
-               }                                                               
                                                                \
+               if ((msg = OPT(cntxt, mb, stk, pci)) != MAL_SUCCEED)            
        \
+                       goto bailout;                                           
                                                \
+               actions += *(int*)getVarValue(mb, getArg(pci, pci->argc - 1));  
\
+               delArgument(pci, pci->argc - 1); /* keep number of argc low, so 
'pci' is not reallocated */ \
        } while (0)
 
 str
@@ -77,16 +75,19 @@ OPTminimalfastImplementation(Client cntx
                }
        }
 
-       optcall(true, OPTinlineImplementation);
-       optcall(true, OPTremapImplementation);
-       optcall(true, OPTemptybindImplementation);
-       optcall(true, OPTdeadcodeImplementation);
-       optcall(true, OPTforImplementation);
-       optcall(true, OPTdictImplementation);
-       optcall(multiplex, OPTmultiplexImplementation);
-       optcall(generator, OPTgeneratorImplementation);
-       optcall(profilerStatus, OPTprofilerImplementation);
-       optcall(true, OPTgarbageCollectorImplementation);
+       optcall(OPTinlineImplementation);
+       optcall(OPTremapImplementation);
+       optcall(OPTemptybindImplementation);
+       optcall(OPTdeadcodeImplementation);
+       optcall(OPTforImplementation);
+       optcall(OPTdictImplementation);
+       if (multiplex)
+               optcall(OPTmultiplexImplementation);
+       if (generator)
+               optcall(OPTgeneratorImplementation);
+       if (profilerStatus)
+               optcall(OPTprofilerImplementation);
+       optcall(OPTgarbageCollectorImplementation);
 
        /* Defense line against incorrect plans  handled by optimizer steps */
        /* keep actions taken as a fake argument */
@@ -118,36 +119,44 @@ OPTdefaultfastImplementation(Client cntx
                }
        }
 
-       optcall(true, OPTinlineImplementation);
-       optcall(true, OPTremapImplementation);
-       optcall(true, OPTcostModelImplementation);
-       optcall(true, OPTcoercionImplementation);
-       optcall(true, OPTaliasesImplementation);
-       optcall(true, OPTevaluateImplementation);
-       optcall(true, OPTemptybindImplementation);
-       optcall(true, OPTdeadcodeImplementation);
-       optcall(true, OPTpushselectImplementation);
-       optcall(true, OPTaliasesImplementation);
-       optcall(true, OPTforImplementation);
-       optcall(true, OPTdictImplementation);
-       optcall(true, OPTmitosisImplementation);
-       optcall(true, OPTmergetableImplementation);
-       optcall(true, OPTaliasesImplementation);
-       optcall(true, OPTconstantsImplementation);
-       optcall(true, OPTcommonTermsImplementation);
-       optcall(true, OPTprojectionpathImplementation);
-       optcall(true, OPTdeadcodeImplementation);
-       optcall(true, OPTmatpackImplementation);
-       optcall(true, OPTreorderImplementation);
-       optcall(true, OPTdataflowImplementation);
-       optcall(true, OPTquerylogImplementation);
-       optcall(multiplex, OPTmultiplexImplementation);
-       optcall(generator, OPTgeneratorImplementation);
-       optcall(profilerStatus, OPTcandidatesImplementation);
-       optcall(true, OPTdeadcodeImplementation);
-       optcall(true, OPTpostfixImplementation);
-       optcall(profilerStatus, OPTprofilerImplementation);
-       optcall(true, OPTgarbageCollectorImplementation);
+       optcall(OPTinlineImplementation);
+       optcall(OPTremapImplementation);
+       optcall(OPTcostModelImplementation);
+       optcall(OPTcoercionImplementation);
+       optcall(OPTaliasesImplementation);
+       optcall(OPTevaluateImplementation);
+       optcall(OPTemptybindImplementation);
+       optcall(OPTdeadcodeImplementation);
+       optcall(OPTpushselectImplementation);
+       optcall(OPTaliasesImplementation);
+       optcall(OPTforImplementation);
+       optcall(OPTdictImplementation);
+       if (!cntxt->no_mitosis) {
+               optcall(OPTmitosisImplementation);
+               optcall(OPTmergetableImplementation); /* depends on mitosis */
+       }
+       optcall(OPTaliasesImplementation);
+       optcall(OPTconstantsImplementation);
+       optcall(OPTcommonTermsImplementation);
+       optcall(OPTprojectionpathImplementation);
+       optcall(OPTdeadcodeImplementation);
+       if (!cntxt->no_mitosis) {
+               optcall(OPTmatpackImplementation); /* depends on mergetable */
+               optcall(OPTreorderImplementation); /* depends on mitosis */
+       }
+       optcall(OPTdataflowImplementation);
+       optcall(OPTquerylogImplementation);
+       if (multiplex)
+               optcall(OPTmultiplexImplementation);
+       if (generator)
+               optcall(OPTgeneratorImplementation);
+       if (profilerStatus)
+               optcall(OPTcandidatesImplementation);
+       optcall(OPTdeadcodeImplementation);
+       optcall(OPTpostfixImplementation);
+       if (profilerStatus)
+               optcall(OPTprofilerImplementation);
+       optcall(OPTgarbageCollectorImplementation);
 
        /* Defense line against incorrect plans  handled by optimizer steps */
        /* keep actions taken as a fake argument */
diff --git a/monetdb5/optimizer/opt_matpack.c b/monetdb5/optimizer/opt_matpack.c
--- a/monetdb5/optimizer/opt_matpack.c
+++ b/monetdb5/optimizer/opt_matpack.c
@@ -27,7 +27,7 @@ OPTmatpackImplementation(Client cntxt, M
        InstrPtr *old = NULL;
        str msg = MAL_SUCCEED;
 
-       if (isOptimizerUsed(mb, pci, mergetableRef) <= 0) {
+       if (!isOptimizerUsed(mb, pci, mergetableRef)) {
                goto wrapup;
        }
 
diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -2292,7 +2292,7 @@ OPTmergetableImplementation(Client cntxt
        char *group_input;
        str msg = MAL_SUCCEED;
 
-       if (isOptimizerUsed(mb, pci, mitosisRef) <= 0)
+       if (!isOptimizerUsed(mb, pci, mitosisRef))
                goto cleanup2;
        old = mb->stmt;
        oldtop = mb->stop;
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -74,6 +74,10 @@ static struct pipeline {
  * tools/mserver/mserver5.1) accordingly!
  */
        {"default_pipe",
+        /* NOTE: this pipeline is automatically replaced by the
+         * default_fast pipeline by the SQL layer, i.e. this list of
+         * optimizers isn't actually used (look in opt_fastpath.c
+         * instead) */
         (char *[]) {
                 "inline",
                 "remap",
@@ -127,6 +131,10 @@ static struct pipeline {
  * (see tools/mserver/mserver5.1) accordingly!
  */
        {"no_mitosis_pipe",
+        /* NOTE: this pipeline is automatically replaced by the
+         * default_fast pipeline by the SQL layer with the no_mitosis
+         * option set, i.e. this list of optimizers isn't actually used
+         * (look in opt_fastpath.c instead) */
         (char *[]) {
                 "inline",
                 "remap",
diff --git a/monetdb5/optimizer/opt_reorder.c b/monetdb5/optimizer/opt_reorder.c
--- a/monetdb5/optimizer/opt_reorder.c
+++ b/monetdb5/optimizer/opt_reorder.c
@@ -57,7 +57,7 @@ OPTreorderImplementation(Client cntxt, M
 
        for (i = 0; i < MAXSLICES; i++)
                top[i] = 0;
-       if (isOptimizerUsed(mb, pci, mitosisRef) <= 0) {
+       if (!isOptimizerUsed(mb, pci, mitosisRef)) {
                goto wrapup;
        }
        (void) cntxt;
diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c
--- a/monetdb5/optimizer/opt_support.c
+++ b/monetdb5/optimizer/opt_support.c
@@ -62,22 +62,24 @@ isOptimizerEnabled(MalBlkPtr mb, const c
 /*
  * Find if an optimizer 'opt' has run before the instruction 'p'.
  */
-int
+bool
 isOptimizerUsed(MalBlkPtr mb, InstrPtr p, const char *opt)
 {
        bool p_found = false;
 
+       if (getModuleId(p) == optimizerRef && getFunctionId(p) == 
defaultfastRef)
+               return true;
        for (int i = mb->stop - 1; i > 0; i--) {
                InstrPtr q = getInstrPtr(mb, i);
 
                p_found |= q == p;              /* the optimizer to find must 
come before p */
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to