Skip to content

Commit 9ac2d32

Browse files
authored
add auto increase mempool for rdma (#140)
1 parent 1ef6744 commit 9ac2d32

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/infinistore.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ ibv_mtu active_mtu;
4040

4141
// indicate if the MM extend is in flight
4242
bool extend_in_flight = false;
43-
// indicate the number of cudaIpcOpenMemHandle
44-
std::atomic<unsigned int> opened_ipc{0};
4543

4644
std::unordered_map<uintptr_t, boost::intrusive_ptr<PTR>> inflight_rdma_writes;
4745

@@ -328,6 +326,14 @@ void Client::cq_poll_handle(uv_poll_t *handle, int status, int events) {
328326
}
329327
}
330328

329+
void add_mempool(uv_work_t *req) { mm->add_mempool(pd); }
330+
331+
void add_mempool_completion(uv_work_t *req, int status) {
332+
extend_in_flight = false;
333+
mm->need_extend = false;
334+
delete req;
335+
}
336+
331337
int Client::allocate_rdma(const RemoteMetaRequest *req) {
332338
INFO("do allocate_rdma...");
333339

@@ -372,6 +378,13 @@ int Client::allocate_rdma(const RemoteMetaRequest *req) {
372378
blocks.clear();
373379
}
374380

381+
if (global_config.auto_increase && mm->need_extend && !extend_in_flight) {
382+
INFO("Extend another mempool");
383+
uv_work_t *req = new uv_work_t();
384+
uv_queue_work(loop, req, add_mempool, add_mempool_completion);
385+
extend_in_flight = true;
386+
}
387+
375388
auto resp = CreateRdmaAllocateResponseDirect(builder, &blocks, error_code);
376389
builder.Finish(resp);
377390

@@ -563,19 +576,6 @@ void on_write(uv_write_t *req, int status) {
563576
free(req);
564577
}
565578

566-
void add_mempool(uv_work_t *req) {
567-
while (opened_ipc > 0) {
568-
std::this_thread::sleep_for(std::chrono::milliseconds(100));
569-
}
570-
mm->add_mempool(pd);
571-
}
572-
573-
void add_mempool_completion(uv_work_t *req, int status) {
574-
extend_in_flight = false;
575-
mm->need_extend = false;
576-
delete req;
577-
}
578-
579579
int init_rdma_context(server_config_t config) {
580580
struct ibv_device **dev_list;
581581
struct ibv_device *ib_dev;

0 commit comments

Comments
 (0)