Changeset: 7696825fab91 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7696825fab91
Added Files:
monetdb5/optimizer/opt_volcano.c
monetdb5/optimizer/opt_volcano.h
Modified Files:
monetdb5/optimizer/Makefile.ag
monetdb5/optimizer/opt_pipes.c
monetdb5/optimizer/opt_prelude.c
monetdb5/optimizer/opt_prelude.h
monetdb5/optimizer/opt_support.h
monetdb5/optimizer/opt_wrapper.c
Branch: default
Log Message:
Add Volcano-style dataflow patcher
If the database is much larger then memory, it makes
sense to regulate parallel execution to avoid the heavy
resource contention triggered by the mergetable.
This is realised by injecting data flow blocking operators.
They can be used to serialize execution of critical operators.
diffs (212 lines):
diff --git a/monetdb5/optimizer/Makefile.ag b/monetdb5/optimizer/Makefile.ag
--- a/monetdb5/optimizer/Makefile.ag
+++ b/monetdb5/optimizer/Makefile.ag
@@ -51,6 +51,7 @@ lib_optimizer = {
opt_support.c opt_support.h \
opt_pushselect.c opt_pushselect.h \
opt_profiler.c opt_profiler.h \
+ opt_volcano.c opt_volcano.h \
opt_wrapper.c
}
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
@@ -90,6 +90,37 @@ static struct PIPELINES {
"optimizer.profiler();"
"optimizer.garbageCollector();",
"stable", NULL, NULL, 1},
+/*
+ * Volcano style execution produces a sequence of blocks from the source
relation
+ */
+ {"volcano_pipe",
+ "optimizer.inline();"
+ "optimizer.candidates();"
+ "optimizer.remap();"
+ "optimizer.costModel();"
+ "optimizer.coercions();"
+ "optimizer.evaluate();"
+ "optimizer.aliases();"
+ "optimizer.pushselect();"
+ "optimizer.mitosis();"
+ "optimizer.mergetable();"
+ "optimizer.deadcode();"
+ "optimizer.aliases();"
+ "optimizer.constants();"
+ "optimizer.commonTerms();"
+ "optimizer.projectionpath();"
+ "optimizer.reorder();"
+ "optimizer.deadcode();"
+ "optimizer.reduce();"
+ "optimizer.matpack();"
+ "optimizer.dataflow();"
+ "optimizer.querylog();"
+ "optimizer.multiplex();"
+ "optimizer.generator();"
+ "optimizer.volcano();"
+ "optimizer.profiler();"
+ "optimizer.garbageCollector();",
+ "stable", NULL, NULL, 1},
/* The no_mitosis pipe line is (and should be kept!) identical to the
* default pipeline, except that optimizer mitosis is omitted. It is
* used mainly to make some tests work deterministically, and to check
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
@@ -35,6 +35,7 @@ str batmtimeRef;
str batmmathRef;
str batxmlRef;
str batsqlRef;
+str blockRef;
str bbpRef;
str tidRef;
str dateRef;
@@ -249,6 +250,7 @@ void optimizerInit(void)
batmmathRef = putName("batmmath",8);
batxmlRef = putName("batxml",6);
batsqlRef = putName("batsql",6);
+ blockRef = putName("block",5);
bbpRef = putName("bbp",3);
tidRef = putName("tid",3);
deltaRef = putName("delta",5);
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
@@ -33,6 +33,7 @@ opt_export str batmtimeRef;
opt_export str batmmathRef;
opt_export str batxmlRef;
opt_export str batsqlRef;
+opt_export str blockRef;
opt_export str bbpRef;
opt_export str tidRef;
opt_export str dateRef;
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
@@ -72,6 +72,7 @@
#define DEBUG_OPT_HEURISTIC 49
#define DEBUG_OPT_PUSHSELECT 51
#define DEBUG_OPT_JSON 54
+#define DEBUG_OPT_VOLCANO 10
#define DEBUG_OPT(X) ((lng) 1 << (X))
opt_export lng optDebug;
diff --git a/monetdb5/optimizer/opt_volcano.c b/monetdb5/optimizer/opt_volcano.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_volcano.c
@@ -0,0 +1,71 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ */
+
+/*
+ * Mark the production and use of candidate lists.
+ */
+
+#include "monetdb_config.h"
+#include "mal_instruction.h"
+#include "opt_volcano.h"
+
+int
+OPTvolcanoImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci)
+{
+ int i, limit;
+ int mvcvar = -1;
+ InstrPtr p,q, *old = mb->stmt;
+
+ (void) pci;
+ (void) cntxt;
+ (void) stk; /* to fool compilers */
+
+ if ( mb->inlineProp )
+ return 0;
+
+ limit= mb->stop;
+ if ( newMalBlkStmt(mb, mb->ssize + 20) < 0)
+ return 0;
+
+ for (i = 0; i < limit; i++) {
+ p = old[i];
+
+ pushInstruction(mb,p);
+ if( getModuleId(p) == sqlRef && getFunctionId(p)== mvcRef ){
+ mvcvar = getArg(p,0);
+ continue;
+ }
+
+ if( getModuleId(p) == algebraRef ){
+ if( getFunctionId(p) == subselectRef ||
+ getFunctionId(p) == thetasubselectRef ||
+ getFunctionId(p) == likesubselectRef ||
+ getFunctionId(p) == subjoinRef
+ ){
+ q= newStmt(mb, languageRef, blockRef);
+ q = pushArgument(mb,q,mvcvar);
+ q = pushArgument(mb,q,getArg(p,0));
+ mvcvar= getArg(q,0);
+ }
+ continue;
+ }
+ if( getModuleId(p) == sqlRef){
+ if ( getFunctionId(p) == bindRef ||
+ getFunctionId(p) == bindidxRef ||
+ getFunctionId(p)== tidRef ||
+ getFunctionId(p)== appendRef ||
+ getFunctionId(p)== updateRef ||
+ getFunctionId(p)== deleteRef
+ ){
+ setArg(p,p->retc,mvcvar);
+ }
+ }
+ }
+ GDKfree(old);
+ return 1;
+}
diff --git a/monetdb5/optimizer/opt_volcano.h b/monetdb5/optimizer/opt_volcano.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_volcano.h
@@ -0,0 +1,19 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ */
+
+#ifndef _OPT_VOLCANO_
+#define _OPT_VOLCANO_
+#include "opt_prelude.h"
+#include "opt_support.h"
+#include "mal_exception.h"
+
+opt_export int OPTvolcanoImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr p);
+
+#define OPTDEBUGvolcano if ( optDebug & ((lng) 1 <<DEBUG_OPT_VOLCANO) )
+
+#endif
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
@@ -55,6 +55,7 @@
#include "opt_remoteQueries.h"
#include "opt_reorder.h"
#include "opt_statistics.h"
+#include "opt_volcano.h"
struct{
str nme;
@@ -88,6 +89,7 @@ struct{
{"remap", &OPTremapImplementation},
{"remoteQueries", &OPTremoteQueriesImplementation},
{"reorder", &OPTreorderImplementation},
+ {"volcano", &OPTvolcanoImplementation},
{0,0}
};
opt_export str OPTwrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list