mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-29 23:19:20 +08:00
mdbx: добавление MDBX_opt_prefault_write_enable
вместо MDBX_ENABLE_PREFAULT
.
This commit is contained in:
parent
b959e217b1
commit
957c99d86f
5
mdbx.h
5
mdbx.h
@ -2254,6 +2254,11 @@ enum MDBX_option_t {
|
|||||||
* On Windows a write-through is used always but \ref MDBX_NOMETASYNC could
|
* On Windows a write-through is used always but \ref MDBX_NOMETASYNC could
|
||||||
* be used for switching to write-and-flush. */
|
* be used for switching to write-and-flush. */
|
||||||
MDBX_opt_writethrough_threshold,
|
MDBX_opt_writethrough_threshold,
|
||||||
|
|
||||||
|
/** \brief Controls prevention of page-faults of reclaimed and allocated pages
|
||||||
|
* in the \ref MDBX_WRITEMAP mode by clearing ones through file handle before
|
||||||
|
* touching. */
|
||||||
|
MDBX_opt_prefault_write_enable,
|
||||||
};
|
};
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
/** \ingroup c_settings */
|
/** \ingroup c_settings */
|
||||||
|
19
src/core.c
19
src/core.c
@ -7043,7 +7043,6 @@ static __inline pgr_t page_alloc_finalize(MDBX_env *const env,
|
|||||||
MDBX_ASAN_UNPOISON_MEMORY_REGION(ret.page, pgno2bytes(env, num));
|
MDBX_ASAN_UNPOISON_MEMORY_REGION(ret.page, pgno2bytes(env, num));
|
||||||
VALGRIND_MAKE_MEM_UNDEFINED(ret.page, pgno2bytes(env, num));
|
VALGRIND_MAKE_MEM_UNDEFINED(ret.page, pgno2bytes(env, num));
|
||||||
|
|
||||||
#if MDBX_ENABLE_PREFAULT
|
|
||||||
/* Содержимое выделенной страницы не нужно, но если страница отсутствует
|
/* Содержимое выделенной страницы не нужно, но если страница отсутствует
|
||||||
* в ОЗУ (что весьма вероятно), то любое обращение к ней приведет
|
* в ОЗУ (что весьма вероятно), то любое обращение к ней приведет
|
||||||
* к page-fault:
|
* к page-fault:
|
||||||
@ -7107,7 +7106,6 @@ static __inline pgr_t page_alloc_finalize(MDBX_env *const env,
|
|||||||
need_clean = false;
|
need_clean = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* MDBX_ENABLE_PREFAULT */
|
|
||||||
} else {
|
} else {
|
||||||
ret.page = page_malloc(txn, num);
|
ret.page = page_malloc(txn, num);
|
||||||
if (unlikely(!ret.page)) {
|
if (unlikely(!ret.page)) {
|
||||||
@ -24553,6 +24551,18 @@ __cold int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option,
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MDBX_opt_prefault_write_enable:
|
||||||
|
if (value == /* default */ UINT64_MAX) {
|
||||||
|
env->me_options.prefault_write = default_prefault_write(env);
|
||||||
|
env->me_options.flags.non_auto.prefault_write = false;
|
||||||
|
} else if (value > 1)
|
||||||
|
err = MDBX_EINVAL;
|
||||||
|
else {
|
||||||
|
env->me_options.prefault_write = value != 0;
|
||||||
|
env->me_options.flags.non_auto.prefault_write = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
}
|
}
|
||||||
@ -24634,6 +24644,10 @@ __cold int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option,
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MDBX_opt_prefault_write_enable:
|
||||||
|
*pvalue = env->me_options.prefault_write;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
}
|
}
|
||||||
@ -25120,7 +25134,6 @@ __dll_export
|
|||||||
" MDBX_AVOID_MSYNC=" MDBX_STRINGIFY(MDBX_AVOID_MSYNC)
|
" MDBX_AVOID_MSYNC=" MDBX_STRINGIFY(MDBX_AVOID_MSYNC)
|
||||||
" MDBX_ENABLE_REFUND=" MDBX_STRINGIFY(MDBX_ENABLE_REFUND)
|
" MDBX_ENABLE_REFUND=" MDBX_STRINGIFY(MDBX_ENABLE_REFUND)
|
||||||
" MDBX_ENABLE_MADVISE=" MDBX_STRINGIFY(MDBX_ENABLE_MADVISE)
|
" MDBX_ENABLE_MADVISE=" MDBX_STRINGIFY(MDBX_ENABLE_MADVISE)
|
||||||
" MDBX_ENABLE_PREFAULT=" MDBX_STRINGIFY(MDBX_ENABLE_PREFAULT)
|
|
||||||
" MDBX_ENABLE_MINCORE=" MDBX_STRINGIFY(MDBX_ENABLE_MINCORE)
|
" MDBX_ENABLE_MINCORE=" MDBX_STRINGIFY(MDBX_ENABLE_MINCORE)
|
||||||
" MDBX_ENABLE_PGOP_STAT=" MDBX_STRINGIFY(MDBX_ENABLE_PGOP_STAT)
|
" MDBX_ENABLE_PGOP_STAT=" MDBX_STRINGIFY(MDBX_ENABLE_PGOP_STAT)
|
||||||
" MDBX_ENABLE_PROFGC=" MDBX_STRINGIFY(MDBX_ENABLE_PROFGC)
|
" MDBX_ENABLE_PROFGC=" MDBX_STRINGIFY(MDBX_ENABLE_PROFGC)
|
||||||
|
@ -87,18 +87,6 @@
|
|||||||
#error MDBX_ENABLE_PGOP_STAT must be defined as 0 or 1
|
#error MDBX_ENABLE_PGOP_STAT must be defined as 0 or 1
|
||||||
#endif /* MDBX_ENABLE_PGOP_STAT */
|
#endif /* MDBX_ENABLE_PGOP_STAT */
|
||||||
|
|
||||||
/** Controls prevention of page-faults of reclaimed and allocated pages in the
|
|
||||||
* MDBX_WRITEMAP mode by clearing ones through file handle before touching. */
|
|
||||||
#ifndef MDBX_ENABLE_PREFAULT
|
|
||||||
#if MDBX_MMAP_INCOHERENT_FILE_WRITE
|
|
||||||
#define MDBX_ENABLE_PREFAULT 0
|
|
||||||
#else
|
|
||||||
#define MDBX_ENABLE_PREFAULT 1
|
|
||||||
#endif
|
|
||||||
#elif !(MDBX_ENABLE_PREFAULT == 0 || MDBX_ENABLE_PREFAULT == 1)
|
|
||||||
#error MDBX_ENABLE_PREFAULT must be defined as 0 or 1
|
|
||||||
#endif /* MDBX_ENABLE_PREFAULT */
|
|
||||||
|
|
||||||
/** Controls using Unix' mincore() to determine whether DB-pages
|
/** Controls using Unix' mincore() to determine whether DB-pages
|
||||||
* are resident in memory. */
|
* are resident in memory. */
|
||||||
#ifndef MDBX_ENABLE_MINCORE
|
#ifndef MDBX_ENABLE_MINCORE
|
||||||
|
Loading…
Reference in New Issue
Block a user