Skip to content

Commit 86ca971

Browse files
Add udp2, an experimental IPC layer implementation
1 parent b1e46cb commit 86ca971

31 files changed

+12600
-0
lines changed

GNUmakefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ ifeq ($(with_openssl), yes)
3434
endif
3535
ifeq ($(enable_pax), yes)
3636
$(MAKE) -C contrib/pax_storage all
37+
endif
38+
ifeq ($(enable_ic_udp2),yes)
39+
$(MAKE) -C contrib/udp2 all
3740
endif
3841
$(MAKE) -C gpMgmt all
3942
$(MAKE) -C gpcontrib all
@@ -81,6 +84,9 @@ ifeq ($(enable_pax), yes)
8184
endif
8285
ifeq ($(with_openssl), yes)
8386
$(MAKE) -C contrib/sslinfo $@
87+
endif
88+
ifeq ($(enable_ic_udp2),yes)
89+
$(MAKE) -C contrib/udp2 $@
8490
endif
8591
$(MAKE) -C gpMgmt $@
8692
$(MAKE) -C gpcontrib $@

configure

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ PROTOBUF_LIBS
761761
PROTOBUF_CFLAGS
762762
enable_preload_ic_module
763763
enable_ic_proxy
764+
enable_ic_udp2
764765
enable_external_fts
765766
HAVE_CXX14
766767
enable_gpcloud
@@ -910,6 +911,7 @@ enable_shared_postgres_backend
910911
enable_link_postgres_with_shared
911912
enable_gpcloud
912913
enable_external_fts
914+
enable_ic_udp2
913915
enable_ic_proxy
914916
enable_preload_ic_module
915917
enable_pax
@@ -1641,6 +1643,8 @@ Optional Features:
16411643
libpostgres.so
16421644
--enable-gpcloud enable gpcloud support
16431645
--enable-external-fts enable external fts support
1646+
--disable-ic-udp2 enable interconnect udp2 implement (requires
1647+
ic_common library)
16441648
--enable-ic-proxy enable interconnect proxy mode (requires libuv
16451649
library)
16461650
--disable-preload-ic-module
@@ -9193,6 +9197,40 @@ $as_echo "#define USE_INTERNAL_FTS 1" >>confdefs.h
91939197
CFLAGS="$CFLAGS -DUSE_INTERNAL_FTS=1"
91949198
fi
91959199

9200+
#
9201+
# ic-udp2
9202+
#
9203+
9204+
9205+
# Check whether --enable-ic-udp2 was given.
9206+
if test "${enable_ic_udp2+set}" = set; then :
9207+
enableval=$enable_ic_udp2;
9208+
case $enableval in
9209+
yes)
9210+
9211+
$as_echo "#define ENABLE_IC_UDP2 1" >>confdefs.h
9212+
9213+
;;
9214+
no)
9215+
:
9216+
;;
9217+
*)
9218+
as_fn_error $? "no argument expected for --enable-ic-udp2 option" "$LINENO" 5
9219+
;;
9220+
esac
9221+
9222+
else
9223+
enable_ic_udp2=yes
9224+
9225+
$as_echo "#define ENABLE_IC_UDP2 1" >>confdefs.h
9226+
9227+
fi
9228+
9229+
9230+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with interconnect udp2 support ... $enable_ic_udp2" >&5
9231+
$as_echo "checking whether to build with interconnect udp2 support ... $enable_ic_udp2" >&6; }
9232+
9233+
91969234
#
91979235
# ic-proxy
91989236
#

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,16 @@ if test "$enable_external_fts" = no; then
923923
CFLAGS="$CFLAGS -DUSE_INTERNAL_FTS=1"
924924
fi
925925

926+
#
927+
# ic-udp2
928+
#
929+
PGAC_ARG_BOOL(enable, ic-udp2, yes,
930+
[enable interconnect udp2 implement (requires ic_common library)],
931+
[AC_DEFINE(ENABLE_IC_UDP2, 1,
932+
[Define to 1 to build with interconnect udp2 support (--enable-ic-udp2)])])
933+
AC_MSG_RESULT([checking whether to build with interconnect udp2 support ... $enable_ic_udp2])
934+
AC_SUBST(enable_ic_udp2)
935+
926936
#
927937
# ic-proxy
928938
#

contrib/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ else
104104
ALWAYS_SUBDIRS += pax_storage
105105
endif
106106

107+
ifeq ($(enable_ic_udp2),yes)
108+
SUBDIRS += udp2
109+
else
110+
ALWAYS_SUBDIRS += udp2
111+
endif
112+
107113
# Missing:
108114
# start-scripts \ (does not have a makefile)
109115

contrib/udp2/CMakeLists.txt

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
cmake_minimum_required(VERSION 3.11.0)
2+
project(udp2)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
set(CMAKE_CXX_STANDARD_REQUIRED True)
6+
7+
# Get the top-level project directory
8+
set(TOP_DIR ${PROJECT_SOURCE_DIR}/../..)
9+
set(CBDB_INCLUDE_DIR ${TOP_DIR}/src/include)
10+
11+
# CMAKE_INSTALL_PREFIX should be set by the calling Makefile
12+
# If not set, we'll use a reasonable default but warn about it
13+
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
14+
message(WARNING "CMAKE_INSTALL_PREFIX not set by parent build system, using default")
15+
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install prefix" FORCE)
16+
endif()
17+
18+
# Check for debug/release configuration from main project
19+
include(CheckSymbolExists)
20+
set(PG_CONFIG_HEADER_FILE "${CBDB_INCLUDE_DIR}/pg_config.h")
21+
if(EXISTS "${PG_CONFIG_HEADER_FILE}")
22+
CHECK_SYMBOL_EXISTS(USE_ASSERT_CHECKING "${PG_CONFIG_HEADER_FILE}" UDP2_USE_DEBUG)
23+
if(UDP2_USE_DEBUG)
24+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
25+
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Debug' based on main project configuration")
26+
else()
27+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
28+
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Release' based on main project configuration")
29+
endif()
30+
else()
31+
# Fallback to Release if pg_config.h is not found
32+
if(NOT CMAKE_BUILD_TYPE)
33+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
34+
message(STATUS "Setting default CMAKE_BUILD_TYPE to 'Release'")
35+
endif()
36+
endif()
37+
38+
# First, build and install ic_common as a subdirectory
39+
add_subdirectory(ic_common)
40+
41+
# Set up include directories
42+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
43+
include_directories(${CMAKE_INSTALL_PREFIX}/include/postgresql/)
44+
include_directories(${CMAKE_INSTALL_PREFIX}/include/postgresql/udp2/)
45+
include_directories(${CBDB_INCLUDE_DIR})
46+
include_directories(${CBDB_INCLUDE_DIR}/server)
47+
48+
# Set up library directories
49+
link_directories(${CMAKE_INSTALL_PREFIX}/lib/postgresql/)
50+
51+
# Source files for udp2 module
52+
set(UDP2_SOURCES
53+
ic_udp2.c
54+
ic_modules.c
55+
)
56+
57+
# Create the udp2 shared library
58+
add_library(udp2 SHARED ${UDP2_SOURCES})
59+
60+
# Set compiler flags consistent with main project
61+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv")
62+
63+
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
64+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -ggdb")
65+
message(STATUS "Building udp2 in Debug mode")
66+
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
67+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -DNDEBUG")
68+
message(STATUS "Building udp2 in Release mode")
69+
endif()
70+
71+
# Link against ic_common library
72+
target_link_libraries(udp2 ic_common)
73+
74+
# Make sure ic_common is built before udp2
75+
add_dependencies(udp2 ic_common)
76+
77+
# Set output name and remove lib prefix
78+
set_target_properties(udp2 PROPERTIES
79+
OUTPUT_NAME "udp2"
80+
PREFIX ""
81+
)
82+
83+
# Install the udp2 library
84+
install(TARGETS udp2
85+
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/postgresql/"
86+
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/postgresql/"
87+
)
88+
89+
# Install udp2 headers
90+
install(FILES
91+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_udp2.h"
92+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_modules.h"
93+
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/postgresql/"
94+
)

contrib/udp2/Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# contrib/udp2/Makefile
2+
top_builddir = ../..
3+
4+
# Include the standard PostgreSQL build system to get variables like prefix, DESTDIR, etc.
5+
ifdef USE_PGXS
6+
PG_CONFIG = pg_config
7+
PGXS := $(shell $(PG_CONFIG) --pgxs)
8+
include $(PGXS)
9+
else
10+
subdir = contrib/udp2
11+
include $(top_builddir)/src/Makefile.global
12+
include $(top_srcdir)/contrib/contrib-global.mk
13+
endif
14+
15+
# Use CMake for building this module
16+
CMAKE_BUILD_DIR = build
17+
18+
# Default target
19+
all: $(CMAKE_BUILD_DIR)/udp2.so
20+
21+
# Create build directory and configure with CMake
22+
$(CMAKE_BUILD_DIR)/Makefile:
23+
@echo "Configuring udp2 with CMake..."
24+
@mkdir -p $(CMAKE_BUILD_DIR)
25+
@cd $(CMAKE_BUILD_DIR) && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) ..
26+
27+
# Build the project using CMake
28+
$(CMAKE_BUILD_DIR)/udp2.so: $(CMAKE_BUILD_DIR)/Makefile
29+
@echo "Building udp2 with CMake..."
30+
@cd $(CMAKE_BUILD_DIR) && $(MAKE)
31+
@cp $(CMAKE_BUILD_DIR)/udp2.so udp2.so
32+
33+
# Install target
34+
install: $(CMAKE_BUILD_DIR)/udp2.so
35+
@echo "Installing udp2..."
36+
@cd $(CMAKE_BUILD_DIR) && $(MAKE) install
37+
38+
# Clean target
39+
clean:
40+
@echo "Cleaning udp2..."
41+
@rm -rf $(CMAKE_BUILD_DIR)
42+
@rm -f udp2.so
43+
44+
# Ensure ic_common is built first
45+
ic_common:
46+
@echo "Building ic_common..."
47+
@mkdir -p ic_common/build
48+
@cd ic_common/build && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) .. && $(MAKE) && $(MAKE) install
49+
50+
# Make sure ic_common is built before udp2
51+
$(CMAKE_BUILD_DIR)/udp2.so: ic_common
52+
53+
.PHONY: all install clean ic_common
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
cmake_minimum_required(VERSION 3.11.0)
2+
project(ic_common)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
set(CMAKE_CXX_STANDARD_REQUIRED True)
6+
7+
# Get the top-level project directory
8+
set(TOP_DIR ${PROJECT_SOURCE_DIR}/../../..)
9+
set(CBDB_INCLUDE_DIR ${TOP_DIR}/src/include)
10+
11+
# CMAKE_INSTALL_PREFIX should be set by the calling Makefile
12+
# If not set, we'll use a reasonable default but warn about it
13+
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
14+
message(WARNING "CMAKE_INSTALL_PREFIX not set by parent build system, using default")
15+
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install prefix" FORCE)
16+
endif()
17+
18+
# Check for debug/release configuration from main project
19+
include(CheckSymbolExists)
20+
set(PG_CONFIG_HEADER_FILE "${CBDB_INCLUDE_DIR}/pg_config.h")
21+
if(EXISTS "${PG_CONFIG_HEADER_FILE}")
22+
CHECK_SYMBOL_EXISTS(USE_ASSERT_CHECKING "${PG_CONFIG_HEADER_FILE}" IC_USE_DEBUG)
23+
if(IC_USE_DEBUG)
24+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
25+
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Debug' based on main project configuration")
26+
else()
27+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
28+
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Release' based on main project configuration")
29+
endif()
30+
else()
31+
# Fallback to Release if pg_config.h is not found
32+
if(NOT CMAKE_BUILD_TYPE)
33+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
34+
message(STATUS "Setting default CMAKE_BUILD_TYPE to 'Release'")
35+
endif()
36+
endif()
37+
38+
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/udp2/*.cpp")
39+
40+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
41+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/udp2)
42+
43+
add_library(ic_common SHARED ${SOURCES})
44+
45+
set_target_properties(ic_common PROPERTIES OUTPUT_NAME "ic_common")
46+
47+
# Set compiler flags consistent with main project
48+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv")
49+
50+
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
51+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -ggdb")
52+
message(STATUS "Building ic_common in Debug mode")
53+
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
54+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG")
55+
message(STATUS "Building ic_common in Release mode")
56+
endif()
57+
58+
# Install headers to the main project's include directory
59+
install(FILES
60+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_types.h"
61+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_except.hpp"
62+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_utility.hpp"
63+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_faultinjection.h"
64+
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/postgresql/"
65+
)
66+
67+
install(FILES
68+
"${CMAKE_CURRENT_SOURCE_DIR}/udp2/ic_udp2.h"
69+
"${CMAKE_CURRENT_SOURCE_DIR}/udp2/ic_udp2.hpp"
70+
"${CMAKE_CURRENT_SOURCE_DIR}/udp2/ic_arrow_adapter.hpp"
71+
"${CMAKE_CURRENT_SOURCE_DIR}/udp2/ic_udp2_internal.hpp"
72+
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/postgresql/udp2/"
73+
)
74+
75+
# Install library to the main project's lib directory
76+
install(TARGETS ic_common
77+
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/"
78+
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/"
79+
)

0 commit comments

Comments
 (0)