Skip to content

Commit 0152ad9

Browse files
committed
add option to disable NotifyTransfer
1 parent b72c569 commit 0152ad9

4 files changed

Lines changed: 30 additions & 14 deletions

File tree

include/mori/io/backend.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,25 @@ struct BackendConfig {
4545
struct RdmaBackendConfig : public BackendConfig {
4646
RdmaBackendConfig() : BackendConfig(BackendType::RDMA) {}
4747
RdmaBackendConfig(int qpPerTransfer_, int postBatchSize_, int numWorkerThreads_,
48-
PollCqMode pollCqMode_)
48+
PollCqMode pollCqMode_, bool enableNotification_)
4949
: BackendConfig(BackendType::RDMA),
5050
qpPerTransfer(qpPerTransfer_),
5151
postBatchSize(postBatchSize_),
5252
numWorkerThreads(numWorkerThreads_),
53-
pollCqMode(pollCqMode_) {}
53+
pollCqMode(pollCqMode_),
54+
enableNotification(enableNotification_) {}
5455

5556
int qpPerTransfer{1};
5657
int postBatchSize{-1};
5758
int numWorkerThreads{1};
5859
PollCqMode pollCqMode{PollCqMode::POLLING};
60+
bool enableNotification{true}; // Enable/disable notification mechanism for transfer completion
5961
};
6062

6163
inline std::ostream& operator<<(std::ostream& os, const RdmaBackendConfig& c) {
6264
return os << "qpPerTransfer[" << c.qpPerTransfer << "] postBatchSize[" << c.postBatchSize
63-
<< "] numWorkerThreads[" << c.numWorkerThreads << "]";
65+
<< "] numWorkerThreads[" << c.numWorkerThreads << "] enableNotification["
66+
<< c.enableNotification << "]";
6467
}
6568

6669
/* ---------------------------------------------------------------------------------------------- */

src/application/transport/rdma/providers/ibverbs/ibverbs.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ void IBVerbsDeviceContext::ConnectEndpoint(const RdmaEndpointHandle& local,
171171
attr.dest_qp_num = remote.qpn;
172172
attr.rq_psn = 0;
173173
attr.max_dest_rd_atomic = devAttr->orig_attr.max_qp_rd_atom;
174-
// Set min_rnr_timer to 20 (approx 4.19 ms) to allow receiver more time to replenish buffers
175-
// Default was 12 (0.64 ms) which causes RNR exhaustion too quickly under burst
176-
attr.min_rnr_timer = 20;
174+
attr.min_rnr_timer = 12;
177175
attr.ah_attr.sl = 0;
178176
attr.ah_attr.src_path_bits = 0;
179177
attr.ah_attr.port_num = local.portId;
@@ -195,11 +193,10 @@ void IBVerbsDeviceContext::ConnectEndpoint(const RdmaEndpointHandle& local,
195193
// RTS
196194
attr.qp_state = IBV_QPS_RTS;
197195
attr.sq_psn = 0;
198-
attr.timeout = 20;
196+
attr.timeout = 14;
199197
attr.retry_cnt = 7;
200-
attr.rnr_retry = 6;
198+
attr.rnr_retry = 7;
201199
attr.max_rd_atomic = devAttr->orig_attr.max_qp_init_rd_atom;
202-
203200
flags = IBV_QP_STATE | IBV_QP_SQ_PSN | IBV_QP_TIMEOUT | IBV_QP_RETRY_CNT | IBV_QP_RNR_RETRY |
204201
IBV_QP_MAX_QP_RD_ATOMIC;
205202
SYSCALL_RETURN_ZERO(ibv_modify_qp(qp, &attr, flags));

src/io/rdma/backend_impl.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ void NotifManager::RegisterEndpointByQpn(uint32_t qpn) {
214214
SYSCALL_RETURN_ZERO(epoll_ctl(epfd, EPOLL_CTL_ADD, ep->local.ibvHandle.compCh->fd, &ev));
215215
}
216216

217+
// Skip notification setup if disabled
218+
if (!config.enableNotification) {
219+
return;
220+
}
221+
217222
std::lock_guard<std::mutex> lock(mu);
218223
if (qpNotifCtx.find(qpn) != qpNotifCtx.end()) return;
219224

@@ -260,6 +265,12 @@ void NotifManager::ProcessOneCqe(int qpn, const EpPair& ep) {
260265
while ((n = ibv_poll_cq(cq, batchSize, wc)) > 0) {
261266
for (int i = 0; i < n; ++i) {
262267
if (wc[i].opcode == IBV_WC_RECV) {
268+
// Skip RECV processing if notification is disabled
269+
if (!config.enableNotification) {
270+
MORI_IO_WARN("Received unexpected RECV completion when notification is disabled");
271+
continue;
272+
}
273+
263274
std::lock_guard<std::mutex> lock(mu);
264275

265276
assert(qpNotifCtx.find(qpn) != qpNotifCtx.end());
@@ -311,6 +322,9 @@ void NotifManager::ProcessOneCqe(int qpn, const EpPair& ep) {
311322
} else {
312323
statusPtr->SetMessage(ibv_wc_status_str(wc[i].status));
313324
statusPtr->SetCode(StatusCode::ERR_RDMA_OP);
325+
MORI_IO_ERROR("NotifManager receive cqe failed for task {} code {} status {}",
326+
msg->meta->id, static_cast<uint32_t>(wc[i].status),
327+
ibv_wc_status_str(wc[i].status));
314328
// set status to nullptr indicate that transfer failed
315329
msg->meta->status = nullptr;
316330
}
@@ -597,7 +611,7 @@ void RdmaBackendSession::ReadWrite(size_t localOffset, size_t remoteOffset, size
597611
status->SetMessage(ret.message);
598612
status->SetCode(ret.code);
599613
}
600-
if (!ret.Failed()) {
614+
if (!ret.Failed() && config.enableNotification) {
601615
RdmaOpRet notifRet = RdmaNotifyTransfer(eps, status, id);
602616
if (notifRet.Failed()) {
603617
status->SetMessage(notifRet.message);
@@ -626,7 +640,7 @@ void RdmaBackendSession::BatchReadWrite(const SizeVec& localOffsets, const SizeV
626640
status->SetMessage(ret.message);
627641
status->SetCode(ret.code);
628642
}
629-
if (!ret.Failed()) {
643+
if (!ret.Failed() && config.enableNotification) {
630644
RdmaOpRet notifRet = RdmaNotifyTransfer(eps, status, id);
631645
if (notifRet.Failed()) {
632646
status->SetMessage(notifRet.message);

src/pybind/mori.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,15 @@ void RegisterMoriIo(pybind11::module_& m) {
311311
py::class_<mori::io::BackendConfig>(m, "BackendConfig");
312312

313313
py::class_<mori::io::RdmaBackendConfig, mori::io::BackendConfig>(m, "RdmaBackendConfig")
314-
.def(py::init<int, int, int, mori::io::PollCqMode>(), py::arg("qp_per_transfer") = 1,
314+
.def(py::init<int, int, int, mori::io::PollCqMode, bool>(), py::arg("qp_per_transfer") = 1,
315315
py::arg("post_batch_size") = -1, py::arg("num_worker_threads") = -1,
316-
py::arg("poll_cq_mode") = mori::io::PollCqMode::POLLING)
316+
py::arg("poll_cq_mode") = mori::io::PollCqMode::POLLING,
317+
py::arg("enable_notification") = true)
317318
.def_readwrite("qp_per_transfer", &mori::io::RdmaBackendConfig::qpPerTransfer)
318319
.def_readwrite("post_batch_size", &mori::io::RdmaBackendConfig::postBatchSize)
319320
.def_readwrite("num_worker_threads", &mori::io::RdmaBackendConfig::numWorkerThreads)
320-
.def_readwrite("poll_cq_mode", &mori::io::RdmaBackendConfig::pollCqMode);
321+
.def_readwrite("poll_cq_mode", &mori::io::RdmaBackendConfig::pollCqMode)
322+
.def_readwrite("enable_notification", &mori::io::RdmaBackendConfig::enableNotification);
321323

322324
py::class_<mori::io::IOEngineConfig>(m, "IOEngineConfig")
323325
.def(py::init<std::string, uint16_t>(), py::arg("host") = "", py::arg("port") = 0)

0 commit comments

Comments
 (0)