mdbx: add MDBX_FAKE_SPILL_WRITEMAP build option.

Change-Id: I2c7f9267b0e725674b8bc73547bedd8478231948
This commit is contained in:
Leonid Yuriev 2021-04-26 18:18:51 +03:00
parent 4fa5e95241
commit 427b480f68
2 changed files with 19 additions and 3 deletions

View File

@ -5109,9 +5109,6 @@ static int mdbx_txn_spill(MDBX_txn *txn, MDBX_cursor *m0, unsigned need) {
int rc = MDBX_SUCCESS;
if (txn->mt_flags & MDBX_WRITEMAP) {
MDBX_dpl *const dl = txn->tw.dirtylist;
#ifndef MDBX_FAKE_SPILL_WRITEMAP
#define MDBX_FAKE_SPILL_WRITEMAP 1
#endif
const unsigned span = dl->length - txn->tw.loose_count;
txn->tw.dirtyroom += span;
if (MDBX_FAKE_SPILL_WRITEMAP) {

View File

@ -131,6 +131,25 @@
#error MDBX_DPL_PREALLOC_FOR_RADIXSORT must be defined as 0 or 1
#endif /* MDBX_DPL_PREALLOC_FOR_RADIXSORT */
/* Basically, this build-option is for TODO. Guess it should be replaced
* with MDBX_ENABLE_WRITEMAP_SPILLING with the three variants:
* 0/OFF = Don't track dirty pages at all and don't spilling ones.
* This should be by-default on Linux and may-be other systems
* (not sure: Darwin/OSX, FreeBSD, Windows 10) where kernel provides
* properly LRU tracking and async writing on-demand.
* 1/ON = Lite tracking of dirty pages but with LRU labels and explicit
* spilling with msync(MS_ASYNC). */
#ifndef MDBX_FAKE_SPILL_WRITEMAP
#if defined(__linux__) || defined(__gnu_linux__)
#define MDBX_FAKE_SPILL_WRITEMAP 1 /* msync(MS_ASYNC) is no-op on Linux */
#else
#define MDBX_FAKE_SPILL_WRITEMAP 0
#endif
#endif
#if !(MDBX_FAKE_SPILL_WRITEMAP == 0 || MDBX_FAKE_SPILL_WRITEMAP == 1)
#error MDBX_FAKE_SPILL_WRITEMAP must be defined as 0 or 1
#endif /* MDBX_FAKE_SPILL_WRITEMAP */
/** Controls sort order of internal page number lists.
* The database format depend on this option and libmdbx builded with different
* option value are incompatible. */