在我的应用程序中,我使用infiniband基础设施将数据流从一个服务器发送到另一个服务器。我已经习惯于简化infiniband上的开发ip,因为我更熟悉套接字编程。到目前为止,性能(最大带宽)对我来说已经足够好了(我知道我没有获得可实现的最大带宽),现在我需要从infiniband连接中获得更多带宽。
ib_write_bw声称我的最大可达到带宽大约是1500MB/s(我没有达到3000MB/s,因为我的卡安装在PCI2.08x上)。
到目前一切尚好。我使用ibverbs和rdma编码我的通信通道,但我得到的带宽远远小于我能获得的带宽,我甚至比使用套接字获得的带宽要少一点,但至少我的应用程序不使用任何CPU能力:
ib_write_bw: 1500MB/s
插槽:700MB/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");
}此时,等待完成的下一段代码是:
//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";
}当传输8MB的区块时,从我的ibv_post_send到ibv_get_cq_event返回事件的时间是13.3ms,然后达到大约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有人知道我做错了什么吗?或者我能改进什么?我没有受到“不是在这里发明的”综合症的影响,所以我甚至愿意抛弃我到目前为止所做的事情,采用其他的东西。我只需要一个点对点的连续传输。
发布于 2012-08-30 02:20:17
我解决了根据页面大小分配要传输的缓冲区的问题。在我的系统中,页面大小是4K (sysconf(_SC_PAGESIZE)返回的值)。这样,我现在能够(我仍然在做注册/注销)达到1400MB/秒左右。
发布于 2012-08-25 01:06:47
根据您的伪代码,看起来好像您为每次传输注册和取消注册了一个内存区域。我认为这可能是事情变慢的主要原因:内存注册是一个非常昂贵的操作,所以您希望尽可能少地进行注册,并尽可能多地重用内存区域。注册内存所花费的所有时间就是您不花在传输数据上的时间。
这指出了伪代码的第二个问题:您正在同步等待完成,并且在前一个工作请求完成之前不会发布另一个工作请求。这意味着从工作请求完成到您完成并发布另一个请求的这段时间内,HCA是空闲的。您最好将多个发送/接收工作请求保持在动态状态,以便当HCA完成一个工作请求时,它可以立即转移到下一个请求。
https://stackoverflow.com/questions/12100970
复制相似问题