mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx: add MDBX_opt_txn_dp_initial
& MDBX_opt_txn_dp_limit
.
More for https://github.com/erthink/libmdbx/issues/128 Change-Id: I4be3c7476e9ce16ed4f27691d0df653552930e3c
This commit is contained in:
parent
84235c7903
commit
76716c23b0
6
mdbx.h
6
mdbx.h
@ -1806,6 +1806,12 @@ enum MDBX_option_t {
|
|||||||
/** \brief The limit to grow a list of reclaimed pages
|
/** \brief The limit to grow a list of reclaimed pages
|
||||||
* for finding a sequence of contiguous pages. */
|
* for finding a sequence of contiguous pages. */
|
||||||
MDBX_opt_rp_augment_limit,
|
MDBX_opt_rp_augment_limit,
|
||||||
|
|
||||||
|
/** \brief The limit of dirty pages for a write transaction. */
|
||||||
|
MDBX_opt_txn_dp_limit,
|
||||||
|
/** \brief The initial allocation size for dirty pages list
|
||||||
|
* of a write transaction. */
|
||||||
|
MDBX_opt_txn_dp_initial,
|
||||||
};
|
};
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
/** \ingroup c_settings */
|
/** \ingroup c_settings */
|
||||||
|
48
src/core.c
48
src/core.c
@ -19787,6 +19787,47 @@ __cold int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option,
|
|||||||
env->me_options.rp_augment_limit = (unsigned)value;
|
env->me_options.rp_augment_limit = (unsigned)value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MDBX_opt_txn_dp_limit:
|
||||||
|
case MDBX_opt_txn_dp_initial:
|
||||||
|
if (unlikely(value > MDBX_PGL_LIMIT))
|
||||||
|
return MDBX_EINVAL;
|
||||||
|
if (unlikely(env->me_txn0 == NULL))
|
||||||
|
return MDBX_EACCESS;
|
||||||
|
if (lock_needed) {
|
||||||
|
err = mdbx_txn_lock(env, false);
|
||||||
|
if (unlikely(err != MDBX_SUCCESS))
|
||||||
|
return err;
|
||||||
|
should_unlock = true;
|
||||||
|
}
|
||||||
|
if (env->me_txn)
|
||||||
|
err = MDBX_EPERM /* unable change during transaction */;
|
||||||
|
else {
|
||||||
|
mdbx_dpl_clear(env->me_txn0->tw.dirtylist);
|
||||||
|
const unsigned value32 = (unsigned)value;
|
||||||
|
if (option == MDBX_opt_txn_dp_initial &&
|
||||||
|
env->me_options.dp_initial != value32) {
|
||||||
|
if (env->me_options.dp_limit < value32)
|
||||||
|
env->me_options.dp_limit = value32;
|
||||||
|
if (env->me_txn0->tw.dirtylist->allocated < value32 &&
|
||||||
|
!mdbx_dpl_reserve(env->me_txn0, value32))
|
||||||
|
err = MDBX_ENOMEM;
|
||||||
|
else
|
||||||
|
env->me_options.dp_initial = value32;
|
||||||
|
}
|
||||||
|
if (option == MDBX_opt_txn_dp_limit &&
|
||||||
|
env->me_options.dp_limit != value32) {
|
||||||
|
if (env->me_txn0->tw.dirtylist->allocated > value32 &&
|
||||||
|
!mdbx_dpl_reserve(env->me_txn0, value32))
|
||||||
|
err = MDBX_ENOMEM;
|
||||||
|
else {
|
||||||
|
if (env->me_options.dp_initial > value32)
|
||||||
|
env->me_options.dp_initial = value32;
|
||||||
|
env->me_options.dp_limit = value32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
}
|
}
|
||||||
@ -19833,6 +19874,13 @@ __cold int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option,
|
|||||||
*value = env->me_options.rp_augment_limit;
|
*value = env->me_options.rp_augment_limit;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MDBX_opt_txn_dp_limit:
|
||||||
|
*value = env->me_options.dp_limit;
|
||||||
|
break;
|
||||||
|
case MDBX_opt_txn_dp_initial:
|
||||||
|
*value = env->me_options.dp_initial;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user