detect and negotiate mtu - #3304
Conversation
|
Please update the RDMA UTs in brpc_rdma_unittest.cpp. |
I can't find a way to check the rdma communication between the current version including mtu negotiation and without mtu negotiation in ut, any advice? |
You can refer to client_hello_msg_invalid_sq_rq_block_size, server_hello_invalid_sq_rq_size, etc. |
|
With #3326 , mtu should be negotiated through V3. |
| // before C_HELLO_SEND); | ||
| // Server: the negotiated MTU = min(local_active_mtu, client_mtu) | ||
| // (filled in BringUpQp). | ||
| butil::optional<uint32_t> _outgoing_mtu; |
There was a problem hiding this comment.
Why use uint32_t instead of ibv_mtu?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/brpc/rdma/rdma_handshake.cpp:420
- Client v3 handshake never advertises MTU in the default unit-test configuration because this code is gated on g_skip_rdma_init. In this repo's tests, main() sets g_skip_rdma_init=true when FLAGS_rdma_test_enable is false, which makes TEST_F(RdmaTest, v3_client_hello_includes_mtu) fail and also prevents exercising MTU negotiation logic in UT mode. Since GetRdmaActiveMtu() already has a safe default (IBV_MTU_1024), it can be advertised even when RDMA init is skipped.
// Best-effort: any failure just means we won't advertise MTU
// (the peer falls back to IBV_MTU_1024).
if (!g_skip_rdma_init) {
_ep->_outgoing_mtu = GetRdmaActiveMtu();
}
test/brpc_rdma_unittest.cpp:1975
- This test assumes the server computes and advertises negotiated MTU even when g_skip_rdma_init=true (the default when FLAGS_rdma_test_enable is not set). However, in that mode RdmaEndpoint::BringUpQp() returns early before MTU negotiation runs, leaving _outgoing_mtu unset; the server hello will omit mtu and EXPECT_TRUE(reply.has_mtu()) will fail. Either make the negotiation run in skip-init mode or skip this test unless RDMA runtime is enabled.
// The server reply must carry a negotiated MTU when the client advertised one.
// Since UT skips real QP bring-up, the server computes min(local, client) and
// stores it in _outgoing_mtu; FillLocalRdmaHello then includes it in the reply.
TEST_F(RdmaTest, v3_server_reply_has_negotiated_mtu) {
StartServer();
| uint32_t negotiated_mtu = IBV_MTU_1024; | ||
| if (remote.path_mtu.has_value()) { | ||
| if (is_server) { | ||
| uint32_t local_mtu = GetRdmaActiveMtu(); | ||
| negotiated_mtu = std::min(local_mtu, *remote.path_mtu); | ||
| // Store the negotiated MTU for the server hello reply. | ||
| _outgoing_mtu = negotiated_mtu; | ||
| } else { | ||
| negotiated_mtu = *remote.path_mtu; | ||
| } | ||
| } | ||
| attr.path_mtu = static_cast<ibv_mtu>(negotiated_mtu); |
What problem does this PR solve?
Issue Number: resolve
Problem Summary:
What is changed and the side effects?
Changed:
Side effects:
The bandwith of rdma perf will be increased 25%(in my case, from 33GB/s to 41GB/s ).
Check List: