Skip to content

Implement runtime dynamic loading for RDMA libraries#284

Merged
bjosv merged 1 commit into
valkey-io:mainfrom
quanyeyang:feature/dynamic-rdma-loading
Feb 23, 2026
Merged

Implement runtime dynamic loading for RDMA libraries#284
bjosv merged 1 commit into
valkey-io:mainfrom
quanyeyang:feature/dynamic-rdma-loading

Conversation

@quanyeyang

Copy link
Copy Markdown
Contributor

Summary

This PR implements runtime dynamic loading (lazy loading) for RDMA libraries (librdmacm and libibverbs).

This is the upstream port of the changes discussed and approved in the main Valkey repository (see valkey-io/valkey#3072).

Why this is needed

Currently, enabling RDMA support forces a hard compile-time dependency on RDMA libraries. This creates significant packaging overhead for Linux distributions that want to ship valkey-cli and valkey-benchmark without forcing users to install RDMA drivers if they only use TCP/UNIX sockets.

Implementation Details

  • Symbol Table (struct rdma_dyn_syms): Replaced direct hard-linked function calls with a symbol table.
  • Avoiding Redeclaration: Wrapped the pointers in a struct and used #define macros after including <rdma/rdma_cma.h> and <infiniband/verbs.h>. This avoids GCC redeclaration errors/namespace conflicts with the native prototypes while keeping all original call sites completely untouched.
  • Inline Functions: Critical data-path static inline functions are intentionally excluded from dlsym resolution to maintain performance and avoid missing-symbol errors on newer rdma-core versions.

CC: @zuiderkwast @pizhenwei @bjosv @michael-grunder
(As discussed in valkey#3072, porting these vendored changes back to the root libvalkey repo).

Comment thread Makefile Outdated
Comment thread CMakeLists.txt Outdated
@quanyeyang quanyeyang force-pushed the feature/dynamic-rdma-loading branch from c9d3474 to a32e4ee Compare February 21, 2026 03:39
@quanyeyang

Copy link
Copy Markdown
Contributor Author

@bjosv Thank you for the review! That makes perfect sense.

I've updated the build files to follow the existing naming conventions and scopes:

  • Makefile: Added USE_DLOPEN_RDMA?=0 and moved its conditional check inside the ifeq ($(USE_RDMA),1) scope.
  • CMake: Added OPTION(ENABLE_DLOPEN_RDMA "..." OFF) at the top and updated the conditional branch to use ENABLE_DLOPEN_RDMA.
    The changes have been pushed!

@pizhenwei pizhenwei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

Comment thread src/rdma.c
Comment thread src/rdma.c Outdated
Signed-off-by: Ada-Church-Closure <nunotabashinobu066@gmail.com>
@quanyeyang quanyeyang force-pushed the feature/dynamic-rdma-loading branch from a32e4ee to ce73a2e Compare February 23, 2026 03:45
@bjosv bjosv merged commit 40d6590 into valkey-io:main Feb 23, 2026
69 of 70 checks passed
@quanyeyang quanyeyang deleted the feature/dynamic-rdma-loading branch February 23, 2026 11:01
zuiderkwast pushed a commit to valkey-io/valkey that referenced this pull request Feb 26, 2026
…3072)

This PR decouples the mandatory RDMA library dependency from
`valkey-cli` and `valkey-benchmark` by implementing a **runtime dynamic
loading (lazy loading)** mechanism.

When `BUILD_RDMA=module` is used, the CLI tools are no longer
hard-linked to `librdmacm` and `libibverbs`. Instead, these libraries
are only loaded via `dlopen` when the `--rdma` flag is explicitly
invoked by the user.

- **Dynamic Symbol Loader**: Implemented a symbol loader in libvalkey
using dlopen() and dlsym(), here:
valkey-io/libvalkey#284. That was merged and
libvalkey was updated in valkey to include this change.
- **Build System Propagation**:
- **Makefile**: When building as a module, pass `USE_DLOPEN_RDMA` flag
to libvalkey's makefile.
- **CMake**: When building as a module, pass `ENABLE_DLOPEN_RDMA` flag
to libvalkey's CMake build.

Fixes #3070

Signed-off-by: Ada-Church-Closure <nunotabashinobu066@gmail.com>
hpatro pushed a commit to hpatro/valkey that referenced this pull request Mar 5, 2026
…alkey-io#3072)

This PR decouples the mandatory RDMA library dependency from
`valkey-cli` and `valkey-benchmark` by implementing a **runtime dynamic
loading (lazy loading)** mechanism.

When `BUILD_RDMA=module` is used, the CLI tools are no longer
hard-linked to `librdmacm` and `libibverbs`. Instead, these libraries
are only loaded via `dlopen` when the `--rdma` flag is explicitly
invoked by the user.

- **Dynamic Symbol Loader**: Implemented a symbol loader in libvalkey
using dlopen() and dlsym(), here:
valkey-io/libvalkey#284. That was merged and
libvalkey was updated in valkey to include this change.
- **Build System Propagation**:
- **Makefile**: When building as a module, pass `USE_DLOPEN_RDMA` flag
to libvalkey's makefile.
- **CMake**: When building as a module, pass `ENABLE_DLOPEN_RDMA` flag
to libvalkey's CMake build.

Fixes valkey-io#3070

Signed-off-by: Ada-Church-Closure <nunotabashinobu066@gmail.com>
Signed-off-by: Harkrishn Patro <bunty.hari@gmail.com>
hanzo-dev pushed a commit to hanzoai/kv that referenced this pull request Jun 10, 2026
…3072)

This PR decouples the mandatory RDMA library dependency from
`valkey-cli` and `valkey-benchmark` by implementing a **runtime dynamic
loading (lazy loading)** mechanism.

When `BUILD_RDMA=module` is used, the CLI tools are no longer
hard-linked to `librdmacm` and `libibverbs`. Instead, these libraries
are only loaded via `dlopen` when the `--rdma` flag is explicitly
invoked by the user.

- **Dynamic Symbol Loader**: Implemented a symbol loader in libvalkey
using dlopen() and dlsym(), here:
valkey-io/libvalkey#284. That was merged and
libvalkey was updated in valkey to include this change.
- **Build System Propagation**:
- **Makefile**: When building as a module, pass `USE_DLOPEN_RDMA` flag
to libvalkey's makefile.
- **CMake**: When building as a module, pass `ENABLE_DLOPEN_RDMA` flag
to libvalkey's CMake build.

Fixes #3070

Signed-off-by: Ada-Church-Closure <nunotabashinobu066@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants