mirror of
https://gitflic.ru/project/erthink/libmdbx.git
synced 2025-01-03 14:56:52 +00:00
mdbx: переименование и доработка опций сборки.
This commit is contained in:
parent
35177611d2
commit
44865dadc7
@ -690,7 +690,7 @@ add_mdbx_option(MDBX_INSTALL_STATIC
|
||||
add_mdbx_option(MDBX_BUILD_SHARED_LIBRARY
|
||||
"Build libmdbx as shared library (DLL)" ${BUILD_SHARED_LIBS})
|
||||
add_mdbx_option(
|
||||
MDBX_BUILD_TOOLS "Build MDBX tools (mdbx_chk/stat/dump/load/copy)"
|
||||
MDBX_BUILD_TOOLS "Build MDBX tools (mdbx_chk/stat/dump/load/copy/drop)"
|
||||
${MDBX_BUILD_TOOLS_DEFAULT})
|
||||
cmake_dependent_option(
|
||||
MDBX_INSTALL_MANPAGES
|
||||
@ -699,8 +699,10 @@ cmake_dependent_option(
|
||||
add_mdbx_option(
|
||||
MDBX_TXN_CHECKOWNER
|
||||
"Checking transaction matches the calling thread inside libmdbx's API" ON)
|
||||
add_mdbx_option(MDBX_ENV_CHECKPID "Paranoid checking PID inside libmdbx's API"
|
||||
AUTO)
|
||||
add_mdbx_option(
|
||||
MDBX_ENV_CHECKPID
|
||||
"Checking PID inside libmdbx's API against reuse DB environment after the fork()"
|
||||
AUTO)
|
||||
mark_as_advanced(MDBX_ENV_CHECKPID)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
add_mdbx_option(MDBX_DISABLE_GNU_SOURCE "Don't use GNU/Linux libc extensions"
|
||||
@ -708,9 +710,9 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
mark_as_advanced(MDBX_DISABLE_GNU_SOURCE)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR IOS)
|
||||
add_mdbx_option(MDBX_OSX_SPEED_INSTEADOF_DURABILITY
|
||||
add_mdbx_option(MDBX_APPLE_SPEED_INSTEADOF_DURABILITY
|
||||
"Disable use fcntl(F_FULLFSYNC) in favor of speed" OFF)
|
||||
mark_as_advanced(MDBX_OSX_SPEED_INSTEADOF_DURABILITY)
|
||||
mark_as_advanced(MDBX_APPLE_SPEED_INSTEADOF_DURABILITY)
|
||||
endif()
|
||||
if(WIN32)
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB)
|
||||
@ -724,15 +726,25 @@ else()
|
||||
MDBX_USE_OFDLOCKS
|
||||
"Use Open file description locks (aka OFD locks, non-POSIX)" AUTO)
|
||||
mark_as_advanced(MDBX_USE_OFDLOCKS)
|
||||
add_mdbx_option(
|
||||
MDBX_USE_MINCORE
|
||||
"Use Unix' mincore() to determine whether DB-pages are resident in memory"
|
||||
ON)
|
||||
mark_as_advanced(MDBX_USE_MINCORE)
|
||||
set(MDBX_AVOID_MSYNC_DEFAULT OFF)
|
||||
endif()
|
||||
add_mdbx_option(
|
||||
MDBX_AVOID_MSYNC
|
||||
"Controls dirty pages tracking, spilling and persisting in MDBX_WRITEMAP mode"
|
||||
"Disable in-memory database updating with consequent flush-to-disk/msync syscall in `MDBX_WRITEMAP` mode"
|
||||
${MDBX_AVOID_MSYNC_DEFAULT})
|
||||
add_mdbx_option(
|
||||
MDBX_MMAP_NEEDS_JOLT
|
||||
"Assume system needs explicit syscall to sync/flush/write modified mapped memory"
|
||||
AUTO)
|
||||
mark_as_advanced(MDBX_MMAP_NEEDS_JOLT)
|
||||
add_mdbx_option(
|
||||
MDBX_LOCKING
|
||||
"Locking method (Windows=-1, SysV=5, POSIX=1988, POSIX=2001, POSIX=2008, Futexes=1995)"
|
||||
"Locking method (Windows=-1, SystemV=5, POSIX=1988, POSIX=2001, POSIX=2008)"
|
||||
AUTO)
|
||||
mark_as_advanced(MDBX_LOCKING)
|
||||
add_mdbx_option(
|
||||
@ -747,23 +759,22 @@ add_mdbx_option(
|
||||
mark_as_advanced(MDBX_DISABLE_VALIDATION)
|
||||
add_mdbx_option(MDBX_ENABLE_REFUND
|
||||
"Zerocost auto-compactification during write-transactions" ON)
|
||||
add_mdbx_option(MDBX_ENABLE_MADVISE
|
||||
"Using POSIX' madvise() and/or similar hints" ON)
|
||||
if(CMAKE_TARGET_BITNESS GREATER 32)
|
||||
set(MDBX_BIGFOOT_DEFAULT ON)
|
||||
else()
|
||||
set(MDBX_BIGFOOT_DEFAULT OFF)
|
||||
endif()
|
||||
add_mdbx_option(
|
||||
MDBX_ENABLE_BIGFOOT
|
||||
"Chunking long list of retired pages during huge transactions commit to avoid use sequences of pages"
|
||||
${MDBX_BIGFOOT_DEFAULT})
|
||||
ON)
|
||||
add_mdbx_option(MDBX_ENABLE_PGOP_STAT
|
||||
"Gathering statistics for page operations" ON)
|
||||
add_mdbx_option(MDBX_ENABLE_PROFGC "Profiling of GC search and updates" OFF)
|
||||
mark_as_advanced(MDBX_ENABLE_PROFGC)
|
||||
add_mdbx_option(MDBX_ENABLE_DBI_SPARSE "FIXME" ON)
|
||||
add_mdbx_option(MDBX_ENABLE_DBI_LOCKFREE "FIXME" ON)
|
||||
add_mdbx_option(
|
||||
MDBX_ENABLE_DBI_SPARSE
|
||||
"Support for sparse sets of DBI handles to reduce overhead when starting and processing transactions"
|
||||
ON)
|
||||
add_mdbx_option(
|
||||
MDBX_ENABLE_DBI_LOCKFREE
|
||||
"Support for deferred releasing and a lockfree path to quickly open DBI handles"
|
||||
ON)
|
||||
|
||||
if(NOT MDBX_AMALGAMATED_SOURCE)
|
||||
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG")
|
||||
|
42
src/cold.c
42
src/cold.c
@ -382,49 +382,7 @@ __cold int mdbx_env_warmup(const MDBX_env *env, const MDBX_txn *txn,
|
||||
#endif /* MLOCK_ONFAULT */
|
||||
|
||||
int err = MDBX_ENOSYS;
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
err = dxb_set_readahead(env, used_pgno, true, true);
|
||||
#else
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (imports.PrefetchVirtualMemory) {
|
||||
WIN32_MEMORY_RANGE_ENTRY hint;
|
||||
hint.VirtualAddress = env->dxb_mmap.base;
|
||||
hint.NumberOfBytes = used_range;
|
||||
if (imports.PrefetchVirtualMemory(GetCurrentProcess(), 1, &hint, 0))
|
||||
err = MDBX_SUCCESS;
|
||||
else {
|
||||
err = (int)GetLastError();
|
||||
ERROR("%s(%zu) error %d", "PrefetchVirtualMemory", used_range, err);
|
||||
}
|
||||
}
|
||||
#endif /* Windows */
|
||||
|
||||
#if defined(POSIX_MADV_WILLNEED)
|
||||
err = posix_madvise(env->dxb_mmap.base, used_range, POSIX_MADV_WILLNEED)
|
||||
? ignore_enosys(errno)
|
||||
: MDBX_SUCCESS;
|
||||
#elif defined(MADV_WILLNEED)
|
||||
err = madvise(env->dxb_mmap.base, used_range, MADV_WILLNEED)
|
||||
? ignore_enosys(errno)
|
||||
: MDBX_SUCCESS;
|
||||
#endif
|
||||
|
||||
#if defined(F_RDADVISE)
|
||||
if (err) {
|
||||
fcntl(env->lazy_fd, F_RDAHEAD, true);
|
||||
struct radvisory hint;
|
||||
hint.ra_offset = 0;
|
||||
hint.ra_count = unlikely(used_range > INT_MAX &&
|
||||
sizeof(used_range) > sizeof(hint.ra_count))
|
||||
? INT_MAX
|
||||
: (int)used_range;
|
||||
err = fcntl(env->lazy_fd, F_RDADVISE, &hint) ? ignore_enosys(errno)
|
||||
: MDBX_SUCCESS;
|
||||
if (err == ENOTTY)
|
||||
err = MDBX_SUCCESS /* Ignore ENOTTY for DB on the ram-disk */;
|
||||
}
|
||||
#endif /* F_RDADVISE */
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
if (err != MDBX_SUCCESS && rc == MDBX_SUCCESS)
|
||||
rc = err;
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#cmakedefine01 MDBX_DISABLE_VALIDATION
|
||||
#cmakedefine01 MDBX_AVOID_MSYNC
|
||||
#cmakedefine01 MDBX_ENABLE_REFUND
|
||||
#cmakedefine01 MDBX_ENABLE_MADVISE
|
||||
#cmakedefine01 MDBX_ENABLE_BIGFOOT
|
||||
#cmakedefine01 MDBX_ENABLE_PGOP_STAT
|
||||
#cmakedefine01 MDBX_ENABLE_PROFGC
|
||||
@ -40,19 +39,29 @@
|
||||
#cmakedefine01 MDBX_ENABLE_DBI_LOCKFREE
|
||||
|
||||
/* Windows */
|
||||
#if !defined(MDBX_BUILD_TEST) && !defined(MDBX_WITHOUT_MSVC_CRT)
|
||||
#if defined(MDBX_BUILD_TEST) || !defined(MDBX_BUILD_CXX) || MDBX_BUILD_CXX
|
||||
#define MDBX_WITHOUT_MSVC_CRT 0
|
||||
#else
|
||||
#cmakedefine01 MDBX_WITHOUT_MSVC_CRT
|
||||
#endif
|
||||
#endif /* MDBX_WITHOUT_MSVC_CRT */
|
||||
|
||||
/* MacOS & iOS */
|
||||
#cmakedefine01 MDBX_OSX_SPEED_INSTEADOF_DURABILITY
|
||||
#cmakedefine01 MDBX_APPLE_SPEED_INSTEADOF_DURABILITY
|
||||
|
||||
/* POSIX */
|
||||
#cmakedefine01 MDBX_DISABLE_GNU_SOURCE
|
||||
|
||||
#cmakedefine MDBX_USE_OFDLOCKS_AUTO
|
||||
#ifndef MDBX_USE_OFDLOCKS_AUTO
|
||||
#cmakedefine01 MDBX_USE_OFDLOCKS
|
||||
#endif
|
||||
#endif /* MDBX_USE_OFDLOCKS */
|
||||
|
||||
#cmakedefine MDBX_MMAP_NEEDS_JOLT_AUTO
|
||||
#ifndef MDBX_MMAP_NEEDS_JOLT_AUTO
|
||||
#cmakedefine01 MDBX_MMAP_NEEDS_JOLT
|
||||
#endif /* MDBX_MMAP_NEEDS_JOLT */
|
||||
|
||||
#cmakedefine01 MDBX_USE_MINCORE
|
||||
|
||||
/* Build Info */
|
||||
#ifndef MDBX_BUILD_TIMESTAMP
|
||||
|
19
src/dxb.c
19
src/dxb.c
@ -153,9 +153,7 @@ __cold int dxb_resize(MDBX_env *const env, const pgno_t used_pgno,
|
||||
}
|
||||
const size_t limit_bytes = pgno_align2os_bytes(env, limit_pgno);
|
||||
const size_t size_bytes = pgno_align2os_bytes(env, size_pgno);
|
||||
#if MDBX_ENABLE_MADVISE || defined(ENABLE_MEMCHECK)
|
||||
const void *const prev_map = env->dxb_mmap.base;
|
||||
#endif /* MDBX_ENABLE_MADVISE || ENABLE_MEMCHECK */
|
||||
|
||||
VERBOSE("resize(env-flags 0x%x, mode %d) datafile/mapping: "
|
||||
"present %" PRIuPTR " -> %" PRIuPTR ", "
|
||||
@ -252,7 +250,6 @@ __cold int dxb_resize(MDBX_env *const env, const pgno_t used_pgno,
|
||||
}
|
||||
munlock_after(env, aligned_munlock_pgno, size_bytes);
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
if (size_bytes < prev_size && mode > implicit_grow) {
|
||||
NOTICE("resize-MADV_%s %u..%u",
|
||||
(env->flags & MDBX_WRITEMAP) ? "REMOVE" : "DONTNEED", size_pgno,
|
||||
@ -304,12 +301,10 @@ __cold int dxb_resize(MDBX_env *const env, const pgno_t used_pgno,
|
||||
} else
|
||||
env->lck->discarded_tail.weak = size_pgno;
|
||||
}
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
rc = osal_mresize(mresize_flags, &env->dxb_mmap, size_bytes, limit_bytes);
|
||||
eASSERT(env, env->dxb_mmap.limit >= env->dxb_mmap.current);
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
if (rc == MDBX_SUCCESS) {
|
||||
eASSERT(env, limit_bytes == env->dxb_mmap.limit);
|
||||
eASSERT(env, size_bytes <= env->dxb_mmap.filesize);
|
||||
@ -329,7 +324,6 @@ __cold int dxb_resize(MDBX_env *const env, const pgno_t used_pgno,
|
||||
;
|
||||
rc = dxb_set_readahead(env, size_pgno, readahead, force);
|
||||
}
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
bailout:
|
||||
if (rc == MDBX_SUCCESS) {
|
||||
@ -448,7 +442,6 @@ void dxb_sanitize_tail(MDBX_env *env, MDBX_txn *txn) {
|
||||
}
|
||||
#endif /* ENABLE_MEMCHECK || __SANITIZE_ADDRESS__ */
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
/* Turn on/off readahead. It's harmful when the DB is larger than RAM. */
|
||||
__cold int dxb_set_readahead(const MDBX_env *env, const pgno_t edge,
|
||||
const bool enable, const bool force_whole) {
|
||||
@ -570,7 +563,6 @@ __cold int dxb_set_readahead(const MDBX_env *env, const pgno_t edge,
|
||||
err = MDBX_SUCCESS;
|
||||
return err;
|
||||
}
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
__cold int dxb_setup(MDBX_env *env, const int lck_rc,
|
||||
const mdbx_mode_t mode_bits) {
|
||||
@ -776,12 +768,10 @@ __cold int dxb_setup(MDBX_env *env, const int lck_rc,
|
||||
globals.bootid.x, globals.bootid.y,
|
||||
(globals.bootid.x | globals.bootid.y) ? "" : "not-");
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
/* calculate readahead hint before mmap with zero redundant pages */
|
||||
const bool readahead =
|
||||
!(env->flags & MDBX_NORDAHEAD) &&
|
||||
mdbx_is_readahead_reasonable(used_bytes, 0) == MDBX_RESULT_TRUE;
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
err = osal_mmap(env->flags, &env->dxb_mmap, env->geo_in_bytes.now,
|
||||
env->geo_in_bytes.upper,
|
||||
@ -789,7 +779,6 @@ __cold int dxb_setup(MDBX_env *env, const int lck_rc,
|
||||
if (unlikely(err != MDBX_SUCCESS))
|
||||
return err;
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
#if defined(MADV_DONTDUMP)
|
||||
err = madvise(env->dxb_mmap.base, env->dxb_mmap.limit, MADV_DONTDUMP)
|
||||
? ignore_enosys(errno)
|
||||
@ -807,7 +796,6 @@ __cold int dxb_setup(MDBX_env *env, const int lck_rc,
|
||||
return err;
|
||||
}
|
||||
#endif /* MADV_DODUMP */
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
#ifdef ENABLE_MEMCHECK
|
||||
env->valgrind_handle =
|
||||
@ -1082,7 +1070,6 @@ __cold int dxb_setup(MDBX_env *env, const int lck_rc,
|
||||
} /* lck exclusive, lck_rc == MDBX_RESULT_TRUE */
|
||||
|
||||
//---------------------------------------------------- setup madvise/readahead
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
if (used_aligned2os_bytes < env->dxb_mmap.current) {
|
||||
#if defined(MADV_REMOVE)
|
||||
if (lck_rc && (env->flags & MDBX_WRITEMAP) != 0 &&
|
||||
@ -1125,7 +1112,6 @@ __cold int dxb_setup(MDBX_env *env, const int lck_rc,
|
||||
err = dxb_set_readahead(env, bytes2pgno(env, used_bytes), readahead, true);
|
||||
if (unlikely(err != MDBX_SUCCESS))
|
||||
return err;
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1192,8 +1178,7 @@ int dxb_sync_locked(MDBX_env *env, unsigned flags, meta_t *const pending,
|
||||
}
|
||||
#endif /* ENABLE_MEMCHECK || __SANITIZE_ADDRESS__ */
|
||||
|
||||
#if MDBX_ENABLE_MADVISE && \
|
||||
(defined(MADV_DONTNEED) || defined(POSIX_MADV_DONTNEED))
|
||||
#if defined(MADV_DONTNEED) || defined(POSIX_MADV_DONTNEED)
|
||||
const size_t discard_edge_pgno = pgno_align2os_pgno(env, largest_pgno);
|
||||
if (prev_discarded_pgno >= discard_edge_pgno + env->madv_threshold) {
|
||||
const size_t prev_discarded_bytes =
|
||||
@ -1249,7 +1234,7 @@ int dxb_sync_locked(MDBX_env *env, unsigned flags, meta_t *const pending,
|
||||
env->lck->discarded_tail.weak = discard_edge_pgno;
|
||||
}
|
||||
}
|
||||
#endif /* MDBX_ENABLE_MADVISE && (MADV_DONTNEED || POSIX_MADV_DONTNEED) */
|
||||
#endif /* MADV_DONTNEED || POSIX_MADV_DONTNEED */
|
||||
|
||||
/* LY: check conditions to shrink datafile */
|
||||
const pgno_t backlog_gap = 3 + pending->trees.gc.height * 3;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "internals.h"
|
||||
|
||||
#if MDBX_ENABLE_MINCORE
|
||||
#if MDBX_USE_MINCORE
|
||||
/*------------------------------------------------------------------------------
|
||||
* Проверка размещения/расположения отображенных страниц БД в ОЗУ (mem-in-core),
|
||||
* с кешированием этой информации. */
|
||||
@ -77,11 +77,11 @@ static bool mincore_fetch(MDBX_env *const env, const size_t unit_begin) {
|
||||
lck->mincore_cache.mask[0] = ~mask;
|
||||
return bit_tas(lck->mincore_cache.mask, 0);
|
||||
}
|
||||
#endif /* MDBX_ENABLE_MINCORE */
|
||||
#endif /* MDBX_USE_MINCORE */
|
||||
|
||||
MDBX_MAYBE_UNUSED static inline bool mincore_probe(MDBX_env *const env,
|
||||
const pgno_t pgno) {
|
||||
#if MDBX_ENABLE_MINCORE
|
||||
#if MDBX_USE_MINCORE
|
||||
const size_t offset_aligned =
|
||||
floor_powerof2(pgno2bytes(env, pgno), globals.sys_pagesize);
|
||||
const unsigned unit_log2 = (env->ps2ln > globals.sys_pagesize_ln2)
|
||||
@ -97,7 +97,7 @@ MDBX_MAYBE_UNUSED static inline bool mincore_probe(MDBX_env *const env,
|
||||
(void)env;
|
||||
(void)pgno;
|
||||
return false;
|
||||
#endif /* MDBX_ENABLE_MINCORE */
|
||||
#endif /* MDBX_USE_MINCORE */
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
@ -351,8 +351,7 @@ __dll_export
|
||||
" MDBX_TRUST_RTC=" MDBX_TRUST_RTC_CONFIG
|
||||
" MDBX_AVOID_MSYNC=" MDBX_STRINGIFY(MDBX_AVOID_MSYNC)
|
||||
" MDBX_ENABLE_REFUND=" MDBX_STRINGIFY(MDBX_ENABLE_REFUND)
|
||||
" MDBX_ENABLE_MADVISE=" MDBX_STRINGIFY(MDBX_ENABLE_MADVISE)
|
||||
" MDBX_ENABLE_MINCORE=" MDBX_STRINGIFY(MDBX_ENABLE_MINCORE)
|
||||
" MDBX_USE_MINCORE=" MDBX_STRINGIFY(MDBX_USE_MINCORE)
|
||||
" MDBX_ENABLE_PGOP_STAT=" MDBX_STRINGIFY(MDBX_ENABLE_PGOP_STAT)
|
||||
" MDBX_ENABLE_PROFGC=" MDBX_STRINGIFY(MDBX_ENABLE_PROFGC)
|
||||
#if MDBX_DISABLE_VALIDATION
|
||||
@ -373,7 +372,7 @@ __dll_export
|
||||
" _GNU_SOURCE=NO"
|
||||
#endif /* _GNU_SOURCE */
|
||||
#ifdef __APPLE__
|
||||
" MDBX_OSX_SPEED_INSTEADOF_DURABILITY=" MDBX_STRINGIFY(MDBX_OSX_SPEED_INSTEADOF_DURABILITY)
|
||||
" MDBX_APPLE_SPEED_INSTEADOF_DURABILITY=" MDBX_STRINGIFY(MDBX_APPLE_SPEED_INSTEADOF_DURABILITY)
|
||||
#endif /* MacOS */
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
" MDBX_WITHOUT_MSVC_CRT=" MDBX_STRINGIFY(MDBX_WITHOUT_MSVC_CRT)
|
||||
|
@ -78,7 +78,6 @@ __cold static int lck_setup_locked(MDBX_env *env) {
|
||||
if (unlikely(err != MDBX_SUCCESS))
|
||||
return err;
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
#ifdef MADV_DODUMP
|
||||
err = madvise(env->lck_mmap.lck, size, MADV_DODUMP) ? ignore_enosys(errno)
|
||||
: MDBX_SUCCESS;
|
||||
@ -97,7 +96,6 @@ __cold static int lck_setup_locked(MDBX_env *env) {
|
||||
if (unlikely(MDBX_IS_ERROR(err)))
|
||||
return err;
|
||||
#endif /* MADV_WILLNEED */
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
lck_t *lck = env->lck_mmap.lck;
|
||||
if (lck_seize_rc == MDBX_RESULT_TRUE) {
|
||||
|
@ -29,23 +29,15 @@
|
||||
/** Using fsync() with chance of data lost on power failure */
|
||||
#define MDBX_OSX_WANNA_SPEED 1
|
||||
|
||||
#ifndef MDBX_OSX_SPEED_INSTEADOF_DURABILITY
|
||||
#ifndef MDBX_APPLE_SPEED_INSTEADOF_DURABILITY
|
||||
/** Choices \ref MDBX_OSX_WANNA_DURABILITY or \ref MDBX_OSX_WANNA_SPEED
|
||||
* for OSX & iOS */
|
||||
#define MDBX_OSX_SPEED_INSTEADOF_DURABILITY MDBX_OSX_WANNA_DURABILITY
|
||||
#endif /* MDBX_OSX_SPEED_INSTEADOF_DURABILITY */
|
||||
|
||||
/** Controls using of POSIX' madvise() and/or similar hints. */
|
||||
#ifndef MDBX_ENABLE_MADVISE
|
||||
#define MDBX_ENABLE_MADVISE 1
|
||||
#elif !(MDBX_ENABLE_MADVISE == 0 || MDBX_ENABLE_MADVISE == 1)
|
||||
#error MDBX_ENABLE_MADVISE must be defined as 0 or 1
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
#define MDBX_APPLE_SPEED_INSTEADOF_DURABILITY MDBX_OSX_WANNA_DURABILITY
|
||||
#endif /* MDBX_APPLE_SPEED_INSTEADOF_DURABILITY */
|
||||
|
||||
/** Controls checking PID against reuse DB environment after the fork() */
|
||||
#ifndef MDBX_ENV_CHECKPID
|
||||
#if (defined(MADV_DONTFORK) && MDBX_ENABLE_MADVISE) || defined(_WIN32) || \
|
||||
defined(_WIN64)
|
||||
#if defined(MADV_DONTFORK) || defined(_WIN32) || defined(_WIN64)
|
||||
/* PID check could be omitted:
|
||||
* - on Linux when madvise(MADV_DONTFORK) is available, i.e. after the fork()
|
||||
* mapped pages will not be available for child process.
|
||||
@ -110,15 +102,16 @@
|
||||
|
||||
/** Controls using Unix' mincore() to determine whether DB-pages
|
||||
* are resident in memory. */
|
||||
#ifndef MDBX_ENABLE_MINCORE
|
||||
#ifndef MDBX_USE_MINCORE
|
||||
#if defined(MINCORE_INCORE) || !(defined(_WIN32) || defined(_WIN64))
|
||||
#define MDBX_ENABLE_MINCORE 1
|
||||
#define MDBX_USE_MINCORE 1
|
||||
#else
|
||||
#define MDBX_ENABLE_MINCORE 0
|
||||
#define MDBX_USE_MINCORE 0
|
||||
#endif
|
||||
#elif !(MDBX_ENABLE_MINCORE == 0 || MDBX_ENABLE_MINCORE == 1)
|
||||
#error MDBX_ENABLE_MINCORE must be defined as 0 or 1
|
||||
#endif /* MDBX_ENABLE_MINCORE */
|
||||
#define MDBX_USE_MINCORE_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_USE_MINCORE)
|
||||
#elif !(MDBX_USE_MINCORE == 0 || MDBX_USE_MINCORE == 1)
|
||||
#error MDBX_USE_MINCORE must be defined as 0 or 1
|
||||
#endif /* MDBX_USE_MINCORE */
|
||||
|
||||
/** Enables chunking long list of retired pages during huge transactions commit
|
||||
* to avoid use sequences of pages. */
|
||||
@ -151,12 +144,16 @@
|
||||
#endif /* MDBX_DPL_PREALLOC_FOR_RADIXSORT */
|
||||
|
||||
/** Controls dirty pages tracking, spilling and persisting in `MDBX_WRITEMAP`
|
||||
* mode. 0/OFF = Don't track dirty pages at all, don't spill ones, and use
|
||||
* msync() to persist data. This is by-default on Linux and other systems where
|
||||
* kernel provides properly LRU tracking and effective flushing on-demand. 1/ON
|
||||
* = Tracking of dirty pages but with LRU labels for spilling and explicit
|
||||
* persist ones by write(). This may be reasonable for systems which low
|
||||
* performance of msync() and/or LRU tracking. */
|
||||
* mode, i.e. disables in-memory database updating with consequent
|
||||
* flush-to-disk/msync syscall.
|
||||
*
|
||||
* 0/OFF = Don't track dirty pages at all, don't spill ones, and use msync() to
|
||||
* persist data. This is by-default on Linux and other systems where kernel
|
||||
* provides properly LRU tracking and effective flushing on-demand.
|
||||
*
|
||||
* 1/ON = Tracking of dirty pages but with LRU labels for spilling and explicit
|
||||
* persist ones by write(). This may be reasonable for goofy systems (Windows)
|
||||
* which low performance of msync() and/or zany LRU tracking. */
|
||||
#ifndef MDBX_AVOID_MSYNC
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define MDBX_AVOID_MSYNC 1
|
||||
@ -212,7 +209,7 @@
|
||||
#error MDBX_ENVCOPY_WRITEBUF must be defined in range 65536..1073741824 and be multiple of 65536
|
||||
#endif /* MDBX_ENVCOPY_WRITEBUF */
|
||||
|
||||
/** Forces assertion checking */
|
||||
/** Forces assertion checking. */
|
||||
#ifndef MDBX_FORCE_ASSERTIONS
|
||||
#define MDBX_FORCE_ASSERTIONS 0
|
||||
#elif !(MDBX_FORCE_ASSERTIONS == 0 || MDBX_FORCE_ASSERTIONS == 1)
|
||||
@ -284,9 +281,6 @@
|
||||
/** POSIX-2008 Robust Mutexes for \ref MDBX_LOCKING */
|
||||
#define MDBX_LOCKING_POSIX2008 2008
|
||||
|
||||
/** BeOS Benaphores, aka Futexes for \ref MDBX_LOCKING */
|
||||
#define MDBX_LOCKING_BENAPHORE 1995
|
||||
|
||||
/** Advanced: Choices the locking implementation (autodetection by default). */
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define MDBX_LOCKING MDBX_LOCKING_WIN32FILES
|
||||
@ -363,19 +357,6 @@
|
||||
#error MDBX_USE_COPYFILERANGE must be defined as 0 or 1
|
||||
#endif /* MDBX_USE_COPYFILERANGE */
|
||||
|
||||
/** Advanced: Using sync_file_range() syscall (autodetection by default). */
|
||||
#ifndef MDBX_USE_SYNCFILERANGE
|
||||
#if ((defined(__linux__) || defined(__gnu_linux__)) && \
|
||||
defined(SYNC_FILE_RANGE_WRITE) && !defined(__ANDROID_API__)) || \
|
||||
(defined(__ANDROID_API__) && __ANDROID_API__ >= 26)
|
||||
#define MDBX_USE_SYNCFILERANGE 1
|
||||
#else
|
||||
#define MDBX_USE_SYNCFILERANGE 0
|
||||
#endif
|
||||
#elif !(MDBX_USE_SYNCFILERANGE == 0 || MDBX_USE_SYNCFILERANGE == 1)
|
||||
#error MDBX_USE_SYNCFILERANGE must be defined as 0 or 1
|
||||
#endif /* MDBX_USE_SYNCFILERANGE */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef MDBX_CPU_WRITEBACK_INCOHERENT
|
||||
@ -416,15 +397,19 @@
|
||||
#error MDBX_MMAP_INCOHERENT_CPU_CACHE must be defined as 0 or 1
|
||||
#endif /* MDBX_MMAP_INCOHERENT_CPU_CACHE */
|
||||
|
||||
#ifndef MDBX_MMAP_USE_MS_ASYNC
|
||||
#if MDBX_MMAP_INCOHERENT_FILE_WRITE || MDBX_MMAP_INCOHERENT_CPU_CACHE
|
||||
#define MDBX_MMAP_USE_MS_ASYNC 1
|
||||
/** Assume system needs explicit syscall to sync/flush/write modified mapped
|
||||
* memory. */
|
||||
#ifndef MDBX_MMAP_NEEDS_JOLT
|
||||
#if MDBX_MMAP_INCOHERENT_FILE_WRITE || MDBX_MMAP_INCOHERENT_CPU_CACHE || \
|
||||
!(defined(__linux__) || defined(__gnu_linux__))
|
||||
#define MDBX_MMAP_NEEDS_JOLT 1
|
||||
#else
|
||||
#define MDBX_MMAP_USE_MS_ASYNC 0
|
||||
#define MDBX_MMAP_NEEDS_JOLT 0
|
||||
#endif
|
||||
#elif !(MDBX_MMAP_USE_MS_ASYNC == 0 || MDBX_MMAP_USE_MS_ASYNC == 1)
|
||||
#error MDBX_MMAP_USE_MS_ASYNC must be defined as 0 or 1
|
||||
#endif /* MDBX_MMAP_USE_MS_ASYNC */
|
||||
#define MDBX_MMAP_NEEDS_JOLT_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_MMAP_NEEDS_JOLT)
|
||||
#elif !(MDBX_MMAP_NEEDS_JOLT == 0 || MDBX_MMAP_NEEDS_JOLT == 1)
|
||||
#error MDBX_MMAP_NEEDS_JOLT must be defined as 0 or 1
|
||||
#endif /* MDBX_MMAP_NEEDS_JOLT */
|
||||
|
||||
#ifndef MDBX_64BIT_ATOMIC
|
||||
#if MDBX_WORDBITS >= 64 || defined(DOXYGEN)
|
||||
@ -507,7 +492,9 @@
|
||||
#endif /* MDBX_CACHELINE_SIZE */
|
||||
|
||||
/* Max length of iov-vector passed to writev() call, used for auxilary writes */
|
||||
#ifndef MDBX_AUXILARY_IOV_MAX
|
||||
#define MDBX_AUXILARY_IOV_MAX 64
|
||||
#endif
|
||||
#if defined(IOV_MAX) && IOV_MAX < MDBX_AUXILARY_IOV_MAX
|
||||
#undef MDBX_AUXILARY_IOV_MAX
|
||||
#define MDBX_AUXILARY_IOV_MAX IOV_MAX
|
||||
|
10
src/osal.c
10
src/osal.c
@ -1623,7 +1623,7 @@ MDBX_INTERNAL int osal_fsync(mdbx_filehandle_t fd,
|
||||
#else
|
||||
|
||||
#if defined(__APPLE__) && \
|
||||
MDBX_OSX_SPEED_INSTEADOF_DURABILITY == MDBX_OSX_WANNA_DURABILITY
|
||||
MDBX_APPLE_SPEED_INSTEADOF_DURABILITY == MDBX_OSX_WANNA_DURABILITY
|
||||
if (mode_bits & MDBX_SYNC_IODQ)
|
||||
return likely(fcntl(fd, F_FULLFSYNC) != -1) ? MDBX_SUCCESS : errno;
|
||||
#endif /* MacOS */
|
||||
@ -1776,7 +1776,7 @@ MDBX_INTERNAL int osal_thread_join(osal_thread_t thread) {
|
||||
|
||||
MDBX_INTERNAL int osal_msync(const osal_mmap_t *map, size_t offset,
|
||||
size_t length, enum osal_syncmode_bits mode_bits) {
|
||||
if (!MDBX_MMAP_USE_MS_ASYNC && mode_bits == MDBX_SYNC_NONE)
|
||||
if (!MDBX_MMAP_NEEDS_JOLT && mode_bits == MDBX_SYNC_NONE)
|
||||
return MDBX_SUCCESS;
|
||||
|
||||
void *ptr = ptr_disp(map->base, offset);
|
||||
@ -1793,7 +1793,7 @@ MDBX_INTERNAL int osal_msync(const osal_mmap_t *map, size_t offset,
|
||||
//
|
||||
// However, this behavior may be changed in custom kernels,
|
||||
// so just leave such optimization to the libc discretion.
|
||||
// NOTE: The MDBX_MMAP_USE_MS_ASYNC must be defined to 1 for such cases.
|
||||
// NOTE: The MDBX_MMAP_NEEDS_JOLT must be defined to 1 for such cases.
|
||||
//
|
||||
// assert(mdbx.linux_kernel_version > 0x02061300);
|
||||
// if (mode_bits <= MDBX_SYNC_KICK)
|
||||
@ -2314,7 +2314,6 @@ MDBX_INTERNAL int osal_mmap(const int flags, osal_mmap_t *map, size_t size,
|
||||
}
|
||||
map->limit = limit;
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
#ifdef MADV_DONTFORK
|
||||
if (unlikely(madvise(map->base, map->limit, MADV_DONTFORK) != 0))
|
||||
return errno;
|
||||
@ -2322,7 +2321,6 @@ MDBX_INTERNAL int osal_mmap(const int flags, osal_mmap_t *map, size_t size,
|
||||
#ifdef MADV_NOHUGEPAGE
|
||||
(void)madvise(map->base, map->limit, MADV_NOHUGEPAGE);
|
||||
#endif /* MADV_NOHUGEPAGE */
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
#endif /* ! Windows */
|
||||
|
||||
@ -2735,7 +2733,6 @@ retry_mapview:;
|
||||
map->limit = limit;
|
||||
map->current = size;
|
||||
|
||||
#if MDBX_ENABLE_MADVISE
|
||||
#ifdef MADV_DONTFORK
|
||||
if (unlikely(madvise(map->base, map->limit, MADV_DONTFORK) != 0)) {
|
||||
assert(errno != 0);
|
||||
@ -2745,7 +2742,6 @@ retry_mapview:;
|
||||
#ifdef MADV_NOHUGEPAGE
|
||||
(void)madvise(map->base, map->limit, MADV_NOHUGEPAGE);
|
||||
#endif /* MADV_NOHUGEPAGE */
|
||||
#endif /* MDBX_ENABLE_MADVISE */
|
||||
|
||||
#endif /* POSIX / Windows */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user