|
1 | | -/* This file is part of the libmdbx amalgamated source code (v0.14.1-389-gd5175913 at 2026-02-05T17:57:15+03:00). |
| 1 | +/* This file is part of the libmdbx amalgamated source code (v0.14.1-428-g6569bd09 at 2026-02-24T16:49:25+03:00). |
2 | 2 | * |
3 | 3 | * libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with |
4 | 4 | * open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight |
|
24 | 24 |
|
25 | 25 | #define xMDBX_ALLOY 1 /* alloyed build */ |
26 | 26 |
|
27 | | -#define MDBX_BUILD_SOURCERY ada3e97b23b38bc24478dd09b1bc2f7430d5b6b731285309c7294921f3d628a2_v0_14_1_389_gd5175913 |
| 27 | +#define MDBX_BUILD_SOURCERY e1b0e3d3dfd6db79e6b76995f4387eded3f83975b0c552b3c5fe9e16f563f21e_v0_14_1_428_g6569bd09 |
28 | 28 |
|
29 | 29 | #define LIBMDBX_INTERNALS |
30 | 30 | #define MDBX_DEPRECATED |
@@ -1795,6 +1795,22 @@ MDBX_MAYBE_UNUSED MDBX_NOTHROW_PURE_FUNCTION static inline uint32_t osal_bswap32 |
1795 | 1795 | #error MDBX_DPL_PREALLOC_FOR_RADIXSORT must be defined as 0 or 1 |
1796 | 1796 | #endif /* MDBX_DPL_PREALLOC_FOR_RADIXSORT */ |
1797 | 1797 |
|
| 1798 | +#ifndef MDBX_DML_PREALLOC_FOR_RADIXSORT |
| 1799 | +#define MDBX_DML_PREALLOC_FOR_RADIXSORT 1 |
| 1800 | +#elif !(MDBX_DML_PREALLOC_FOR_RADIXSORT == 0 || MDBX_DML_PREALLOC_FOR_RADIXSORT == 1) |
| 1801 | +#error MDBX_DML_PREALLOC_FOR_RADIXSORT must be defined as 0 or 1 |
| 1802 | +#endif /* MDBX_DML_PREALLOC_FOR_RADIXSORT */ |
| 1803 | + |
| 1804 | +#ifndef MDBX_DPL_CACHE_NPAGES |
| 1805 | +#if MDBX_WORDBITS >= 64 |
| 1806 | +#define MDBX_DPL_CACHE_NPAGES 1 |
| 1807 | +#else |
| 1808 | +#define MDBX_DPL_CACHE_NPAGES 0 |
| 1809 | +#endif |
| 1810 | +#elif !(MDBX_DPL_CACHE_NPAGES == 0 || MDBX_DPL_CACHE_NPAGES == 1) |
| 1811 | +#error MDBX_DPL_CACHE_NPAGES must be defined as 0 or 1 |
| 1812 | +#endif /* MDBX_DPL_CACHE_NPAGES */ |
| 1813 | + |
1798 | 1814 | /** Controls dirty pages tracking, spilling and persisting in `MDBX_WRITEMAP`. |
1799 | 1815 | * |
1800 | 1816 | * \details In other words, disables in-memory database updating with consequent |
@@ -1935,6 +1951,20 @@ MDBX_MAYBE_UNUSED MDBX_NOTHROW_PURE_FUNCTION static inline uint32_t osal_bswap32 |
1935 | 1951 | #error MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS must be defined as 0 or 1 |
1936 | 1952 | #endif /* MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS */ |
1937 | 1953 |
|
| 1954 | +/** Forces rounding size of memory mapped regions and files to system allocation granularity rather to system page size. |
| 1955 | + * |
| 1956 | + * \details In most operating systems, RAM is allocated in larger chunks consisting of several pages. |
| 1957 | + * Thus, rounding up to the size of the system page, rather than the actual size of the block used |
| 1958 | + * for memory allocation, does not save resources, but only hides what is really happening. |
| 1959 | + * On the other hand, system allocation granularity may depend not only on the type of operating system, |
| 1960 | + * but also on the version, settings, and amount of available resources (RAM), so increasing the rounding |
| 1961 | + * unit may lead to doubtful and unexpected behavior for the user. */ |
| 1962 | +#ifndef MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY |
| 1963 | +#define MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY 0 |
| 1964 | +#elif !(MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY == 0 || MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY == 1) |
| 1965 | +#error MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY must be defined as 0 or 1 |
| 1966 | +#endif /* MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY */ |
| 1967 | + |
1938 | 1968 | //------------------------------------------------------------------------------ |
1939 | 1969 |
|
1940 | 1970 | /** Win32 File Locking API for \ref MDBX_LOCKING */ |
@@ -3316,7 +3346,7 @@ typedef const pgno_t *const_pnl_t; |
3316 | 3346 | #define MDBX_PNL_LEAST(pl) MDBX_PNL_LAST(pl) |
3317 | 3347 | #define MDBX_PNL_MOST(pl) MDBX_PNL_FIRST(pl) |
3318 | 3348 | #define MDBX_PNL_CONTIGUOUS(prev, next, span) (((prev) - (next)) == (span)) |
3319 | | -#endif |
| 3349 | +#endif /* MDBX_PNL_ASCENDING */ |
3320 | 3350 |
|
3321 | 3351 | #ifndef __cplusplus |
3322 | 3352 |
|
@@ -3372,11 +3402,15 @@ MDBX_MAYBE_UNUSED MDBX_INTERNAL pnl_t pnl_clone(const const_pnl_t src); |
3372 | 3402 |
|
3373 | 3403 | MDBX_INTERNAL int pnl_reserve(pnl_t __restrict *__restrict ppnl, const size_t wanna); |
3374 | 3404 |
|
3375 | | -MDBX_MAYBE_UNUSED static inline int __must_check_result pnl_need(pnl_t __restrict *__restrict ppnl, size_t num) { |
3376 | | - assert(pnl_size(*ppnl) <= PAGELIST_LIMIT && pnl_alloclen(*ppnl) >= pnl_size(*ppnl)); |
3377 | | - assert(num <= PAGELIST_LIMIT); |
3378 | | - const size_t wanna = pnl_size(*ppnl) + num; |
3379 | | - return likely(pnl_alloclen(*ppnl) >= wanna) ? MDBX_SUCCESS : pnl_reserve(ppnl, wanna); |
| 3405 | +MDBX_MAYBE_UNUSED static inline int __must_check_result pnl_need(pnl_t __restrict *__restrict ppnl, size_t more) { |
| 3406 | + if (likely(*ppnl)) { |
| 3407 | + assert(pnl_size(*ppnl) <= PAGELIST_LIMIT && pnl_alloclen(*ppnl) >= pnl_size(*ppnl)); |
| 3408 | + assert(more <= PAGELIST_LIMIT); |
| 3409 | + more += pnl_size(*ppnl); |
| 3410 | + if (likely(pnl_alloclen(*ppnl) >= more)) |
| 3411 | + return MDBX_SUCCESS; |
| 3412 | + } |
| 3413 | + return pnl_reserve(ppnl, more); |
3380 | 3414 | } |
3381 | 3415 |
|
3382 | 3416 | MDBX_MAYBE_UNUSED static inline void pnl_append_prereserved(__restrict pnl_t pnl, pgno_t pgno) { |
@@ -3438,10 +3472,39 @@ MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline size_t pnl_search(con |
3438 | 3472 | return n; |
3439 | 3473 | } |
3440 | 3474 |
|
| 3475 | +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline bool pnl_contains(const const_pnl_t pnl, pgno_t pgno, |
| 3476 | + size_t limit) { |
| 3477 | + size_t n = pnl_search(pnl, pgno, limit); |
| 3478 | + return n > 0 && n <= pnl_size(pnl) && pnl[n] == pgno; |
| 3479 | +} |
| 3480 | + |
| 3481 | +MDBX_NOTHROW_PURE_FUNCTION MDBX_MAYBE_UNUSED static inline bool pnl_contains_span(const const_pnl_t pnl, pgno_t pgno, |
| 3482 | + pgno_t span) { |
| 3483 | + size_t n = pnl_search_nochk(pnl, pgno); |
| 3484 | +#if MDBX_PNL_ASCENDING |
| 3485 | +#error "FIXME" |
| 3486 | +#else |
| 3487 | + return n >= span && pnl[n] == pgno && MDBX_PNL_CONTIGUOUS(pnl[n - span + 1], pnl[n], span - 1); |
| 3488 | +#endif /* MDBX_PNL_ASCENDING */ |
| 3489 | +} |
| 3490 | + |
3441 | 3491 | MDBX_INTERNAL size_t pnl_merge(pnl_t dst, const const_pnl_t src); |
3442 | 3492 |
|
3443 | 3493 | MDBX_MAYBE_UNUSED MDBX_NOTHROW_PURE_FUNCTION MDBX_INTERNAL size_t pnl_maxspan(const const_pnl_t pnl); |
3444 | 3494 |
|
| 3495 | +MDBX_MAYBE_UNUSED MDBX_NOTHROW_PURE_FUNCTION static inline size_t pnl_scan_span(const const_pnl_t pnl, |
| 3496 | + const size_t from) { |
| 3497 | + size_t span = 1; |
| 3498 | + assert(from > 0 && from <= pnl_size(pnl)); |
| 3499 | + while (from + span <= pnl_size(pnl) && MDBX_PNL_CONTIGUOUS(pnl[from], pnl[from + span], span)) |
| 3500 | + ++span; |
| 3501 | + return span; |
| 3502 | +} |
| 3503 | + |
| 3504 | +MDBX_MAYBE_UNUSED MDBX_INTERNAL pgno_t pnl_get_best_sequence(const pnl_t pnl, const size_t span, |
| 3505 | + const pgno_t defrag_detent); |
| 3506 | +MDBX_MAYBE_UNUSED MDBX_INTERNAL pgno_t pnl_crop_tail_sequence(const pnl_t pnl); |
| 3507 | + |
3445 | 3508 | #endif /* !__cplusplus */ |
3446 | 3509 |
|
3447 | 3510 | #ifdef __cplusplus |
|
0 commit comments