Repository: incubator-hawq
Updated Branches:
  refs/heads/master ecb6763f5 -> 5feb8c08e


HAWQ-1583. Vectorization execution framework init.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/5feb8c08
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/5feb8c08
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/5feb8c08

Branch: refs/heads/master
Commit: 5feb8c08e3b3de82a8e774959a96250bbbf5afb0
Parents: ecb6763
Author: Weinan Wang <wew...@pivotal.io>
Authored: Mon Jan 29 10:51:57 2018 +0800
Committer: amyrazz44 <a...@pivotal.io>
Committed: Mon Feb 12 13:02:51 2018 +0800

----------------------------------------------------------------------
 .gitignore                          |  3 ++
 contrib/vexecutor/Makefile          | 37 +++++++++++++++
 contrib/vexecutor/README            | 28 +++++++++++
 contrib/vexecutor/vexecutor.c       | 80 ++++++++++++++++++++++++++++++++
 contrib/vexecutor/vexecutor.h       | 31 +++++++++++++
 pom.xml                             |  1 +
 src/backend/executor/execProcnode.c | 14 +++++-
 src/include/executor/executor.h     | 10 ++++
 8 files changed, 203 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 24039c6..a8cd621 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,3 +66,6 @@ autom4te.cache/
 *.gcda
 *.gcno
 CodeCoverage*
+
+.vscode
+cmake-build-debug

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/contrib/vexecutor/Makefile
----------------------------------------------------------------------
diff --git a/contrib/vexecutor/Makefile b/contrib/vexecutor/Makefile
new file mode 100644
index 0000000..b4936cf
--- /dev/null
+++ b/contrib/vexecutor/Makefile
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+MODULE_big = vexecutor
+OBJS    = vexecutor.o
+
+PG_CXXFLAGS = -Wall -O0 -g -std=c++11
+PG_LIBS = $(libpq_pgport) 
+
+PG_CONFIG = pg_config
+
+ifdef USE_PGXS
+PGXS := $(shell pg_config --pgxs)
+include $(PGXS)
+else
+subdir = contrib/vexecutor
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
+
+SHLIB_LINK += $(filter -lz -lsnappy, $(LIBS))

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/contrib/vexecutor/README
----------------------------------------------------------------------
diff --git a/contrib/vexecutor/README b/contrib/vexecutor/README
new file mode 100644
index 0000000..ff9d251
--- /dev/null
+++ b/contrib/vexecutor/README
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+Build HAWQ Vectorized Executor steps:
+
+1. Make sure HAWQ compilation and installation success.
+
+2. execute "make ;make install" in vexecutor directory
+
+3. add library name "vexector" to "shared_preload_libraries" in 
postgresql.conf which has to copies allocated in master and segment data 
directories respectively. Make sure both of them is assigned.
+
+4. restart HAWQ cluster
+
+5. execute "set vectorized_executor_enable to on" in psql to activate 
vectorized execution

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/contrib/vexecutor/vexecutor.c
----------------------------------------------------------------------
diff --git a/contrib/vexecutor/vexecutor.c b/contrib/vexecutor/vexecutor.c
new file mode 100644
index 0000000..4f71d22
--- /dev/null
+++ b/contrib/vexecutor/vexecutor.c
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+#include "vexecutor.h"
+#include "utils/guc.h"
+
+PG_MODULE_MAGIC;
+
+/*
+ * hook function
+ */
+static PlanState* VExecInitNode(Plan *node,EState *eState,int eflags);
+static TupleTableSlot* VExecProcNode(PlanState *node);
+static bool VExecEndNode(PlanState *node);
+
+/*
+ * _PG_init is called when the module is loaded. In this function we save the
+ * previous utility hook, and then install our hook to pre-intercept calls to
+ * the copy command.
+ */
+void
+_PG_init(void)
+{
+       elog(DEBUG3, "PG INIT VEXECTOR");
+       vmthd.ExecInitNode_Hook = VExecInitNode;
+       vmthd.ExecProcNode_Hook = VExecProcNode;
+       vmthd.ExecEndNode_Hook = VExecEndNode;
+       DefineCustomBoolVariable("vectorized_executor_enable",
+                                gettext_noop("enable vectorized executor"),
+                                NULL,
+                                &vmthd.vectorized_executor_enable,
+                                PGC_USERSET,
+                                NULL,NULL);
+}
+
+/*
+ * _PG_fini is called when the module is unloaded. This function uninstalls the
+ * extension's hooks.
+ */
+void
+_PG_fini(void)
+{
+       elog(DEBUG3, "PG FINI VEXECTOR");
+       vmthd.ExecInitNode_Hook = NULL;
+       vmthd.ExecProcNode_Hook = NULL;
+       vmthd.ExecEndNode_Hook = NULL;
+}
+
+static PlanState* VExecInitNode(Plan *node,EState *eState,int eflags)
+{
+       elog(DEBUG3, "PG VEXEC INIT NODE");
+       return NULL;
+}
+static TupleTableSlot* VExecProcNode(PlanState *node)
+{
+       return NULL;
+}
+
+static bool VExecEndNode(PlanState *node)
+{
+       elog(DEBUG3, "PG VEXEC END NODE");
+       return false;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/contrib/vexecutor/vexecutor.h
----------------------------------------------------------------------
diff --git a/contrib/vexecutor/vexecutor.h b/contrib/vexecutor/vexecutor.h
new file mode 100644
index 0000000..d34fa83
--- /dev/null
+++ b/contrib/vexecutor/vexecutor.h
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __VEXECUTOR_H__
+#define __VEXECUTOR_H__
+
+#include "postgres.h"
+#include "fmgr.h"
+#include "executor/executor.h"
+
+/* Function declarations for extension loading and unloading */
+extern void _PG_init(void);
+extern void _PG_fini(void);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9803532..872aaa7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -214,6 +214,7 @@
               <exclude>src/timezone/**/*</exclude>
               <exclude>doc/src/sgml/fixrtf</exclude>
               <exclude>doc/**/*.sgml</exclude>
+              <exclude>contrib/vexecutor/*</exclude>
               <exclude>contrib/pgcrypto/*</exclude>
 
               <!-- Files which are not easy to have license headers. -->

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/src/backend/executor/execProcnode.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execProcnode.c 
b/src/backend/executor/execProcnode.c
index 0cc8716..70df3ec 100644
--- a/src/backend/executor/execProcnode.c
+++ b/src/backend/executor/execProcnode.c
@@ -147,6 +147,7 @@
 #include "utils/debugbreak.h"
 #include "pg_trace.h"
 
+VectorExecMthd vmthd = {};
 #ifdef CDB_TRACE_EXECUTOR
 #include "nodes/print.h"
 static void ExecCdbTraceNode(PlanState *node, bool entry, TupleTableSlot 
*result);
@@ -225,6 +226,9 @@ ExecInitNode(Plan *node, EState *estate, int eflags)
        PlanState  *result;
        List       *subps;
        ListCell   *l;
+    if(vmthd.vectorized_executor_enable && vmthd.ExecInitNode_Hook
+                       && (result = 
vmthd.ExecInitNode_Hook(node,estate,eflags)))
+               return result;
 
        /*
         * do nothing when we get to the end of a leaf on tree.
@@ -797,7 +801,7 @@ ExecSliceDependencyNode(PlanState *node)
        ExecSliceDependencyNode(outerPlanState(node));
        ExecSliceDependencyNode(innerPlanState(node));
 }
-    
+
 /* ----------------------------------------------------------------
  *             ExecProcNode
  *
@@ -808,6 +812,10 @@ TupleTableSlot *
 ExecProcNode(PlanState *node)
 {
        TupleTableSlot *result = NULL;
+    if(vmthd.vectorized_executor_enable && vmthd.ExecProcNode_Hook
+          && (result = vmthd.ExecProcNode_Hook(node)))
+               return result;
+
 
        START_MEMORY_ACCOUNT(node->plan->memoryAccount);
        {
@@ -1524,6 +1532,10 @@ ExecUpdateTransportState(PlanState *node, 
ChunkTransportState *state)
 void
 ExecEndNode(PlanState *node)
 {
+       if(vmthd.vectorized_executor_enable && vmthd.ExecEndNode_Hook
+          && vmthd.ExecEndNode_Hook(node))
+               return ;
+
        ListCell   *subp;
 
        /*

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5feb8c08/src/include/executor/executor.h
----------------------------------------------------------------------
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index ea1dad2..44e0546 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -41,6 +41,16 @@
 
 #include "cdb/cdbdef.h"                 /* CdbVisitOpt */
 
+typedef struct vectorexe_t {
+       bool vectorized_executor_enable;
+       PlanState* (*ExecInitNode_Hook)(Plan *node,EState *eState,int eflags);
+       TupleTableSlot* (*ExecProcNode_Hook)(PlanState *node);
+       bool (*ExecEndNode_Hook)(PlanState *node);
+} VectorExecMthd;
+
+extern PGDLLIMPORT VectorExecMthd vmthd;
+
+
 struct ChunkTransportState;             /* #include "cdb/cdbinterconnect.h" */
 
 /*

Reply via email to