Skip to content

Commit f57317e

Browse files
committed
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.
1 parent 9f9d297 commit f57317e

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

configure

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,8 @@ HAVE_CXX14
759759
enable_gpcloud
760760
enable_shared_postgres_backend
761761
enable_mapreduce
762-
enable_catalog_ext
763762
enable_serverless
763+
enable_catalog_ext
764764
enable_orca
765765
autodepend
766766
PKG_CONFIG_LIBDIR
@@ -1608,7 +1608,7 @@ Optional Features:
16081608
--enable-cassert enable assertion checks (for debugging)
16091609
--disable-orca disable ORCA optimizer
16101610
--enable-catalog-ext enable Cloudberry catalog extension
1611-
--enable-serverless enable Cloudberry serverless mode
1611+
--enable-serverless use serverless mode of Cloudberry
16121612
--enable-mapreduce enable Cloudberry Mapreduce support
16131613
--disable-shared-postgres-backend
16141614
enable Cloudberry shared postgres backend support
@@ -1618,7 +1618,7 @@ Optional Features:
16181618
library)
16191619
--disable-preload-ic-module
16201620
disable preload interconnect module
1621-
--enable-pax enable pax support
1621+
--disable-pax disable pax support
16221622
--disable-thread-safety disable thread-safety in client libraries
16231623
--enable-openssl-redirect
16241624
enable redirect openssl interface to internal
@@ -8380,7 +8380,7 @@ $as_echo "checking whether to build with catalog extension... $enable_catalog_ex
83808380

83818381

83828382
#
8383-
# Enable serverless mode
8383+
# --enable-serverless uses serverless mode of Cloudberry
83848384
#
83858385

83868386

@@ -8407,8 +8407,8 @@ else
84078407
fi
84088408

84098409

8410-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to use serverless architecture of Cloudberry ... $enable_serverless" >&5
8411-
$as_echo "checking whether to use serverless architecture of Cloudberry ... $enable_serverless" >&6; }
8410+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to use serverless mode of Cloudberry... $enable_serverless" >&5
8411+
$as_echo "checking whether to use serverless mode of Cloudberry... $enable_serverless" >&6; }
84128412

84138413

84148414
#
@@ -9101,6 +9101,7 @@ fi
91019101
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with preload ic module ... $enable_preload_ic_module" >&5
91029102
$as_echo "checking whether to build with preload ic module ... $enable_preload_ic_module" >&6; }
91039103

9104+
91049105
#
91059106
# pax support
91069107
#
@@ -9125,13 +9126,16 @@ $as_echo "#define USE_PAX_STORAGE 1" >>confdefs.h
91259126

91269127
else
91279128
enable_pax=yes
9128-
9129-
$as_echo "#define USE_PAX_STORAGE 1" >>confdefs.h
9129+
9130+
$as_echo "#define USE_PAX_STORAGE 1" >>confdefs.h
9131+
91309132
fi
91319133

9134+
91329135
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with pax support ... $enable_pax" >&5
91339136
$as_echo "checking whether to build with pax support ... $enable_pax" >&6; }
91349137

9138+
91359139
#
91369140
# Include directories
91379141
#
@@ -15699,6 +15703,13 @@ fi
1569915703

1570015704

1570115705

15706+
# for contrib/pax
15707+
if test "$enable_pax" = yes; then
15708+
if test "$enable_shared_postgres_backend" = no; then
15709+
as_fn_error $? "pax support requires --enable-shared-postgres-backend" "$LINENO" 5
15710+
fi
15711+
fi
15712+
1570215713
# for contrib/sepgsql
1570315714
if test "$with_selinux" = yes; then
1570415715
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_compute_create_name in -lselinux" >&5

configure.ac

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,10 @@ AC_SUBST(enable_preload_ic_module)
929929
# pax support
930930
#
931931
PGAC_ARG_BOOL(enable, pax, yes,
932-
[disable PAX support],
932+
[disable pax support],
933933
[AC_DEFINE(USE_PAX_STORAGE, 1,
934934
[Define to 1 to support PAX])])
935-
AC_MSG_RESULT([checking whether to build with PAX support ... $enable_pax])
935+
AC_MSG_RESULT([checking whether to build with pax support ... $enable_pax])
936936
AC_SUBST(enable_pax)
937937

938938
#
@@ -1749,6 +1749,13 @@ fi
17491749
AC_SUBST(LDAP_LIBS_FE)
17501750
AC_SUBST(LDAP_LIBS_BE)
17511751

1752+
# for contrib/pax
1753+
if test "$enable_pax" = yes; then
1754+
if test "$enable_shared_postgres_backend" = no; then
1755+
AC_MSG_ERROR([pax support requires --enable-shared-postgres-backend])
1756+
fi
1757+
fi
1758+
17521759
# for contrib/sepgsql
17531760
if test "$with_selinux" = yes; then
17541761
AC_CHECK_LIB(selinux, security_compute_create_name, [],

src/backend/Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ LIBS += -lsystemd
7373
endif
7474

7575
##########################################################################
76+
TARGETS = submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
77+
ifeq ($(enable_shared_postgres_backend),yes)
78+
TARGETS += libpostgres.so
79+
endif
7680

77-
all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
81+
all: $(TARGETS)
7882

7983
ifneq ($(PORTNAME), cygwin)
8084
ifneq ($(PORTNAME), win32)
@@ -85,10 +89,8 @@ libpostgres.so: $(OBJS)
8589
$(CXX) -shared $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(export_dynamic) \
8690
$(filter-out main/main.o, $(call expand_subsys,$^)) $(LIBS) -o $@
8791

88-
postgres: main/main.o libpostgres.so $(top_builddir)/src/port/libpgport_srv.a $(top_builddir)/src/common/libpgcommon_srv.a
89-
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) \
90-
main/main.o libpostgres.so $(top_builddir)/src/port/libpgport_srv.a \
91-
$(top_builddir)/src/common/libpgcommon_srv.a $(LIBS) -o $@
92+
postgres: $(OBJS)
93+
$(CXX) $(CXXFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o $@
9294

9395
else
9496
postgres: $(OBJS)

0 commit comments

Comments
 (0)