Repository navigation
Fall back from SRQ to a dedicated RQ before TCP - #3782
Open
chenBright wants to merge 1 commit into
Open
chenBright wants to merge 1 commit into
chenBright wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical RDMA initialization issue remains: eager preallocation of the default resource pool can exhaust HCA or system resources and cause startup failure before the SRQ path can operate.
1 open issue
What changed in this PR
This PR updates RDMA connection negotiation so SRQ-preferring clients can fall back to a dedicated receive queue before using TCP, while adding runtime SRQ admission control and broader compatibility coverage.
Changes:
- Adds client-side dedicated-RQ retry, bounded reconnects, v2/v3 handshake compatibility, deadline handling, and TCP fallback.
- Adds
rdma_connect_srqandrdma_accept_srqflags with cached SRQ capability validation and server admission control. - Expands SRQ/RDMA resource and handshake tests and updates English and Chinese documentation.
| File | Description |
|---|---|
| test/brpc_srq_unittest.cpp | Updates SRQ option and device tests and adds worker recovery and admission-control coverage. |
| test/brpc_rdma_unittest.cpp | Adds handshake fallback, refusal, deadline, queue-mode, and resource-failure tests. |
| src/brpc/rdma/srq_worker.h | Exposes SRQ device capability validation and removes the obsolete SRQ flag declaration. |
| src/brpc/rdma/srq_worker.cpp | Refactors SRQ capability validation and rate-limits resource allocation diagnostics. |
| src/brpc/rdma/srq_receive_pool.cpp | Rate-limits receive-pool allocation and registration errors. |
| src/brpc/rdma/rq_connection.cpp | Enables dedicated-QP resource precreation regardless of SRQ preference. |
| src/brpc/rdma/rdma_helper.h | Declares the SRQ availability query interface. |
| src/brpc/rdma/rdma_helper.cpp | Caches and exposes SRQ hardware and configuration availability. |
| src/brpc/rdma/rdma_handshake.proto | Adds the optional v3 refusal indicator. |
| src/brpc/rdma/rdma_handshake.h | Adds the declined handshake result and updates refusal semantics. |
| src/brpc/rdma/rdma_handshake.cpp | Recognizes explicit and legacy v3 refusals during client negotiation. |
| src/brpc/rdma/rdma_handshake_server.h | Declares shared v3 refusal-message construction. |
| src/brpc/rdma/rdma_handshake_server.cpp | Emits explicit refusal responses for RDMA and TCP-only paths. |
| src/brpc/rdma/rdma_endpoint.h | Declares client negotiation, queue allocation, and handshake-finalization helpers. |
| src/brpc/rdma/rdma_endpoint.cpp | Implements SRQ/private-RQ negotiation, reconnect fallback, server admission, and deadline-aware handshake completion. |
| docs/en/rdma.md | Documents the new SRQ flags, fallback behavior, and resource implications in English. |
| docs/cn/rdma.md | Documents the new SRQ flags, fallback behavior, and resource implications in Chinese. |
Review effort: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What problem does this PR solve?
Issue Number: resolve
Problem Summary:
A client that requests a shared receive queue (SRQ) can fall back to TCP even when both peers support RDMA with a dedicated receive queue (RQ).
What is changed and the side effects?
Changed:
ACK=0and allocates a dedicated QP. It reconnects only if allocation succeeds. Otherwise, it can send the pending RPC over the original TCP connection.qp_num=0and valid dedicated-RQ parameters. Peers that only support v2 can still negotiate a dedicated RQ. Each logical connection gets at most two hello exchanges under the original connect deadline. A scheduling delay after the final ACK no longer turns a completed handshake into a timeout.rdma_connect_srqfor outgoing connections (defaultfalse) andrdma_accept_srqfor incoming connections (defaulttrue). Turning off server admission through/flagsdeclines new SRQ requests before allocating resources. Established SRQ connections continue serving RPCs.Handshake fallback:
Ais the original TCP connection.Bis opened only for a second handshake. Before sending any hello, the client can switch from SRQ to a dedicated RQ onA. If neither QP can be allocated and the connection is still usable, the RPC goes directly over TCP onA.sequenceDiagram participant C as Client participant S as Server C->>S: A · v3 hello with SRQ or dedicated RQ alt Matching queue mode and local QP activation succeeds S-->>C: A · matching RDMA parameters C->>S: A · ACK=1 C->>S: RPC over RDMA else Retryable SRQ failure S-->>C: A · v3 reply C->>S: A · ACK=0 C->>C: Allocate a dedicated QP while A is still usable alt QP allocated C->>S: Open B C->>S: B · v3 hello with dedicated RQ else QP unavailable C->>S: RPC over TCP on A end else Peer closes early, resets, or replies with v2 magic C->>S: Open B C->>C: Reuse or allocate a dedicated QP alt QP ready C->>S: B · v2 hello with dedicated RQ else QP unavailable C->>S: RPC over TCP on B end else Other complete but unusable reply S-->>C: A · unusable RDMA parameters C->>S: A · ACK=0 C->>S: RPC over TCP on A end opt A second hello was sent on B alt Matching parameters and local QP activation succeeds S-->>C: B · dedicated RQ parameters C->>S: B · ACK=1 C->>S: RPC over RDMA else Complete reply but RDMA cannot be established S-->>C: B · hello reply C->>S: B · ACK=0 C->>S: RPC over TCP on B else Another version retry is requested C->>C: Fail the connection end endA retryable SRQ failure is an explicit or historical refusal, a valid dedicated-RQ reply to an SRQ offer, or a local SRQ QP activation failure. A legacy all-zero refusal gives no indication whether the server supports a dedicated RQ. Cancellation, deadline expiry during negotiation, a failed reconnect, or a fatal I/O or framing error ends the handshake with an error.
Side effects:
Performance effects:
Breaking backward compatibility:
Check List: