Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TransferEngine]chore: replace slices vector with slice counter #93

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions mooncake-transfer-engine/include/transport/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,9 @@ class Transport {
};

struct TransferTask {
~TransferTask() {
for (auto &entry : slices) delete entry;
slices.clear();
}

std::vector<Slice *> slices;

volatile uint64_t slice_count = 0;
volatile uint64_t success_slice_count = 0;
volatile uint64_t failed_slice_count = 0;
volatile uint64_t transferred_bytes = 0;
Expand Down
2 changes: 1 addition & 1 deletion mooncake-transfer-engine/src/multi_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int MultiTransport::getTransferStatus(BatchID batch_id, size_t task_id,
uint64_t success_slice_count = task.success_slice_count;
uint64_t failed_slice_count = task.failed_slice_count;
if (success_slice_count + failed_slice_count ==
(uint64_t)task.slices.size()) {
task.slice_count) {
if (failed_slice_count) {
status.s = Transport::TransferStatusEnum::FAILED;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ int NVMeoFTransport::submitTransfer(

nvmeof_desc.transfer_status.push_back(
TransferStatus{.s = PENDING, .transferred_bytes = 0});
nvmeof_desc.task_to_slices.push_back({slice_id, task.slices.size()});
nvmeof_desc.task_to_slices.push_back({slice_id, task.slice_count});
++task_id;
slice_id += task.slices.size();
slice_id += task.slice_count;
}

desc_pool_->submitBatch(nvmeof_desc.desc_idx_);
Expand Down Expand Up @@ -229,6 +229,10 @@ void NVMeoFTransport::addSliceToTask(void *source_addr, uint64_t slice_len,
TransferRequest::OpCode op,
TransferTask &task,
const char *file_path) {
if (!source_addr || !file_path) {
LOG(ERROR) << "Invalid source_addr or file_path";
return;
}
Slice *slice = new Slice();
slice->source_addr = (char *)source_addr;
slice->length = slice_len;
Expand All @@ -238,7 +242,7 @@ void NVMeoFTransport::addSliceToTask(void *source_addr, uint64_t slice_len,
slice->task = &task;
slice->status = Slice::PENDING;
task.total_bytes += slice->length;
task.slices.push_back(slice);
task.slice_count += 1;
}

void NVMeoFTransport::addSliceToCUFileBatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int RdmaTransport::submitTransfer(BatchID batch_id,
local_segment_desc->buffers[buffer_id].lkey[device_id];
slices_to_post[context].push_back(slice);
task.total_bytes += slice->length;
task.slices.push_back(slice);
task.slice_count++;
break;
}
if (device_id < 0) {
Expand Down Expand Up @@ -290,7 +290,8 @@ int RdmaTransport::submitTransferTask(
local_segment_desc->buffers[buffer_id].lkey[device_id];
slices_to_post[context].push_back(slice);
task.total_bytes += slice->length;
task.slices.push_back(slice);
// task.slices.push_back(slice);
task.slice_count += 1;
break;
}
if (device_id < 0) {
Expand All @@ -317,7 +318,7 @@ int RdmaTransport::getTransferStatus(BatchID batch_id,
uint64_t success_slice_count = task.success_slice_count;
uint64_t failed_slice_count = task.failed_slice_count;
if (success_slice_count + failed_slice_count ==
(uint64_t)task.slices.size()) {
task.slice_count) {
if (failed_slice_count)
status[task_id].s = TransferStatusEnum::FAILED;
else
Expand All @@ -340,7 +341,7 @@ int RdmaTransport::getTransferStatus(BatchID batch_id, size_t task_id,
uint64_t success_slice_count = task.success_slice_count;
uint64_t failed_slice_count = task.failed_slice_count;
if (success_slice_count + failed_slice_count ==
(uint64_t)task.slices.size()) {
task.slice_count) {
if (failed_slice_count)
status.s = TransferStatusEnum::FAILED;
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ int TcpTransport::getTransferStatus(BatchID batch_id, size_t task_id,
uint64_t success_slice_count = task.success_slice_count;
uint64_t failed_slice_count = task.failed_slice_count;
if (success_slice_count + failed_slice_count ==
(uint64_t)task.slices.size()) {
task.slice_count) {
if (failed_slice_count) {
status.s = TransferStatusEnum::FAILED;
} else {
Expand Down Expand Up @@ -313,7 +313,7 @@ int TcpTransport::submitTransfer(BatchID batch_id,
slice->task = &task;
slice->target_id = request.target_id;
slice->status = Slice::PENDING;
task.slices.push_back(slice);
task.slice_count += 1;
startTransfer(slice);
}

Expand All @@ -335,7 +335,7 @@ int TcpTransport::submitTransferTask(
slice->task = &task;
slice->target_id = request.target_id;
slice->status = Slice::PENDING;
task.slices.push_back(slice);
task.slice_count += 1;
startTransfer(slice);
}
return 0;
Expand Down