HAWQ-856 Explicitly initialize GPOPT and its dependencies.
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/0f6ac20a Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/0f6ac20a Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/0f6ac20a Branch: refs/heads/HAWQ-537 Commit: 0f6ac20a9c687c70cac136f55e44022f8476792f Parents: 752a98c Author: Venkatesh (Venky) Raghavan <vragha...@pivotal.io> Authored: Wed Jun 22 15:14:38 2016 -0700 Committer: Venkatesh (Venky) Raghavan <vragha...@pivotal.io> Committed: Wed Jun 22 15:14:38 2016 -0700 ---------------------------------------------------------------------- depends/thirdparty/gporca | 2 +- depends/thirdparty/gpos | 2 +- src/backend/gpopt/CGPOptimizer.cpp | 67 ++++++++++++++++++++++++++++++++- src/backend/gpopt/ivy.xml | 4 +- src/backend/utils/init/postinit.c | 14 +++++++ src/include/gpopt/CGPOptimizer.h | 7 ++++ 6 files changed, 91 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6ac20a/depends/thirdparty/gporca ---------------------------------------------------------------------- diff --git a/depends/thirdparty/gporca b/depends/thirdparty/gporca index f0532b1..0d83756 160000 --- a/depends/thirdparty/gporca +++ b/depends/thirdparty/gporca @@ -1 +1 @@ -Subproject commit f0532b19c22c86e6959ae35fb9568096b7d666f9 +Subproject commit 0d837569e61182f68bf1b92038c6616401790a16 http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6ac20a/depends/thirdparty/gpos ---------------------------------------------------------------------- diff --git a/depends/thirdparty/gpos b/depends/thirdparty/gpos index 91fa636..6af760f 160000 --- a/depends/thirdparty/gpos +++ b/depends/thirdparty/gpos @@ -1 +1 @@ -Subproject commit 91fa636d53ad71d56a4beae55e3ed1fb6d6f8f92 +Subproject commit 6af760fb96f5bd48783e8644e7d63c39132b8c08 http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6ac20a/src/backend/gpopt/CGPOptimizer.cpp ---------------------------------------------------------------------- diff --git a/src/backend/gpopt/CGPOptimizer.cpp b/src/backend/gpopt/CGPOptimizer.cpp index c0eaa3e..db3cab8 100644 --- a/src/backend/gpopt/CGPOptimizer.cpp +++ b/src/backend/gpopt/CGPOptimizer.cpp @@ -48,7 +48,7 @@ void CGPOptimizer::TouchLibraryInitializers() { - void (*gpos)() = gpos_init; + void (*gpos)(gpos_init_params*) = gpos_init; void (*dxl)() = gpdxl_init; void (*opt)() = gpopt_init; } @@ -90,6 +90,39 @@ CGPOptimizer::SzDXLPlan return COptTasks::SzOptimize(pquery); } +//--------------------------------------------------------------------------- +// @function: +// InitGPOPT() +// +// @doc: +// Initialize GPTOPT and dependent libraries +// +//--------------------------------------------------------------------------- +void +CGPOptimizer::InitGPOPT () +{ + // Use GPORCA's default allocators + struct gpos_init_params params = { NULL, NULL }; + gpos_init(¶ms); + gpdxl_init(); + gpopt_init(); +} + +//--------------------------------------------------------------------------- +// @function: +// TerminateGPOPT() +// +// @doc: +// Terminate GPOPT and dependent libraries +// +//--------------------------------------------------------------------------- +void +CGPOptimizer::TerminateGPOPT () +{ + gpopt_terminate(); + gpdxl_terminate(); + gpos_terminate(); +} //--------------------------------------------------------------------------- // @function: @@ -130,4 +163,36 @@ char *SzDXLPlan } } +//--------------------------------------------------------------------------- +// @function: +// InitGPOPT() +// +// @doc: +// Initialize GPTOPT and dependent libraries +// +//--------------------------------------------------------------------------- +extern "C" +{ +void InitGPOPT () +{ + return CGPOptimizer::InitGPOPT(); +} +} + +//--------------------------------------------------------------------------- +// @function: +// TerminateGPOPT() +// +// @doc: +// Terminate GPOPT and dependent libraries +// +//--------------------------------------------------------------------------- +extern "C" +{ +void TerminateGPOPT () +{ + return CGPOptimizer::TerminateGPOPT(); +} +} + // EOF http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6ac20a/src/backend/gpopt/ivy.xml ---------------------------------------------------------------------- diff --git a/src/backend/gpopt/ivy.xml b/src/backend/gpopt/ivy.xml index a9d08aa..43423eb 100644 --- a/src/backend/gpopt/ivy.xml +++ b/src/backend/gpopt/ivy.xml @@ -38,8 +38,8 @@ under the License. </configurations> <dependencies> - <dependency org="emc" name="optimizer" rev="1.630" conf="osx106_x86->osx106_x86_32;osx106_x86_32->osx106_x86_32;rhel5_x86_64->rhel5_x86_64;suse10_x86_64->suse10_x86_64" /> - <dependency org="emc" name="libgpos" rev="1.136" conf="osx106_x86->osx106_x86_32;osx106_x86_32->osx106_x86_32;rhel5_x86_64->rhel5_x86_64;suse10_x86_64->suse10_x86_64" /> + <dependency org="emc" name="optimizer" rev="1.633" conf="osx106_x86->osx106_x86_32;osx106_x86_32->osx106_x86_32;rhel5_x86_64->rhel5_x86_64;suse10_x86_64->suse10_x86_64" /> + <dependency org="emc" name="libgpos" rev="1.137" conf="osx106_x86->osx106_x86_32;osx106_x86_32->osx106_x86_32;rhel5_x86_64->rhel5_x86_64;suse10_x86_64->suse10_x86_64" /> <dependency org="xerces" name="xerces-c" rev="3.1.1-p1" conf="osx106_x86->osx106_x86_32;osx106_x86_32->osx106_x86_32;rhel5_x86_64->rhel5_x86_64;suse10_x86_64->suse10_x86_64" /> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6ac20a/src/backend/utils/init/postinit.c ---------------------------------------------------------------------- diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index c2e3c96..5358c5f 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -62,6 +62,11 @@ static void InitCommunication(void); static void ShutdownPostgres(int code, Datum arg); static bool ThereIsAtLeastOneRole(void); +#ifdef USE_ORCA +extern void InitGPOPT(); +extern void TerminateGPOPT(); +#endif + /*** InitPostgres support ***/ /* @@ -471,6 +476,11 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* Initialize memory protection */ GPMemoryProtect_Init(); +#ifdef USE_ORCA + /* Initialize GPOPT */ + InitGPOPT(); +#endif + /* * Initialize my entry in the shared-invalidation manager's array of * per-backend data. @@ -727,6 +737,10 @@ ShutdownPostgres(int code, Datum arg) */ ReportOOMConsumption(); +#ifdef USE_ORCA + TerminateGPOPT(); +#endif + /* Disable memory protection */ GPMemoryProtect_Shutdown(); /* Release SessionState entry */ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6ac20a/src/include/gpopt/CGPOptimizer.h ---------------------------------------------------------------------- diff --git a/src/include/gpopt/CGPOptimizer.h b/src/include/gpopt/CGPOptimizer.h index a1061fd..68b3957 100644 --- a/src/include/gpopt/CGPOptimizer.h +++ b/src/include/gpopt/CGPOptimizer.h @@ -57,6 +57,13 @@ class CGPOptimizer // serialize planned statement into DXL static char *SzDXLPlan(Query *pquery); + + // gpopt initialize and terminate + static + void InitGPOPT(); + + static + void TerminateGPOPT(); }; #endif // CGPOptimizer_H