mdbx: add MDBX_opt_rp_augment_limit.

More for https://github.com/erthink/libmdbx/issues/128

Change-Id: I94f3350b72ad11d0b586aaef1574f7654223bc40
This commit is contained in:
Leonid Yuriev 2020-11-21 17:53:17 +03:00
parent 461ba000e3
commit 4cd08f0ef9
3 changed files with 17 additions and 2 deletions

4
mdbx.h
View File

@ -1802,6 +1802,10 @@ enum MDBX_option_t {
/** \brief The limit to grow a list of pre-allocated dirty pages. */
MDBX_opt_dp_reserve_limit,
/** \brief The limit to grow a list of reclaimed pages
* for finding a sequence of contiguous pages. */
MDBX_opt_rp_augment_limit,
};
#ifndef __cplusplus
/** \ingroup c_settings */

View File

@ -5278,9 +5278,8 @@ skip_cache:
}
const unsigned gc_len = MDBX_PNL_SIZE(gc_pnl);
/* TODO: provide a user-configurable threshold */
const unsigned threshold_2_stop_gc_reclaiming = MDBX_PNL_MAX / 4;
if (unlikely(gc_len + MDBX_PNL_SIZE(txn->tw.reclaimed_pglist) >
threshold_2_stop_gc_reclaiming) &&
env->me_options.rp_augment_limit) &&
(pgno_add(txn->mt_next_pgno, num) <= txn->mt_geo.upper ||
gc_len + MDBX_PNL_SIZE(txn->tw.reclaimed_pglist) >=
MDBX_PNL_MAX / 16 * 15)) {
@ -9234,6 +9233,7 @@ __cold int mdbx_env_create(MDBX_env **penv) {
env->me_stuck_meta = -1;
env->me_options.dp_reserve_limit = 1024;
env->me_options.rp_augment_limit = 1024 * 1024;
int rc;
const size_t os_psize = mdbx_syspagesize();
@ -19710,6 +19710,12 @@ __cold int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option,
}
break;
case MDBX_opt_rp_augment_limit:
if (unlikely(value > MDBX_PNL_MAX))
return MDBX_EINVAL;
env->me_options.rp_augment_limit = (unsigned)value;
break;
default:
return MDBX_EINVAL;
}
@ -19752,6 +19758,10 @@ __cold int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option,
*value = env->me_options.dp_reserve_limit;
break;
case MDBX_opt_rp_augment_limit:
*value = env->me_options.rp_augment_limit;
break;
default:
return MDBX_EINVAL;
}

View File

@ -995,6 +995,7 @@ struct MDBX_env {
unsigned me_dp_reserve_len;
struct {
unsigned dp_reserve_limit;
unsigned rp_augment_limit;
} me_options;
struct {
#if MDBX_LOCKING > 0