infiniband rdma穷人转会bw

在我的应用程序中,我使用infiniband基础结构将数据stream从服务器发送到另一个。 我已经习惯了简单的开发IP over infiniband,因为我更熟悉套接字编程。 到目前为止,性能(max bw)对我来说已经足够好了(我知道我没有获得可实现的最大带宽),现在我需要从该infiniband连接中获得更多的带宽。

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

到现在为止还挺好。 我使用ibverbs和rdma编写了我的通信频道,但是我所得到的带宽远远低于我可以得到的带宽,甚至比使用套接字less得多,但是至less我的应用程序不使用任何CPU功率:

ib_write_bw:1500 MB / s

套接字:700 MB / s <=在testing期间,我的系统的一个核心是100%

ibvers + rdma:600 MB / s <=在此testing期间根本不使用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"); } 

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

 //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"; } 

当从我的ibv_post_send到ibv_get_cq_event返回一个事件的时间为13.3ms时,传输8MB的块达到600MB / 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 

被动方:

 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 

有谁知道我在做什么错了? 或者我可以改进? 我不受“这里没有发明”综合症的影响,所以我甚至会公开抛弃我迄今为止所做的并采取了其他措施。 我只需要点到点的连续转移。

根据您的伪代码,看起来好像您为每次传输注册和取消注册一个内存区域。 我认为这可能是事情发生缓慢的主要原因:内存注册是一个非常昂贵的操作,所以你希望尽可能少地使用它,并尽可能地重用你的内存区域。 注册内存的所有时间都是您不用于传输数据的时间。

这指出了你的伪代码的第二个问题:你正在同步等待完成,并没有发布另一个工作请求,直到前一个完成。 这意味着在从工作请求完成到完成并发布另一个请求的时间内,HCA处于闲置状态。 在飞行中保留多个发送/接收工作请求要好得多,以便当HCA完成一个工作请求时,可以立即转到下一个工作请求。

我解决了分配我的缓冲区的问题被传输alligned到页面大小。 在我的系统页面大小是4K(由sysconf(_SC_PAGESIZE)返回的值)。 这样做我能够(我仍然注册/注销)达到现在约1400 MB /秒。