Skip to content

Commit

Permalink
DAOS-15037 client: Pass vectorized write to dfs
Browse files Browse the repository at this point in the history
Rather than sending one entry at a time, we create a
d_iov_t for the whole write.  This shows about a 13x
performance increase for checkpointing in maxtext
AI application.

Required-githooks: true

Change-Id: Ib14b189ad37eb799d84d19794fc06077c3436989
Signed-off-by: Jeff Olivier <[email protected]>
  • Loading branch information
jolivier23 committed Jan 18, 2024
1 parent da658ad commit dbb3a25
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 44 deletions.
52 changes: 30 additions & 22 deletions src/client/dfuse/il/int_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@
#include "ioil.h"

static ssize_t
read_bulk(char *buff, size_t len, off_t position, struct fd_entry *entry, int *errcode)
read_bulksgl(d_sg_list_t *sgl, size_t len, off_t position, struct fd_entry *entry, int *errcode)
{
daos_size_t read_size = 0;
d_iov_t iov = {};
d_sg_list_t sgl = {};
daos_size_t read_size = 0;
daos_event_t ev;
daos_handle_t eqh;
int rc;

DFUSE_TRA_DEBUG(entry->fd_dfsoh, "%#zx-%#zx", position, position + len - 1);

sgl.sg_nr = 1;
d_iov_set(&iov, (void *)buff, len);
sgl.sg_iovs = &iov;

rc = ioil_get_eqh(&eqh);
if (rc == 0) {
bool flag = false;
Expand All @@ -39,8 +33,8 @@ read_bulk(char *buff, size_t len, off_t position, struct fd_entry *entry, int *e
D_GOTO(out, rc = daos_der2errno(rc));
}

rc = dfs_read(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, &sgl, position,
&read_size, &ev);
rc = dfs_read(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, sgl, position, &read_size,
&ev);
if (rc)
D_GOTO(out, rc);

Expand All @@ -57,7 +51,7 @@ read_bulk(char *buff, size_t len, off_t position, struct fd_entry *entry, int *e
}
rc = ev.ev_error;
} else {
rc = dfs_read(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, &sgl, position, &read_size,
rc = dfs_read(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, sgl, position, &read_size,
NULL);
}
out:
Expand All @@ -72,29 +66,43 @@ read_bulk(char *buff, size_t len, off_t position, struct fd_entry *entry, int *e
ssize_t
ioil_do_pread(char *buff, size_t len, off_t position, struct fd_entry *entry, int *errcode)
{
return read_bulk(buff, len, position, entry, errcode);
d_iov_t iov = {};
d_sg_list_t sgl = {};

sgl.sg_nr = 1;
d_iov_set(&iov, (void *)buff, len);
sgl.sg_iovs = &iov;

return read_bulksgl(&sgl, len, position, entry, errcode);
}

ssize_t
ioil_do_preadv(const struct iovec *iov, int count, off_t position, struct fd_entry *entry,
int *errcode)
{
ssize_t bytes_read;
d_iov_t *diov;
d_sg_list_t sgl = {};
ssize_t total_read = 0;
int i;
int rc;

D_ALLOC_ARRAY(diov, count);
if (diov == NULL) {
*errcode = ENOMEM;
return -1;
}

for (i = 0; i < count; i++) {
bytes_read = read_bulk(iov[i].iov_base, iov[i].iov_len, position, entry, errcode);
d_iov_set(&diov[i], iov[i].iov_base, iov[i].iov_len);
total_read += iov[i].iov_len;
}

if (bytes_read == -1)
return (ssize_t)-1;
sgl.sg_nr = count;
sgl.sg_iovs = diov;

if (bytes_read == 0)
return total_read;
rc = read_bulksgl(&sgl, total_read, position, entry, errcode);

position += bytes_read;
total_read += bytes_read;
}
D_FREE(diov);

return total_read;
return rc;
}
57 changes: 35 additions & 22 deletions src/client/dfuse/il/int_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@

#include "ioil.h"

ssize_t
ioil_do_writex(const char *buff, size_t len, off_t position, struct fd_entry *entry, int *errcode)
static ssize_t
ioil_do_writesgl(d_sg_list_t *sgl, size_t len, off_t position, struct fd_entry *entry, int *errcode)
{
d_iov_t iov = {};
d_sg_list_t sgl = {};
daos_event_t ev;
daos_handle_t eqh;
int rc;

DFUSE_TRA_DEBUG(entry->fd_dfsoh, "%#zx-%#zx", position, position + len - 1);

sgl.sg_nr = 1;
d_iov_set(&iov, (void *)buff, len);
sgl.sg_iovs = &iov;

rc = ioil_get_eqh(&eqh);
if (rc == 0) {
bool flag = false;
Expand All @@ -40,7 +34,7 @@ ioil_do_writex(const char *buff, size_t len, off_t position, struct fd_entry *en
D_GOTO(out, rc = daos_der2errno(rc));
}

rc = dfs_write(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, &sgl, position, &ev);
rc = dfs_write(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, sgl, position, &ev);
if (rc)
D_GOTO(out, rc);

Expand All @@ -57,7 +51,7 @@ ioil_do_writex(const char *buff, size_t len, off_t position, struct fd_entry *en
}
rc = ev.ev_error;
} else {
rc = dfs_write(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, &sgl, position, NULL);
rc = dfs_write(entry->fd_cont->ioc_dfs, entry->fd_dfsoh, sgl, position, NULL);
}
out:
if (rc) {
Expand All @@ -68,27 +62,46 @@ ioil_do_writex(const char *buff, size_t len, off_t position, struct fd_entry *en
return len;
}

ssize_t
ioil_do_writex(const char *buff, size_t len, off_t position, struct fd_entry *entry, int *errcode)
{
d_iov_t iov = {};
d_sg_list_t sgl = {};

sgl.sg_nr = 1;
d_iov_set(&iov, (void *)buff, len);
sgl.sg_iovs = &iov;

return ioil_do_writesgl(&sgl, len, position, entry, errcode);
}

ssize_t
ioil_do_pwritev(const struct iovec *iov, int count, off_t position, struct fd_entry *entry,
int *errcode)
{
ssize_t bytes_written;
ssize_t total_write = 0;
d_iov_t *diov;
d_sg_list_t sgl = {};
size_t total_write = 0;
int i;
int rc;

D_ALLOC_ARRAY(diov, count);
if (diov == NULL) {
*errcode = ENOMEM;
return -1;
}

for (i = 0; i < count; i++) {
bytes_written =
ioil_do_writex(iov[i].iov_base, iov[i].iov_len, position, entry, errcode);
d_iov_set(&diov[i], iov[i].iov_base, iov[i].iov_len);
total_write += iov[i].iov_len;
}

if (bytes_written == -1)
return (ssize_t)-1;
sgl.sg_nr = count;
sgl.sg_iovs = diov;

if (bytes_written == 0)
return total_write;
rc = ioil_do_writesgl(&sgl, total_write, position, entry, errcode);

position += bytes_written;
total_write += bytes_written;
}
D_FREE(diov);

return total_write;
return rc;
}

0 comments on commit dbb3a25

Please sign in to comment.