Skip to content

Commit 36bd4e5

Browse files
committed
Introduce RDMA transport
Main changes in this patch: * implement *Valkey Over RDMA* protocol, see *Protocol* section in RDMA.md * implement server side of connection module only, this means we can *NOT* compile RDMA support as built-in. * add necessary information in RDMA.md * support 'CONFIG SET/GET', for example, 'CONFIG Set rdma.port 6380', then check this by 'rdma res show cm_id' and valkey-cli(with RDMA support, but not implemented in this patch) * the full listeners show like(): listener0:name=tcp,bind=*,bind=-::*,port=6379 listener1:name=unix,bind=/var/run/valkey.sock listener2:name=rdma,bind=xx.xx.xx.xx,bind=yy.yy.yy.yy,port=6379 listener3:name=tls,bind=*,bind=-::*,port=16379 valgrind test works fine: valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/valkey-server --port 6379 --loadmodule src/valkey-rdma.so port=6379 bind=xx.xx.xx.xx --loglevel verbose --protected-mode no --server_cpulist 2 --bio_cpulist 3 --aof_rewrite_cpulist 3 --bgsave_cpulist 3 --appendonly no performance test: server side: ./src/valkey-server --port 6379 # TCP port 6379 has no conflict with RDMA port 6379 --loadmodule src/valkey-rdma.so port=6379 bind=xx.xx.xx.xx bind=yy.yy.yy.yy --loglevel verbose --protected-mode no --server_cpulist 2 --bio_cpulist 3 --aof_rewrite_cpulist 3 --bgsave_cpulist 3 --appendonly no build a valkey-benchmark with RDMA support(not implemented in this patch), run on a x86(Intel Platinum 8260) with RoCEv2 interface(Mellanox ConnectX-5): client side: ./src/valkey-benchmark -h xx.xx.xx.xx -p 6379 -c 30 -n 10000000 --threads 4 -d 1024 -t ping,get,set --rdma ====== PING_INLINE ====== 480561.28 requests per second, 0.060 msec avg latency. ====== PING_MBULK ====== 540482.06 requests per second, 0.053 msec avg latency. ====== SET ====== 399952.00 requests per second, 0.073 msec avg latency. ====== GET ====== 443498.31 requests per second, 0.065 msec avg latency. Signed-off-by: zhenwei pi <[email protected]>
1 parent bb7e5bf commit 36bd4e5

File tree

3 files changed

+2019
-1
lines changed

3 files changed

+2019
-1
lines changed

RDMA.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
RDMA Support
22
============
33

4+
Getting Started
5+
---------------
6+
Note that Valkey Over RDMA is only supported by Linux.
7+
8+
## Building
9+
10+
To build with RDMA support you'll need RDMA development libraries (e.g.
11+
librdmacm-dev and libibverbs-dev on Debian/Ubuntu).
12+
13+
For now, Valkey only supports RDMA as connection module mode.
14+
Run `make BUILD_RDMA=module`.
15+
16+
## Running manually
17+
18+
To manually run a Valkey server with RDMA mode:
19+
20+
./src/valkey-server --protected-mode no \
21+
--loadmodule src/valkey-rdma.so bind=192.168.122.100 port=6379
22+
23+
It's possible to change bind address/port of RDMA by runtime command:
24+
10.2.16.101:6379> CONFIG SET rdma-port 6380
25+
26+
It's also possible to have both RDMA and TCP available, and there is no
27+
conflict of TCP(6379) and RDMA(6379), Ex:
28+
29+
./src/valkey-server --protected-mode no \
30+
--loadmodule src/valkey-rdma.so bind=192.168.122.100 port=6379 \
31+
--port 6379
32+
33+
Note that the network card (192.168.122.100 of this example) should support
34+
RDMA. To test a server supports RDMA or not:
35+
36+
~# rdma res show (a new version iproute2 package)
37+
Or:
38+
39+
~# ibv_devices
40+
441
Connections
542
-----------
643

@@ -121,3 +158,17 @@ setup TX buffer
121158
-------------------RDMA disconnect----------------->
122159
<------------------RDMA disconnect------------------
123160
```
161+
162+
163+
## Event handling
164+
There is no POLLOUT event of RDMA comp channel:
165+
1, if TX is not full, it's always writable.
166+
2, if TX is full, should wait a 'RegisterLocalAddr' message to refresh
167+
'TX buffer'.
168+
169+
To-Do List
170+
----------
171+
- [ ] hiredis
172+
- [ ] rdma client & benchmark
173+
- [ ] POLLOUT event emulation for hiredis
174+
- [ ] auto-test suite is not implemented currently

src/Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,21 @@ ifeq ($(BUILD_TLS),module)
332332
TLS_MODULE_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_MODULE)
333333
endif
334334

335+
RDMA_MODULE=
336+
RDMA_MODULE_NAME:=valkey-rdma$(PROG_SUFFIX).so
337+
RDMA_MODULE_CFLAGS:=$(FINAL_CFLAGS)
338+
ifeq ($(BUILD_RDMA),module)
339+
FINAL_CFLAGS+=-DUSE_RDMA=$(BUILD_MODULE)
340+
RDMA_PKGCONFIG := $(shell $(PKG_CONFIG) --exists librdmacm libibverbs && echo $$?)
341+
ifeq ($(RDMA_PKGCONFIG),0)
342+
RDMA_LIBS=$(shell $(PKG_CONFIG) --libs librdmacm libibverbs)
343+
else
344+
RDMA_LIBS=-lrdmacm -libverbs
345+
endif
346+
RDMA_MODULE=$(RDMA_MODULE_NAME)
347+
RDMA_MODULE_CFLAGS+=-DUSE_RDMA=$(BUILD_YES) -DBUILD_RDMA_MODULE $(RDMA_LIBS)
348+
endif
349+
335350
ifndef V
336351
define MAKE_INSTALL
337352
@printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2
@@ -409,7 +424,7 @@ ENGINE_TEST_OBJ:=$(sort $(patsubst unit/%.c,unit/%.o,$(ENGINE_TEST_FILES)))
409424
ENGINE_UNIT_TESTS:=$(ENGINE_NAME)-unit-tests$(PROG_SUFFIX)
410425
ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(ENGINE_SERVER_OBJ) $(ENGINE_CLI_OBJ) $(ENGINE_BENCHMARK_OBJ)))
411426

412-
all: $(SERVER_NAME) $(ENGINE_SENTINEL_NAME) $(ENGINE_CLI_NAME) $(ENGINE_BENCHMARK_NAME) $(ENGINE_CHECK_RDB_NAME) $(ENGINE_CHECK_AOF_NAME) $(TLS_MODULE)
427+
all: $(SERVER_NAME) $(ENGINE_SENTINEL_NAME) $(ENGINE_CLI_NAME) $(ENGINE_BENCHMARK_NAME) $(ENGINE_CHECK_RDB_NAME) $(ENGINE_CHECK_AOF_NAME) $(TLS_MODULE) $(RDMA_MODULE)
413428
@echo ""
414429
@echo "Hint: It's a good idea to run 'make test' ;)"
415430
@echo ""
@@ -432,6 +447,7 @@ persist-settings: distclean
432447
echo OPT=$(OPT) >> .make-settings
433448
echo MALLOC=$(MALLOC) >> .make-settings
434449
echo BUILD_TLS=$(BUILD_TLS) >> .make-settings
450+
echo BUILD_RDMA=$(BUILD_RDMA) >> .make-settings
435451
echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings
436452
echo CFLAGS=$(CFLAGS) >> .make-settings
437453
echo LDFLAGS=$(LDFLAGS) >> .make-settings
@@ -484,6 +500,10 @@ $(ENGINE_CHECK_AOF_NAME): $(SERVER_NAME)
484500
$(TLS_MODULE_NAME): $(SERVER_NAME)
485501
$(QUIET_CC)$(CC) -o $@ tls.c -shared -fPIC $(TLS_MODULE_CFLAGS) $(TLS_CLIENT_LIBS)
486502

503+
# valkey-rdma.so
504+
$(RDMA_MODULE_NAME): $(REDIS_SERVER_NAME)
505+
$(QUIET_CC)$(CC) -o $@ rdma.c -shared -fPIC $(RDMA_MODULE_CFLAGS)
506+
487507
# valkey-cli
488508
$(ENGINE_CLI_NAME): $(ENGINE_CLI_OBJ)
489509
$(SERVER_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)

0 commit comments

Comments
 (0)