mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 23:24:14 +08:00
mdbx: refine pgno-lists.
Change-Id: Id38e4aff508437210d4c0e63962067dfe518eb31
This commit is contained in:
parent
592c064873
commit
552b759878
42
src/bits.h
42
src/bits.h
@ -434,11 +434,11 @@ typedef struct MDBX_lockinfo {
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Two kind lists of pages (aka IDL) */
|
/* Two kind lists of pages (aka IDL) */
|
||||||
|
|
||||||
/* An IDL is an ID List, a sorted array of IDs. The first
|
/* An PNL is an Page Number List, a sorted array of IDs. The first
|
||||||
* element of the array is a counter for how many actual
|
* element of the array is a counter for how many actual
|
||||||
* IDs are in the list. In the libmdbx IDLs are sorted in
|
* IDs are in the list. In the libmdbx PNLs are sorted in
|
||||||
* descending order. */
|
* descending order. */
|
||||||
typedef pgno_t *MDBX_IDL;
|
typedef pgno_t *MDBX_PNL;
|
||||||
|
|
||||||
/* List of txnid, only for MDBX_env.mt_lifo_reclaimed */
|
/* List of txnid, only for MDBX_env.mt_lifo_reclaimed */
|
||||||
typedef txnid_t *MDBX_TXL;
|
typedef txnid_t *MDBX_TXL;
|
||||||
@ -455,23 +455,23 @@ typedef struct MDBX_ID2 {
|
|||||||
* unused. The array is sorted in ascending order by mid. */
|
* unused. The array is sorted in ascending order by mid. */
|
||||||
typedef MDBX_ID2 *MDBX_ID2L;
|
typedef MDBX_ID2 *MDBX_ID2L;
|
||||||
|
|
||||||
/* IDL sizes - likely should be even bigger
|
/* PNL sizes - likely should be even bigger
|
||||||
* limiting factors: sizeof(pgno_t), thread stack size */
|
* limiting factors: sizeof(pgno_t), thread stack size */
|
||||||
#define MDBX_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */
|
#define MDBX_PNL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */
|
||||||
#define MDBX_IDL_DB_SIZE (1 << MDBX_IDL_LOGN)
|
#define MDBX_PNL_DB_SIZE (1 << MDBX_PNL_LOGN)
|
||||||
#define MDBX_IDL_UM_SIZE (1 << (MDBX_IDL_LOGN + 1))
|
#define MDBX_PNL_UM_SIZE (1 << (MDBX_PNL_LOGN + 1))
|
||||||
|
|
||||||
#define MDBX_IDL_DB_MAX (MDBX_IDL_DB_SIZE - 1)
|
#define MDBX_PNL_DB_MAX (MDBX_PNL_DB_SIZE - 1)
|
||||||
#define MDBX_IDL_UM_MAX (MDBX_IDL_UM_SIZE - 1)
|
#define MDBX_PNL_UM_MAX (MDBX_PNL_UM_SIZE - 1)
|
||||||
|
|
||||||
#define MDBX_IDL_SIZEOF(ids) (((ids)[0] + 1) * sizeof(pgno_t))
|
#define MDBX_PNL_SIZEOF(pl) (((pl)[0] + 1) * sizeof(pgno_t))
|
||||||
#define MDBX_IDL_IS_ZERO(ids) ((ids)[0] == 0)
|
#define MDBX_PNL_IS_ZERO(pl) ((pl)[0] == 0)
|
||||||
#define MDBX_IDL_CPY(dst, src) (memcpy(dst, src, MDBX_IDL_SIZEOF(src)))
|
#define MDBX_PNL_CPY(dst, src) (memcpy(dst, src, MDBX_PNL_SIZEOF(src)))
|
||||||
#define MDBX_IDL_FIRST(ids) ((ids)[1])
|
#define MDBX_PNL_FIRST(pl) ((pl)[1])
|
||||||
#define MDBX_IDL_LAST(ids) ((ids)[(ids)[0]])
|
#define MDBX_PNL_LAST(pl) ((pl)[(pl)[0]])
|
||||||
|
|
||||||
/* Current max length of an mdbx_midl_alloc()ed IDL */
|
/* Current max length of an mdbx_pnl_alloc()ed PNL */
|
||||||
#define MDBX_IDL_ALLOCLEN(ids) ((ids)[-1])
|
#define MDBX_PNL_ALLOCLEN(pl) ((pl)[-1])
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Internal structures */
|
/* Internal structures */
|
||||||
@ -503,7 +503,7 @@ struct MDBX_txn {
|
|||||||
/* The list of reclaimed txns from freeDB */
|
/* The list of reclaimed txns from freeDB */
|
||||||
MDBX_TXL mt_lifo_reclaimed;
|
MDBX_TXL mt_lifo_reclaimed;
|
||||||
/* The list of pages that became unused during this transaction. */
|
/* The list of pages that became unused during this transaction. */
|
||||||
MDBX_IDL mt_befree_pages;
|
MDBX_PNL mt_befree_pages;
|
||||||
/* The list of loose pages that became unused and may be reused
|
/* The list of loose pages that became unused and may be reused
|
||||||
* in this transaction, linked through NEXT_LOOSE_PAGE(page). */
|
* in this transaction, linked through NEXT_LOOSE_PAGE(page). */
|
||||||
MDBX_page *mt_loose_pages;
|
MDBX_page *mt_loose_pages;
|
||||||
@ -512,7 +512,7 @@ struct MDBX_txn {
|
|||||||
/* The sorted list of dirty pages we temporarily wrote to disk
|
/* The sorted list of dirty pages we temporarily wrote to disk
|
||||||
* because the dirty list was full. page numbers in here are
|
* because the dirty list was full. page numbers in here are
|
||||||
* shifted left by 1, deleted slots have the LSB set. */
|
* shifted left by 1, deleted slots have the LSB set. */
|
||||||
MDBX_IDL mt_spill_pages;
|
MDBX_PNL mt_spill_pages;
|
||||||
union {
|
union {
|
||||||
/* For write txns: Modified pages. Sorted when not MDBX_WRITEMAP. */
|
/* For write txns: Modified pages. Sorted when not MDBX_WRITEMAP. */
|
||||||
MDBX_ID2L mt_rw_dirtylist;
|
MDBX_ID2L mt_rw_dirtylist;
|
||||||
@ -699,9 +699,9 @@ struct MDBX_env {
|
|||||||
#define me_last_reclaimed me_pgstate.mf_last_reclaimed
|
#define me_last_reclaimed me_pgstate.mf_last_reclaimed
|
||||||
#define me_reclaimed_pglist me_pgstate.mf_reclaimed_pglist
|
#define me_reclaimed_pglist me_pgstate.mf_reclaimed_pglist
|
||||||
MDBX_page *me_dpages; /* list of malloc'd blocks for re-use */
|
MDBX_page *me_dpages; /* list of malloc'd blocks for re-use */
|
||||||
/* IDL of pages that became unused in a write txn */
|
/* PNL of pages that became unused in a write txn */
|
||||||
MDBX_IDL me_free_pgs;
|
MDBX_PNL me_free_pgs;
|
||||||
/* ID2L of pages written during a write txn. Length MDBX_IDL_UM_SIZE. */
|
/* ID2L of pages written during a write txn. Length MDBX_PNL_UM_SIZE. */
|
||||||
MDBX_ID2L me_dirtylist;
|
MDBX_ID2L me_dirtylist;
|
||||||
/* Max number of freelist items that can fit in a single overflow page */
|
/* Max number of freelist items that can fit in a single overflow page */
|
||||||
unsigned me_maxfree_1pg;
|
unsigned me_maxfree_1pg;
|
||||||
|
561
src/mdbx.c
561
src/mdbx.c
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
/* mdbx_chk.c - memory-mapped database check tool */
|
/* mdbx_chk.c - memory-mapped database check tool */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>
|
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>
|
||||||
@ -343,7 +343,7 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key,
|
|||||||
data->iov_len);
|
data->iov_len);
|
||||||
else {
|
else {
|
||||||
number = *iptr++;
|
number = *iptr++;
|
||||||
if (number >= MDBX_IDL_UM_MAX)
|
if (number >= MDBX_PNL_UM_MAX)
|
||||||
problem_add("entry", record_number, "wrong idl length", "%" PRIiPTR "",
|
problem_add("entry", record_number, "wrong idl length", "%" PRIiPTR "",
|
||||||
number);
|
number);
|
||||||
else if ((number + 1) * sizeof(pgno_t) != data->iov_len)
|
else if ((number + 1) * sizeof(pgno_t) != data->iov_len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user