Skip to content

Commit 90c4ca8

Browse files
committed
Introduce RDMA transport
Main changes in this patch: * implement server side of connection module only, this means we can *NOT* compile RDMA support as built-in. * add necessary information in README.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 6bab2d7 commit 90c4ca8

File tree

3 files changed

+1957
-1
lines changed

3 files changed

+1957
-1
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ libssl-dev on Debian/Ubuntu) and run:
3131

3232
% make BUILD_TLS=yes
3333

34+
To build with RDMA support you'll need RDMA development libraries (e.g.
35+
librdmacm-dev and libibverbs-dev on Debian/Ubuntu). For now, Valkey only
36+
supports RDMA as connection module mode. Run:
37+
38+
% make BUILD_RDMA=module
39+
3440
To build with systemd support, you'll need systemd development libraries (such
3541
as libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS) and run:
3642

@@ -155,6 +161,36 @@ Running Valkey with TLS:
155161
Please consult the [TLS.md](TLS.md) file for more information on
156162
how to use Valkey with TLS.
157163

164+
Running Valkey with RDMA:
165+
------------------
166+
167+
Note that Valkey Over RDMA is only supported by Linux currently.
168+
169+
To manually run a Valkey server with RDMA mode:
170+
171+
% ./src/valkey-server --protected-mode no \
172+
--loadmodule src/valkey-rdma.so bind=192.168.122.100 port=6379
173+
174+
It's possible to change bind address/port of RDMA by runtime command:
175+
176+
10.2.16.101:6379> CONFIG SET rdma-port 6380
177+
178+
It's also possible to have both RDMA and TCP available, and there is no
179+
conflict of TCP(6379) and RDMA(6379), Ex:
180+
181+
% ./src/valkey-server --protected-mode no \
182+
--loadmodule src/valkey-rdma.so bind=192.168.122.100 port=6379 \
183+
--port 6379
184+
185+
Note that the network card (192.168.122.100 of this example) should support
186+
RDMA. To test a server supports RDMA or not:
187+
188+
% rdma res show (a new version iproute2 package)
189+
Or:
190+
191+
% ibv_devices
192+
193+
158194
Playing with Valkey
159195
------------------
160196

src/Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,27 @@ 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+
else
349+
ifeq ($(BUILD_RDMA),no)
350+
# disable RDMA, do nothing
351+
else
352+
$(error "RDMA is only supported as module(BUILD_RDMA=module), or disabled(BUILD_RDMA=no)")
353+
endif
354+
endif
355+
335356
ifndef V
336357
define MAKE_INSTALL
337358
@printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2
@@ -409,7 +430,7 @@ ENGINE_TEST_OBJ:=$(sort $(patsubst unit/%.c,unit/%.o,$(ENGINE_TEST_FILES)))
409430
ENGINE_UNIT_TESTS:=$(ENGINE_NAME)-unit-tests$(PROG_SUFFIX)
410431
ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(ENGINE_SERVER_OBJ) $(ENGINE_CLI_OBJ) $(ENGINE_BENCHMARK_OBJ)))
411432

412-
all: $(SERVER_NAME) $(ENGINE_SENTINEL_NAME) $(ENGINE_CLI_NAME) $(ENGINE_BENCHMARK_NAME) $(ENGINE_CHECK_RDB_NAME) $(ENGINE_CHECK_AOF_NAME) $(TLS_MODULE)
433+
all: $(SERVER_NAME) $(ENGINE_SENTINEL_NAME) $(ENGINE_CLI_NAME) $(ENGINE_BENCHMARK_NAME) $(ENGINE_CHECK_RDB_NAME) $(ENGINE_CHECK_AOF_NAME) $(TLS_MODULE) $(RDMA_MODULE)
413434
@echo ""
414435
@echo "Hint: It's a good idea to run 'make test' ;)"
415436
@echo ""
@@ -432,6 +453,7 @@ persist-settings: distclean
432453
echo OPT=$(OPT) >> .make-settings
433454
echo MALLOC=$(MALLOC) >> .make-settings
434455
echo BUILD_TLS=$(BUILD_TLS) >> .make-settings
456+
echo BUILD_RDMA=$(BUILD_RDMA) >> .make-settings
435457
echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings
436458
echo CFLAGS=$(CFLAGS) >> .make-settings
437459
echo LDFLAGS=$(LDFLAGS) >> .make-settings
@@ -484,6 +506,10 @@ $(ENGINE_CHECK_AOF_NAME): $(SERVER_NAME)
484506
$(TLS_MODULE_NAME): $(SERVER_NAME)
485507
$(QUIET_CC)$(CC) -o $@ tls.c -shared -fPIC $(TLS_MODULE_CFLAGS) $(TLS_CLIENT_LIBS)
486508

509+
# valkey-rdma.so
510+
$(RDMA_MODULE_NAME): $(REDIS_SERVER_NAME)
511+
$(QUIET_CC)$(CC) -o $@ rdma.c -shared -fPIC $(RDMA_MODULE_CFLAGS)
512+
487513
# valkey-cli
488514
$(ENGINE_CLI_NAME): $(ENGINE_CLI_OBJ)
489515
$(SERVER_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)

0 commit comments

Comments
 (0)