Skip to content

Commit 9519f02

Browse files
authored
Feature: add tests and benchmark in intercontect module (#384)
The test of the interconnect and the benchmark can be run independently of CBDB, also need to be compiled separately. Benchmark can be used to measure the performance of different interconnect implementations in the current network environment. but for now, only single client + single server is supported in testing and benchmark. More information: contrib/interconnect/README.md
1 parent d364a23 commit 9519f02

11 files changed

Lines changed: 2705 additions & 5 deletions

File tree

configure

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21032,7 +21032,6 @@ $as_echo "#define HAVE_GCC__ATOMIC_INT64_CAS 1" >>confdefs.h
2103221032

2103321033
fi
2103421034

21035-
2103621035
# Check for x86 cpuid instruction
2103721036
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __get_cpuid" >&5
2103821037
$as_echo_n "checking for __get_cpuid... " >&6; }

contrib/interconnect/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,75 @@ SendChunk/RecvTupleChunk() {
199199
200200
```
201201

202+
# interconnect test && bench
202203

204+
In the path `contrib/interconnect/test`, the test of the interconnect and the benchmark are implemented, also need to be compiled separately.
203205

206+
For proxy type interconnect, user need to compile `cbdb` with `--enable-ic-proxy` to make the test take effect.
207+
208+
compile test and benchmark
209+
210+
```
211+
cd contrib/interconnect/test
212+
mkdir build && cd build
213+
cmake ..
214+
make -j
215+
```
216+
217+
Notice that: for now, only `single client + single server` is supported in testing and benchmarking.
218+
219+
## bench result
220+
221+
test env
222+
223+
- system: CentOS Linux release 7.5.1804
224+
- machine: qingcloud e2, x86, 8 cpu, 16G memory
225+
- mtu: 1500
226+
- buffer size: 200
227+
- time: 100s
228+
229+
230+
tcp result:
231+
232+
```
233+
+----------------+------------+
234+
| Total time(s) | 100.000 |
235+
| Loop times | 48045111 |
236+
| LPS(l/ms) | 480.451 |
237+
| Recv mbs | 65430 |
238+
| TPS(mb/s) | 654.301 |
239+
| Recv counts | 336315777 |
240+
| Items ops/ms | 3363.157 |
241+
+----------------+------------+
242+
```
243+
244+
proxy result:
245+
246+
```
247+
+----------------+------------+
248+
| Total time(s) | 100.118 |
249+
| Loop times | 11447670 |
250+
| LPS(l/ms) | 114.342 |
251+
| Recv mbs | 15589 |
252+
| TPS(mb/s) | 155.716 |
253+
| Recv counts | 80133690 |
254+
| Items ops/ms | 800.393 |
255+
+----------------+------------+
256+
```
257+
258+
udpifc result:
259+
260+
```
261+
+----------------+------------+
262+
| Total time(s) | 100.079 |
263+
| Loop times | 369104 |
264+
| LPS(l/ms) | 3.688 |
265+
| Recv mbs | 502 |
266+
| TPS(mb/s) | 5.023 |
267+
| Recv counts | 2583728 |
268+
| Items ops/ms | 25.817 |
269+
+----------------+------------+
270+
```
271+
272+
Notice that: Lower TPS does not mean the protocol is slower, might means that the cpu time taken by the protocol is low. For the udpifc, it satisfies the highest tps required by `cbdb`. at the same time it occupies a lower cpu than other types of interconnect.
204273

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
project(interconnect_ext)
2+
3+
cmake_minimum_required (VERSION 3.11.0)
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
find_program(
7+
PG_CONFIG pg_config
8+
HINTS ${PG_PATH}
9+
PATH_SUFFIXES bin
10+
DOC "The path to the pg_config of the CBDB version to compile against")
11+
12+
if(NOT PG_CONFIG)
13+
message(FATAL_ERROR "Unable to find 'pg_config'")
14+
endif()
15+
16+
function(GET_PG_CONFIG var)
17+
set(_temp)
18+
19+
# Only call pg_config if the variable didn't already have a value.
20+
if(NOT ${var})
21+
execute_process(
22+
COMMAND ${PG_CONFIG} ${ARGN}
23+
OUTPUT_VARIABLE _temp
24+
OUTPUT_STRIP_TRAILING_WHITESPACE)
25+
endif()
26+
27+
set(${var}
28+
${_temp}
29+
PARENT_SCOPE)
30+
endfunction()
31+
32+
# Get CBDB configuration from pg_config
33+
get_pg_config(PG_INCLUDEDIR --includedir)
34+
35+
set(TOP_DIR ../../..)
36+
set(UNIT_TEST_DIR ${TOP_DIR}/src/test/unit/cmockery/)
37+
set(UNIT_TEST_MOCK_DIR ${TOP_DIR}/src/test/unit/mock/)
38+
set(IC_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../)
39+
set(CBDB_INCLUDE_DIR ${PG_INCLUDEDIR}/postgresql/server)
40+
41+
add_definitions(-DENABLE_IC_PROXY)
42+
43+
set(interconnect_src
44+
../ic_common.c
45+
../ic_modules.c
46+
../tcp/ic_tcp.c
47+
../udp/ic_udpifc.c
48+
../proxy/ic_proxy_main.c
49+
../proxy/ic_proxy_client.c
50+
../proxy/ic_proxy_peer.c
51+
../proxy/ic_proxy_router.c
52+
../proxy/ic_proxy_backend.c
53+
../proxy/ic_proxy_addr.c
54+
../proxy/ic_proxy_key.c
55+
../proxy/ic_proxy_packet.c
56+
../proxy/ic_proxy_pkt_cache.c
57+
../proxy/ic_proxy_iobuf.c)
58+
59+
set(interconnect_ext_test_src
60+
${UNIT_TEST_DIR}/cmockery.c
61+
ic_test_env.c
62+
elog_mock.c
63+
ic_interface_test.c)
64+
65+
set(ic_bench_src
66+
${UNIT_TEST_DIR}/cmockery.c
67+
ic_test_env.c
68+
elog_mock.c
69+
ic_bench.c)
70+
71+
SET(CMAKE_BUILD_TYPE "Debug")
72+
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
73+
74+
add_compile_definitions(ENABLE_IC_PROXY)
75+
link_directories($ENV{GPHOME}/lib)
76+
add_executable(interconnect_ext_test ${interconnect_src} ${interconnect_ext_test_src})
77+
target_include_directories(interconnect_ext_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} "${CBDB_INCLUDE_DIR}" "${IC_MODULE_DIR}" "${UNIT_TEST_DIR}")
78+
79+
target_link_libraries(interconnect_ext_test PUBLIC
80+
pthread
81+
uv
82+
postgres)
83+
84+
link_directories($ENV{GPHOME}/lib)
85+
add_executable(ic_bench ${interconnect_src} ${ic_bench_src})
86+
target_include_directories(ic_bench PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} "${CBDB_INCLUDE_DIR}" "${IC_MODULE_DIR}" "${UNIT_TEST_DIR}")
87+
target_link_libraries(ic_bench PUBLIC
88+
pthread
89+
uv
90+
postgres)

0 commit comments

Comments
 (0)