Changeset: 8ea09480b1ea for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8ea09480b1ea
Added Files:
monetdb5/optimizer/opt_strimps.c
monetdb5/optimizer/opt_strimps.h
Modified Files:
monetdb5/modules/mal/strimps.c
monetdb5/optimizer/CMakeLists.txt
monetdb5/optimizer/opt_pipes.c
monetdb5/optimizer/opt_prelude.c
monetdb5/optimizer/opt_prelude.h
monetdb5/optimizer/opt_wrapper.c
monetdb5/optimizer/optimizer.c
Branch: string_imprints
Log Message:
Scaffolding for strimp optimizer
diffs (242 lines):
diff --git a/monetdb5/modules/mal/strimps.c b/monetdb5/modules/mal/strimps.c
--- a/monetdb5/modules/mal/strimps.c
+++ b/monetdb5/modules/mal/strimps.c
@@ -86,10 +86,10 @@ PATstrimpCreate(Client cntxt, MalBlkPtr
bid = *getArgReference_bat(stk, pci, 1);
if ((b = BATdescriptor(bid)) == NULL)
- throw(MAL, "strimps.strimpHeader", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
+ throw(MAL, "strimps.strimpCreate", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
if(STRMPcreate(b) != GDK_SUCCEED)
- throw(MAL, "strimps.strimpHistogram", SQLSTATE(HY002)
OPERATION_FAILED);
+ throw(MAL, "strimps.strimpCreate", SQLSTATE(HY002)
OPERATION_FAILED);
// *getArgReference_lng(stk, pci, 0) = 0;
return MAL_SUCCEED;
diff --git a/monetdb5/optimizer/CMakeLists.txt
b/monetdb5/optimizer/CMakeLists.txt
--- a/monetdb5/optimizer/CMakeLists.txt
+++ b/monetdb5/optimizer/CMakeLists.txt
@@ -49,6 +49,7 @@ target_sources(optimizer
opt_postfix.c opt_postfix.h
opt_volcano.c opt_volcano.h
opt_fastpath.c opt_fastpath.h
+ opt_strimps.c opt_strimps.h
opt_wrapper.c
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/opt_pipes.h)
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
@@ -49,7 +49,20 @@ static struct PIPELINES {
"optimizer.deadcode();"
"optimizer.multiplex();"
"optimizer.generator();"
- "optimizer.profiler();"
+ "optimizer.profiler();"
+ //"optimizer.candidates();" only for decoration in explain
+ //"optimizer.mask();"
+ "optimizer.garbageCollector();",
+ "stable", NULL, 1},
+ {"minimal_strimps_pipe",
+ "optimizer.inline();"
+ "optimizer.remap();"
+ "optimizer.bincopyfrom();"
+ "optimizer.strimps();"
+ "optimizer.deadcode();"
+ "optimizer.multiplex();"
+ "optimizer.generator();"
+ "optimizer.profiler();"
//"optimizer.candidates();" only for decoration in explain
//"optimizer.mask();"
"optimizer.garbageCollector();",
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
@@ -188,6 +188,7 @@ const char *minusRef;
const char *mirrorRef;
const char *mitosisRef;
const char *mkeyRef;
+const char *mkstrimpsRef;
const char *mmathRef;
const char *modRef;
const char *mtimeRef;
@@ -279,6 +280,8 @@ const char *startRef;
const char *starttraceRef;
const char *stoptraceRef;
const char *streamsRef;
+const char *strimpFilterSelectRef;
+const char *strimpsRef;
const char *strRef;
const char *subavgRef;
const char *subcountRef;
@@ -495,6 +498,7 @@ void optimizerInit(void)
mirrorRef = putName("mirror");
mitosisRef = putName("mitosis");
mkeyRef = putName("mkey");
+ mkstrimpsRef = putName("mkstrimp");
mmathRef = putName("mmath");
modRef = putName("%");
mtimeRef = putName("mtime");
@@ -586,6 +590,7 @@ void optimizerInit(void)
starttraceRef = putName("starttrace");
stoptraceRef = putName("stoptrace");
streamsRef = putName("streams");
+ strimpsRef = putName("strimps");
strRef = putName("str");
subavgRef = putName("subavg");
subcountRef = putName("subcount");
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
@@ -186,6 +186,7 @@ mal_export const char *minusRef;
mal_export const char *mirrorRef;
mal_export const char *mitosisRef;
mal_export const char *mkeyRef;
+mal_export const char *mkstrimpsRef;
mal_export const char *mmathRef;
mal_export const char *modRef;
mal_export const char *mtimeRef;
@@ -278,6 +279,8 @@ mal_export const char *startRef;
mal_export const char *starttraceRef;
mal_export const char *stoptraceRef;
mal_export const char *streamsRef;
+mal_export const char *strimpFilterSelectRef;
+mal_export const char *strimpsRef;
mal_export const char *strRef;
mal_export const char *subavgRef;
mal_export const char *subcountRef;
diff --git a/monetdb5/optimizer/opt_strimps.c b/monetdb5/optimizer/opt_strimps.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_strimps.c
@@ -0,0 +1,76 @@
+/*
+ * 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 - 2021 MonetDB B.V.
+ */
+
+/*
+ * Selectively inject serialization operations when we know the
+ * raw footprint of the query exceeds 80% of RAM.
+ */
+
+#include "monetdb_config.h"
+#include "mal_instruction.h"
+#include "opt_strimps.h"
+
+// delaying the startup should not be continued throughout the plan
+// after the startup phase there should be intermediate work to do
+//A heuristic to check it
+#define MAXdelays 128
+
+str
+OPTstrimpsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci)
+{
+ int i, limit;
+ // int mvcvar = -1;
+ int count=0;
+ InstrPtr p,q, *old = mb->stmt;
+ char buf[256];
+ lng usec = GDKusec();
+ str msg = MAL_SUCCEED;
+
+ (void) pci;
+ (void) cntxt;
+ (void) stk; /* to fool compilers */
+
+
+ if ( mb->inlineProp )
+ return MAL_SUCCEED;
+
+ limit= mb->stop;
+ if ( newMalBlkStmt(mb, mb->ssize + 20) < 0)
+ throw(MAL,"optimizer.volcano", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+
+ for (i = 0; i < limit; i++) {
+ p = old[i];
+ if (getModuleId(p) == algebraRef && getFunctionId(p) ==
likeselectRef) {
+ q = newInstruction(0, strimpsRef, mkstrimpsRef); /*
This should be void? */
+ setDestVar(q, newTmpVariable(mb, TYPE_void));
+ q = addArgument(mb, q, getArg(p, 1));
+
+ pushInstruction(mb, q);
+ typeChecker(cntxt->usermodule, mb, q, mb->stop-1, TRUE);
+
+ count++;
+ }
+ pushInstruction(mb, p);
+ }
+
+ /* Defense line against incorrect plans */
+ if( count){
+ msg = chkTypes(cntxt->usermodule, mb, FALSE);
+ if (!msg)
+ msg = chkFlow(mb);
+ if (!msg)
+ msg = chkDeclarations(mb);
+ }
+ /* keep all actions taken as a post block comment */
+ usec = GDKusec()- usec;
+ snprintf(buf,256,"%-20s actions=%2d time=" LLFMT "
usec","volcano",count,usec);
+ newComment(mb,buf);
+ if( count > 0)
+ addtoMalBlkHistory(mb);
+ return msg;
+}
diff --git a/monetdb5/optimizer/opt_strimps.h b/monetdb5/optimizer/opt_strimps.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_strimps.h
@@ -0,0 +1,18 @@
+/*
+ * 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 - 2021 MonetDB B.V.
+ */
+
+#ifndef _OPT_STRIMPS_
+#define _OPT_STRIMPS_
+#include "opt_prelude.h"
+#include "opt_support.h"
+#include "mal_exception.h"
+
+extern str OPTstrimpsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+
+
+#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
@@ -53,6 +53,7 @@
#include "opt_reorder.h"
#include "opt_volcano.h"
#include "opt_fastpath.h"
+#include "opt_strimps.h"
#include "opt_wlc.h"
#include "optimizer_private.h"
@@ -95,6 +96,7 @@ struct{
{"remap", &OPTremapImplementation,0,0},
{"remoteQueries", &OPTremoteQueriesImplementation,0,0},
{"reorder", &OPTreorderImplementation,0,0},
+ {"strimps", &OPTstrimpsImplementation,0,0},
{"volcano", &OPTvolcanoImplementation,0,0},
{"wlc", &OPTwlcImplementation,0,0},
{0,0,0,0}
diff --git a/monetdb5/optimizer/optimizer.c b/monetdb5/optimizer/optimizer.c
--- a/monetdb5/optimizer/optimizer.c
+++ b/monetdb5/optimizer/optimizer.c
@@ -130,6 +130,7 @@ static mel_func optimizer_init_funcs[] =
optwrapper_pattern("oltp", "Inject the OLTP locking primitives"),
optwrapper_pattern("wlc", "Inject the workload capture-replay primitives"),
optwrapper_pattern("postfix", "Postfix the plan,e.g. pushing projections"),
+ optwrapper_pattern("strimps", "Use strimps index if appropriate"),
pattern("optimizer", "mask", OPTwrapper, false, "", args(1,1, arg("",str))),
pattern("optimizer", "mask", OPTwrapper, false, "Manipulate the MSK objects",
args(1,3, arg("",str),arg("mod",str),arg("fcn",str))),
{ .imp=NULL }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list