Changeset: 47c16cb9d27b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=47c16cb9d27b
Added Files:
        monetdb5/optimizer/opt_mutation.c
        monetdb5/optimizer/opt_mutation.h
Modified Files:
        monetdb5/optimizer/Makefile.ag
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/optimizer/optimizer.mal
        monetdb5/scheduler/run_mutation.c
Branch: mutation
Log Message:

Addition of the mutation optimizer
It simply injects the call to the corresponding
scheduler.


diffs (209 lines):

diff --git a/monetdb5/optimizer/Makefile.ag b/monetdb5/optimizer/Makefile.ag
--- a/monetdb5/optimizer/Makefile.ag
+++ b/monetdb5/optimizer/Makefile.ag
@@ -54,6 +54,7 @@ lib_optimizer = {
                opt_mergetable.c opt_mergetable.h \
                opt_mitosis.c opt_mitosis.h \
                opt_multiplex.c opt_multiplex.h \
+               opt_mutation.c opt_mutation.h \
                opt_octopus.c opt_octopus.h \
                opt_origin.c opt_origin.h \
                opt_pipes.c opt_pipes.h \
diff --git a/monetdb5/optimizer/opt_mutation.c 
b/monetdb5/optimizer/opt_mutation.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_mutation.c
@@ -0,0 +1,49 @@
+/* 
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ * 
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * 
+ * The Original Code is the MonetDB Database System.
+ * 
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2013 MonetDB B.V.
+ * All Rights Reserved.
+*/
+#include "monetdb_config.h"
+#include "opt_mutation.h"
+
+int 
+OPTmutationImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
+{
+       int i,limit, slimit;
+       InstrPtr *old= mb->stmt;
+
+       (void) cntxt;
+       (void) pci;
+       (void) stk;             /* to fool compilers */
+
+       if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
+               return 0;
+
+       limit= mb->stop;
+       slimit = mb->ssize;
+       if ( newMalBlkStmt(mb, mb->ssize) < 0)
+               return 0;
+
+       pushInstruction(mb, old[0]);
+       (void) newStmt(mb,schedulerRef, mutationRef);
+       for (i = 1; i < limit; i++) 
+               pushInstruction(mb,old[i]);
+       for(; i<slimit; i++)
+               if( old[i])
+                       freeInstruction(old[i]);
+       GDKfree(old);
+       return 1;
+}
diff --git a/monetdb5/optimizer/opt_mutation.h 
b/monetdb5/optimizer/opt_mutation.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_mutation.h
@@ -0,0 +1,31 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ * 
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * 
+ * The Original Code is the MonetDB Database System.
+ * 
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2013 MonetDB B.V.
+ * All Rights Reserved.
+*/
+#ifndef _OPT_MUTATION_
+#define _OPT_MUTATION_
+#include "opt_prelude.h"
+#include "opt_support.h"
+#include "mal_interpreter.h"
+#include "mal_instruction.h"
+#include "mal_function.h"
+
+opt_export int OPTmutationImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
+
+#define OPTDEBUGmutation  if ( optDebug & (1 <<DEBUG_OPT_MUTATION) )
+
+#endif
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
@@ -274,6 +274,35 @@ struct PIPELINES {
         "optimizer.multiplex();"
         "optimizer.garbageCollector();",
         "experimental", "OPTcompress", NULL, 1},
+/*
+ * The mutation optimizer modifies the plan at each call.
+ * It is a refinement of the default pipeline
+ */
+       {"mutation_pipe",
+        "optimizer.inline();"
+        "optimizer.remap();"
+        "optimizer.costModel();"
+        "optimizer.coercions();"
+        "optimizer.evaluate();"
+        "optimizer.emptySet();"
+        "optimizer.aliases();"
+        "optimizer.pushselect();"
+        //"optimizer.mitosis();"
+        //"optimizer.mergetable();"
+        //"optimizer.deadcode();"
+        "optimizer.commonTerms();"
+        //"optimizer.groups();"
+        "optimizer.joinPath();"
+        "optimizer.reorder();"
+        "optimizer.deadcode();"
+        "optimizer.reduce();"
+        "optimizer.matpack();"
+        "optimizer.dataflow();"
+        "optimizer.querylog();"
+        "optimizer.multiplex();"
+        "optimizer.mutation();"
+        "optimizer.garbageCollector();",
+        "stable", NULL, NULL, 1},
 /* sentinel */
        {NULL, NULL, NULL, NULL, NULL, 0}
 };
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
@@ -168,6 +168,7 @@ struct OPTcatalog {
 {"mergetable", 0,      0,      0,      DEBUG_OPT_MERGETABLE},
 {"mitosis",            0,      0,      0,      DEBUG_OPT_MITOSIS},
 {"multiplex",  0,      0,      0,      DEBUG_OPT_MULTIPLEX},
+{"mutation",   0,      0,      0,      DEBUG_OPT_MUTATION},
 {"octopus",            0,      0,      0,      DEBUG_OPT_OCTOPUS},
 {"origin",             0,      0,      0,      DEBUG_OPT_ORIGIN},
 {"peephole",   0,      0,      0,      DEBUG_OPT_PEEPHOLE},
diff --git a/monetdb5/optimizer/opt_support.h b/monetdb5/optimizer/opt_support.h
--- a/monetdb5/optimizer/opt_support.h
+++ b/monetdb5/optimizer/opt_support.h
@@ -64,6 +64,7 @@
 #define DEBUG_OPT_MACRO                                23
 #define DEBUG_OPT_MATPACK                      53
 #define DEBUG_OPT_MERGETABLE           24
+#define DEBUG_OPT_MUTATION                     54
 #define DEBUG_OPT_OCTOPUS                      25
 #define DEBUG_OPT_ORIGIN                       52
 #define DEBUG_OPT_PARTITIONS           26
diff --git a/monetdb5/optimizer/opt_wrapper.c b/monetdb5/optimizer/opt_wrapper.c
--- a/monetdb5/optimizer/opt_wrapper.c
+++ b/monetdb5/optimizer/opt_wrapper.c
@@ -61,6 +61,7 @@ All Rights Reserved.
 #include "opt_mergetable.h"
 #include "opt_mitosis.h"
 #include "opt_multiplex.h"
+#include "opt_mutation.h"
 #include "opt_octopus.h"
 #include "opt_origin.h"
 #include "opt_prejoin.h"
@@ -105,6 +106,7 @@ struct{
        {"mergetable", &OPTmergetableImplementation},
        {"mitosis", &OPTmitosisImplementation},
        {"multiplex", &OPTmultiplexImplementation},
+       {"mutation", &OPTmutationImplementation},
        {"octopus", &OPToctopusImplementation},
        {"origin", &OPToriginImplementation},
        {"prejoin", &OPTprejoinImplementation},
diff --git a/monetdb5/optimizer/optimizer.mal b/monetdb5/optimizer/optimizer.mal
--- a/monetdb5/optimizer/optimizer.mal
+++ b/monetdb5/optimizer/optimizer.mal
@@ -494,4 +494,12 @@ pattern optimizer.pushselect(mod:str, fc
 address OPTwrapper
 comment "Push selects down projections";
 
+#opt_mutation.mal
+
+pattern optimizer.mutation():str
+address OPTwrapper;
+pattern optimizer.mutation(mod:str, fcn:str):str
+address OPTwrapper
+comment "Prepare for plan mutation";
+
 optimizer.prelude();
diff --git a/monetdb5/scheduler/run_mutation.c 
b/monetdb5/scheduler/run_mutation.c
--- a/monetdb5/scheduler/run_mutation.c
+++ b/monetdb5/scheduler/run_mutation.c
@@ -88,7 +88,7 @@ RUNmutationInternal(Client cntxt, MalStk
 
                clk = GDKusec();
                // assume scheduler call is at line 1
-               //      msg = runMALsequence(cntxt, src, 
2,mutant->src->stop,stk,0,0);
+               //msg = runMALsequence(cntxt, src, 2,mutant->src->stop,stk,0,0);
                msg = runMAL(cntxt, src, 0, 0);
                mutant->calls++;
                mutant->runtime += GDKusec()- clk;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to