infiniband rdma 不良传输 bw

Gae*_*ola 5 linux performance rdma infiniband

在我的应用程序中,我使用 infiniband 基础设施将数据流从服务器发送到另一个服务器。我过去习惯通过 infiniband 轻松开发 ip,因为我更熟悉套接字编程。到目前为止,性能(最大带宽)对我来说已经足够好了(我知道我没有获得可实现的最大带宽),现在我需要从无限带宽连接中获得更多带宽。

ib_write_bw 声称我的最大可实现带宽约为 1500 MB/s(我没有得到 3000MB/s,因为我的卡安装在 PCI 2.0 8x 中)。

到现在为止还挺好。我使用 ibverbs 和 rdma 对我的通信通道进行了编码,但我得到的带宽远远低于我可以获得的带宽,我什至获得的带宽比使用套接字少一点,但至少我的应用程序不使用任何 CPU 功率:

ib_write_bw:1500 MB/s

套接字:700 MB/s <= 在此测试期间,我的系统的一个核心处于 100%

ibvers+rdma: 600 MB/s <= 在这个测试过程中根本没有使用 CPU

看来瓶颈就在这里:

ibv_sge sge;
sge.addr = (uintptr_t)memory_to_transfer;
sge.length = memory_to_transfer_size;
sge.lkey = memory_to_transfer_mr->lkey;

ibv_send_wr wr;
memset(&wr, 0, sizeof(wr));
wr.wr_id = 0;
wr.opcode = IBV_WR_RDMA_WRITE;
wr.sg_list = &sge;
wr.num_sge = 1;
wr.send_flags = IBV_SEND_SIGNALED;
wr.wr.rdma.remote_addr = (uintptr_t)thePeerMemoryRegion.addr;
wr.wr.rdma.rkey = thePeerMemoryRegion.rkey;

ibv_send_wr *bad_wr = NULL;
if (ibv_post_send(theCommunicationIdentifier->qp, &wr, &bad_wr) != 0) {
  notifyError("Unable to ibv post receive");
}
Run Code Online (Sandbox Code Playgroud)

此时等待完成的下一个代码是:

//Wait for completation
ibv_cq *cq;
void* cq_context;
if (ibv_get_cq_event(theCompletionEventChannel, &cq, &cq_context) != 0) {
  notifyError("Unable to get a ibv cq event");
}

ibv_ack_cq_events(cq, 1);

if (ibv_req_notify_cq(cq, 0) != 0) {
  notifyError("Unable to get a req notify");
}

ibv_wc wc;
int myRet = ibv_poll_cq(cq, 1, &wc);
if (myRet > 1) {
  LOG(WARNING) << "Got more than a single ibv_wc, expecting one";
}
Run Code Online (Sandbox Code Playgroud)

从我的 ibv_post_send 到 ibv_get_cq_event 返回事件的时间是 13.3 毫秒,当传输 8 MB 的数据块时,达到大约 600 MB/s。

要指定更多(在伪代码中我在全局执行的操作):

主动端:

post a message receive
rdma connection
wait for rdma connection event
<<at this point transfer tx flow starts>>
start:
register memory containing bytes to transfer
wait remote memory region addr/key ( I wait for a ibv_wc)
send data with ibv_post_send
post a message receive
wait for ibv_post_send event ( I wait for a ibv_wc) (this lasts 13.3 ms)
send message "DONE"
unregister memory 
goto start
Run Code Online (Sandbox Code Playgroud)

被动方面:

post a message receive
rdma accept
wait for rdma connection event
<<at this point transfer rx flow starts>>
start:
register memory that has to receive the bytes
send addr/key of memory registered
wait "DONE" message 
unregister memory
post a message receive
goto start
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?或者我可以改进什么?我没有受到“这里不是发明”综合症的影响,所以我什至愿意扔掉我迄今为止所做的事情并采用其他东西。我只需要点对点连续传输。

Gae*_*ola 2

我解决了分配要传输的缓冲区与页面大小对齐的问题。在我的系统中页面大小为 4K(sysconf(_SC_PAGESIZE) 返回的值)。这样做我现在能够(我仍然进行注册/取消注册)达到大约 1400 MB/秒。