This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 8793ec0619d Enhancement: change link methd to reduce PLT overhead
8793ec0619d is described below

commit 8793ec0619d33173b4b7b022617a30d380c7ab5a
Author: GongXun <[email protected]>
AuthorDate: Fri May 16 23:51:28 2025 +0800

    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 added an option enable_link_postgres_with_shared to
    link libpostgres.so when compiling postgres, and The default value
    is false, just like greenplum, statically linking all object files
    when compiling postgres.
    
    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.
    
    And the ic-cbdb-parallel test has been migrated to use the release
    version instead of the debug version.
    
    This change was made because running the test on the debug version
    caused disk space issues. When both libpostgres.so and postgres are
    compiled in the debug version, disk usage increases by several hundred
    megabytes compared to the release version. As a result, the
    ic-cbdb-parallel test failed due to insufficient disk space.
    
    By switching to the release version, this issue is resolved, and the
    test runs faster as well.
---
 .github/workflows/build-cloudberry.yml     |  3 ++
 .github/workflows/build-dbg-cloudberry.yml |  3 --
 configure                                  | 51 ++++++++++++++++++++++++++++++
 configure.ac                               | 25 ++++++++++++++-
 src/Makefile.global.in                     |  1 +
 src/backend/Makefile                       |  8 ++++-
 6 files changed, 86 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/build-cloudberry.yml 
b/.github/workflows/build-cloudberry.yml
index a6e659596b5..8d04d51a095 100644
--- a/.github/workflows/build-cloudberry.yml
+++ b/.github/workflows/build-cloudberry.yml
@@ -315,6 +315,9 @@ jobs:
               },
               {"test":"ic-parallel-retrieve-cursor",
                
"make_configs":["src/test/isolation2:installcheck-parallel-retrieve-cursor"]
+              },
+              {"test":"ic-cbdb-parallel",
+               "make_configs":["src/test/regress:installcheck-cbdb-parallel"]
               }
             ]
           }'
diff --git a/.github/workflows/build-dbg-cloudberry.yml 
b/.github/workflows/build-dbg-cloudberry.yml
index 998242efcd7..569e6a350d6 100644
--- a/.github/workflows/build-dbg-cloudberry.yml
+++ b/.github/workflows/build-dbg-cloudberry.yml
@@ -222,9 +222,6 @@ jobs:
           # Define base test configurations
           ALL_TESTS='{
             "include": [
-              {"test":"ic-cbdb-parallel",
-               "make_configs":["src/test/regress:installcheck-cbdb-parallel"]
-              }
             ]
           }'
 
diff --git a/configure b/configure
index 9de18682ecd..2905dd719fa 100755
--- a/configure
+++ b/configure
@@ -761,6 +761,7 @@ enable_ic_proxy
 enable_external_fts
 HAVE_CXX14
 enable_gpcloud
+enable_link_postgres_with_shared
 enable_shared_postgres_backend
 enable_mapreduce
 enable_serverless
@@ -903,6 +904,7 @@ enable_catalog_ext
 enable_serverless
 enable_mapreduce
 enable_shared_postgres_backend
+enable_link_postgres_with_shared
 enable_gpcloud
 enable_external_fts
 enable_ic_proxy
@@ -1630,6 +1632,9 @@ Optional Features:
   --enable-mapreduce      enable Cloudberry Mapreduce support
   --disable-shared-postgres-backend
                           enable Cloudberry shared postgres backend support
+  --enable-link-postgres-with-shared
+                          build Cloudberry using the shared library
+                          libpostgres.so
   --enable-gpcloud        enable gpcloud support
   --enable-external-fts   enable external fts support
   --enable-ic-proxy       enable interconnect proxy mode (requires libuv
@@ -8589,6 +8594,45 @@ if test "$enable_shared_postgres_backend" = yes ; then :
 
 fi # fi
 
+#
+# --enable-link-postgres-with-shared enables linking postgres with shared 
library libpostgres.so
+#
+
+
+# Check whether --enable-link-postgres-with-shared was given.
+if test "${enable_link_postgres_with_shared+set}" = set; then :
+  enableval=$enable_link_postgres_with_shared;
+  case $enableval in
+    yes)
+
+$as_echo "#define USE_LINK_POSTGRES_WITH_SHARED 1" >>confdefs.h
+
+      ;;
+    no)
+      :
+      ;;
+    *)
+      as_fn_error $? "no argument expected for 
--enable-link-postgres-with-shared option" "$LINENO" 5
+      ;;
+  esac
+
+else
+  enable_link_postgres_with_shared=no
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build 
Cloudberry using the shared library libpostgres.so... 
$enable_link_postgres_with_shared" >&5
+$as_echo "checking whether to build Cloudberry using the shared library 
libpostgres.so... $enable_link_postgres_with_shared" >&6; }
+
+
+# check if enable-shared-postgres-backend is yes when 
enable-link-postgres-with-shared is yes
+if test "$enable_link_postgres_with_shared" = yes; then
+  if test "$enable_shared_postgres_backend" = no; then
+    as_fn_error $? "--enable-link-postgres-with-shared is yes, but 
--enable-shared-postgres-backend is no" "$LINENO" 5
+  fi
+fi
+
 #
 # gpcloud, enabled by default
 #
@@ -16057,6 +16101,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 91202c748d5..4dfcd8bf8c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -871,7 +871,7 @@ AC_SUBST(enable_mapreduce)
 #
 PGAC_ARG_BOOL(enable, shared-postgres-backend, yes, [enable Cloudberry shared 
postgres backend support],
               [AC_DEFINE([USE_SHARED_POSTGRES_BACKEND], 1,
-                                    [Define to 1 to build with shared postgres 
backend capabilities (--enable-shared-postgres-backend)])])
+                                    [Define to 1 to build with shared 
Cloudberry backend capabilities (--enable-shared-postgres-backend)])])
 AC_MSG_RESULT([checking whether to build with Cloudberry shared postgres 
backend... $enable_shared_postgres_backend])
 AC_SUBST(enable_shared_postgres_backend)
 
@@ -881,6 +881,22 @@ AS_IF([test "$enable_shared_postgres_backend" = yes ],
   CXXFLAGS="$CXXFLAGS -fPIC "
 ]) # fi
 
+#
+# --enable-link-postgres-with-shared enables linking postgres with shared 
library libpostgres.so
+#
+PGAC_ARG_BOOL(enable, link-postgres-with-shared, no, [build Cloudberry using 
the shared library libpostgres.so],
+              [AC_DEFINE([USE_LINK_POSTGRES_WITH_SHARED], 1,
+                                    [Define to 1 to build Cloudberry using the 
shared library libpostgres.so (--enable-link-postgres-with-shared)])])
+AC_MSG_RESULT([checking whether to build Cloudberry using the shared library 
libpostgres.so... $enable_link_postgres_with_shared])
+AC_SUBST(enable_link_postgres_with_shared)
+
+# check if enable-shared-postgres-backend is yes when 
enable-link-postgres-with-shared is yes
+if test "$enable_link_postgres_with_shared" = yes; then
+  if test "$enable_shared_postgres_backend" = no; then
+    AC_MSG_ERROR([--enable-link-postgres-with-shared is yes, but 
--enable-shared-postgres-backend is no])
+  fi
+fi
+
 #
 # gpcloud, enabled by default
 #
@@ -1783,6 +1799,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/Makefile.global.in b/src/Makefile.global.in
index 8a195a39856..343eb985c69 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -230,6 +230,7 @@ enable_debug_extensions = @enable_debug_extensions@
 enable_orafce          = @enable_orafce@
 enable_mapreduce    = @enable_mapreduce@
 enable_shared_postgres_backend    = @enable_shared_postgres_backend@
+enable_link_postgres_with_shared  = @enable_link_postgres_with_shared@
 enable_gpcloud             = @enable_gpcloud@
 enable_ic_proxy     = @enable_ic_proxy@
 enable_pax          = @enable_pax@
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 6c16a9aa9e4..44dbe7f0e15 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -105,16 +105,22 @@ $(SYMBOL_MAP_FILE): 
$(top_builddir)/src/interfaces/libpq/exports.txt
        ( echo '{ global: *; '; echo ' local:'; $(AWK) '/^[^\#]/ {printf 
"%s;\n",$$1}' $< | grep -v -E $(SAFELY_EXPORTED_SYMBOLS_PATTERN); echo '};' ) 
>$@
 SYMBOL_MAPPING_FLAGS = -Wl,--version-script=$(SYMBOL_MAP_FILE)
 endif
-
 ifeq ($(enable_shared_postgres_backend),yes)
+all: libpostgres.so
 libpostgres.so: $(OBJS) $(SYMBOL_MAP_FILE)
        $(CXX) -shared $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(export_dynamic) \
          $(filter-out main/main.o, $(call expand_subsys,$(OBJS))) $(LIBS) 
$(SYMBOL_MAPPING_FLAGS) -o $@
 
+# if enable-build-postgres-with-shared is yes, link postgres with shared 
library libpostgres.so
+ifeq ($(enable_link_postgres_with_shared),yes)
 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 $@
+else
+postgres: $(OBJS) $(SYMBOL_MAP_FILE)
+       $(CXX) $(CXXFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) 
$(LDFLAGS_EX) $(export_dynamic) $(LIBS) $(SYMBOL_MAPPING_FLAGS) -o $@
+endif
 
 else
 postgres: $(OBJS) $(SYMBOL_MAP_FILE)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to