mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-31 10:58:20 +08:00
mdbx: avoids using pwritev() for single-writes (up to 10% speedup for some kernels & scenarios).
Change-Id: I71fbf0e113b1de4d05b2a43e8532a977c42b8f91
This commit is contained in:
parent
c9f461c4eb
commit
0146b3e2c0
10
src/core.c
10
src/core.c
@ -7567,6 +7567,14 @@ static int mdbx_flush_iov(MDBX_txn *const txn, struct iovec *iov,
|
|||||||
unsigned iov_items, size_t iov_off,
|
unsigned iov_items, size_t iov_off,
|
||||||
size_t iov_bytes) {
|
size_t iov_bytes) {
|
||||||
MDBX_env *const env = txn->mt_env;
|
MDBX_env *const env = txn->mt_env;
|
||||||
|
mdbx_assert(env, iov_items > 0);
|
||||||
|
if (likely(iov_items == 1)) {
|
||||||
|
mdbx_assert(env, iov->iov_len == iov_bytes);
|
||||||
|
int rc = mdbx_pwrite(env->me_lazy_fd, iov->iov_base, iov_bytes, iov_off);
|
||||||
|
mdbx_dpage_free(env, (MDBX_page *)iov->iov_base,
|
||||||
|
bytes2pgno(env, iov_bytes));
|
||||||
|
return rc;
|
||||||
|
} else {
|
||||||
int rc = mdbx_pwritev(env->me_lazy_fd, iov, iov_items, iov_off, iov_bytes);
|
int rc = mdbx_pwritev(env->me_lazy_fd, iov, iov_items, iov_off, iov_bytes);
|
||||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||||
mdbx_error("Write error: %s", mdbx_strerror(rc));
|
mdbx_error("Write error: %s", mdbx_strerror(rc));
|
||||||
@ -7576,9 +7584,9 @@ static int mdbx_flush_iov(MDBX_txn *const txn, struct iovec *iov,
|
|||||||
for (unsigned i = 0; i < iov_items; i++)
|
for (unsigned i = 0; i < iov_items; i++)
|
||||||
mdbx_dpage_free(env, (MDBX_page *)iov[i].iov_base,
|
mdbx_dpage_free(env, (MDBX_page *)iov[i].iov_base,
|
||||||
bytes2pgno(env, iov[i].iov_len));
|
bytes2pgno(env, iov[i].iov_len));
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Flush (some) dirty pages to the map, after clearing their dirty flag.
|
/* Flush (some) dirty pages to the map, after clearing their dirty flag.
|
||||||
* [in] txn the transaction that's being committed
|
* [in] txn the transaction that's being committed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user