From e1244e6d6f40dc274e47e72f45f01e8ec1390cd8 Mon Sep 17 00:00:00 2001 From: GongXun Date: Fri, 16 May 2025 23:51:28 +0800 Subject: [PATCH] Enhancement: change link methd to reduce PLT overhead During TPC-DS testing, we observed that compiling postgres with libpostgres.so introduces PTL function call overhead for some functions. By linking object files (*.o) directly instead, we achieved a 5-8% performance improvement in the TPC-DS 1TB benchmark. This commit modifies the postgres linking process to directly link with the object files rather than the shared library. Additionally, this update fixes a minor bug: the pax extension has a dependency on libpostgres.so. Now, when enabling the pax entension, we check that enable_shared_postgres_backend is set to 'yes' to ensure proper functionality. --- configure | 28 ++++++++++++++++++++-------- configure.ac | 13 ++++++++++--- src/backend/Makefile | 7 +++---- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/configure b/configure index e612c658399..cc3b3e907ab 100755 --- a/configure +++ b/configure @@ -570,6 +570,7 @@ ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # +ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= @@ -759,8 +760,8 @@ HAVE_CXX14 enable_gpcloud enable_shared_postgres_backend enable_mapreduce -enable_catalog_ext enable_serverless +enable_catalog_ext enable_orca autodepend PKG_CONFIG_LIBDIR @@ -1608,7 +1609,7 @@ Optional Features: --enable-cassert enable assertion checks (for debugging) --disable-orca disable ORCA optimizer --enable-catalog-ext enable Cloudberry catalog extension - --enable-serverless enable Cloudberry serverless mode + --enable-serverless use serverless mode of Cloudberry --enable-mapreduce enable Cloudberry Mapreduce support --disable-shared-postgres-backend enable Cloudberry shared postgres backend support @@ -1618,7 +1619,7 @@ Optional Features: library) --disable-preload-ic-module disable preload interconnect module - --enable-pax enable pax support + --disable-pax disable pax support --disable-thread-safety disable thread-safety in client libraries --enable-openssl-redirect enable redirect openssl interface to internal @@ -8380,7 +8381,7 @@ $as_echo "checking whether to build with catalog extension... $enable_catalog_ex # -# Enable serverless mode +# --enable-serverless uses serverless mode of Cloudberry # @@ -8407,8 +8408,8 @@ else fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to use serverless architecture of Cloudberry ... $enable_serverless" >&5 -$as_echo "checking whether to use serverless architecture of Cloudberry ... $enable_serverless" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to use serverless mode of Cloudberry... $enable_serverless" >&5 +$as_echo "checking whether to use serverless mode of Cloudberry... $enable_serverless" >&6; } # @@ -9101,6 +9102,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with preload ic module ... $enable_preload_ic_module" >&5 $as_echo "checking whether to build with preload ic module ... $enable_preload_ic_module" >&6; } + # # pax support # @@ -9125,13 +9127,16 @@ $as_echo "#define USE_PAX_STORAGE 1" >>confdefs.h else enable_pax=yes - - $as_echo "#define USE_PAX_STORAGE 1" >>confdefs.h + +$as_echo "#define USE_PAX_STORAGE 1" >>confdefs.h + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with pax support ... $enable_pax" >&5 $as_echo "checking whether to build with pax support ... $enable_pax" >&6; } + # # Include directories # @@ -15699,6 +15704,13 @@ fi +# for contrib/pax_storage +if test "$enable_pax" = yes; then + if test "$enable_shared_postgres_backend" = no; then + as_fn_error $? "pax support requires --enable-shared-postgres-backend" "$LINENO" 5 + fi +fi + # for contrib/sepgsql if test "$with_selinux" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_compute_create_name in -lselinux" >&5 diff --git a/configure.ac b/configure.ac index a1e3d9709db..c9041c0c08d 100644 --- a/configure.ac +++ b/configure.ac @@ -929,10 +929,10 @@ AC_SUBST(enable_preload_ic_module) # pax support # PGAC_ARG_BOOL(enable, pax, yes, - [disable PAX support], + [disable pax support], [AC_DEFINE(USE_PAX_STORAGE, 1, - [Define to 1 to support PAX])]) -AC_MSG_RESULT([checking whether to build with PAX support ... $enable_pax]) + [Define to 1 to support pax])]) +AC_MSG_RESULT([checking whether to build with pax support ... $enable_pax]) AC_SUBST(enable_pax) # @@ -1749,6 +1749,13 @@ fi AC_SUBST(LDAP_LIBS_FE) AC_SUBST(LDAP_LIBS_BE) +# for contrib/pax_storage +if test "$enable_pax" = yes; then + if test "$enable_shared_postgres_backend" = no; then + AC_MSG_ERROR([pax support requires --enable-shared-postgres-backend]) + fi +fi + # for contrib/sepgsql if test "$with_selinux" = yes; then AC_CHECK_LIB(selinux, security_compute_create_name, [], diff --git a/src/backend/Makefile b/src/backend/Makefile index 5a41ad2f3b2..29cb7b7e4b0 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -81,14 +81,13 @@ ifneq ($(PORTNAME), win32) ifneq ($(PORTNAME), aix) ifeq ($(enable_shared_postgres_backend),yes) +all: libpostgres.so libpostgres.so: $(OBJS) $(CXX) -shared $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(export_dynamic) \ $(filter-out main/main.o, $(call expand_subsys,$^)) $(LIBS) -o $@ -postgres: main/main.o libpostgres.so $(top_builddir)/src/port/libpgport_srv.a $(top_builddir)/src/common/libpgcommon_srv.a - $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) \ - main/main.o libpostgres.so $(top_builddir)/src/port/libpgport_srv.a \ - $(top_builddir)/src/common/libpgcommon_srv.a $(LIBS) -o $@ +postgres: $(OBJS) + $(CXX) $(CXXFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o $@ else postgres: $(OBJS)