Commit 63b61817 authored by Tudor Bosman's avatar Tudor Bosman Committed by Sara Golemon

convert RecordIO to pwritev

Summary: zero-copy

Test Plan: record_io_test

Reviewed By: lucian@fb.com

FB internal diff: D806813
parent bfd3d062
...@@ -50,17 +50,14 @@ void RecordIOWriter::write(std::unique_ptr<IOBuf> buf) { ...@@ -50,17 +50,14 @@ void RecordIOWriter::write(std::unique_ptr<IOBuf> buf) {
return; // nothing to do return; // nothing to do
} }
// TODO(tudorb): Maybe use pwritev, but for now we're copying everything in DCHECK_EQ(buf->computeChainDataLength(), totalLength);
// one place. auto iov = buf->getIov();
buf->unshare();
buf->coalesce();
DCHECK_EQ(buf->length(), totalLength);
// We're going to write. Reserve space for ourselves. // We're going to write. Reserve space for ourselves.
off_t pos = filePos_.fetch_add(buf->length()); off_t pos = filePos_.fetch_add(totalLength);
ssize_t bytes = pwriteFull(file_.fd(), buf->data(), buf->length(), pos); ssize_t bytes = pwritevFull(file_.fd(), iov.data(), iov.size(), pos);
checkUnixError(bytes, "pwrite() failed"); checkUnixError(bytes, "pwrite() failed");
DCHECK_EQ(bytes, buf->length()); DCHECK_EQ(bytes, totalLength);
} }
RecordIOReader::RecordIOReader(File file, uint32_t fileId) RecordIOReader::RecordIOReader(File file, uint32_t fileId)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment