Skip to content

Commit e47a61a

Browse files
gongxun0928avamingli
authored andcommitted
chore: compile postgres statically to reduce the PLT function call
When building postgres, link all the *.o files directly into the binary instead of linking libpostgres.so. This approach reduces the overhead of PLT function calls. Based on our internal performance tests, this change improves the performance of a 1TB TPC-DS benchmark by 5-8%. and generate libpostgres.so at the same time, so that other extensions can write unit tests.
1 parent 964756f commit e47a61a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/backend/Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ endif
7474

7575
##########################################################################
7676

77-
all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
77+
all: submake-libpgport submake-catalog-headers submake-utils-headers postgres libpostgres.so $(POSTGRES_IMP)
7878

7979
ifneq ($(PORTNAME), cygwin)
8080
ifneq ($(PORTNAME), win32)
@@ -85,10 +85,8 @@ libpostgres.so: $(OBJS)
8585
$(CXX) -shared $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(export_dynamic) \
8686
$(filter-out main/main.o, $(call expand_subsys,$^)) $(LIBS) -o $@
8787

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 $@
88+
postgres: $(OBJS)
89+
$(CXX) $(CXXFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o $@
9290

9391
else
9492
postgres: $(OBJS)

0 commit comments

Comments
 (0)