mirror of
https://github.com/isar/libmdbx.git
synced 2025-11-07 07:18:56 +08:00
mdbx: переделка page_alloc_slowpath() с добавлением профилирования GC.
This commit is contained in:
@@ -578,10 +578,30 @@ typedef struct MDBX_page {
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if MDBX_ENABLE_PGOP_STAT
|
||||
typedef struct profgc_stat {
|
||||
/* Монотонное время по "настенным часам"
|
||||
* затраченное на чтение и поиск внутри GC */
|
||||
uint64_t rtime_monotonic;
|
||||
/* Монотонное время по "настенным часам" затраченное
|
||||
* на подготовку страниц извлекаемых из GC, включая подкачку с диска. */
|
||||
uint64_t xtime_monotonic;
|
||||
/* Процессорное время в режим пользователя
|
||||
* затраченное на чтение и поиск внутри GC */
|
||||
uint64_t rtime_cpu;
|
||||
/* Количество итераций чтения-поиска внутри GC при выделении страниц */
|
||||
uint32_t rsteps;
|
||||
/* Количество запросов на выделение последовательностей страниц,
|
||||
* т.е. когда запрашивает выделение больше одной страницы */
|
||||
uint32_t xpages;
|
||||
/* Счетчик выполнения по медленному пути (slow path execution count) */
|
||||
uint32_t spe_counter;
|
||||
/* page faults (hard page faults) */
|
||||
uint32_t majflt;
|
||||
} profgc_stat_t;
|
||||
|
||||
/* Statistics of page operations overall of all (running, completed and aborted)
|
||||
* transactions */
|
||||
typedef struct {
|
||||
typedef struct pgop_stat {
|
||||
MDBX_atomic_uint64_t newly; /* Quantity of a new pages added */
|
||||
MDBX_atomic_uint64_t cow; /* Quantity of pages copied for update */
|
||||
MDBX_atomic_uint64_t clone; /* Quantity of parent's dirty pages clones
|
||||
@@ -592,15 +612,32 @@ typedef struct {
|
||||
MDBX_atomic_uint64_t unspill; /* Quantity of unspilled/reloaded pages */
|
||||
MDBX_atomic_uint64_t
|
||||
wops; /* Number of explicit write operations (not a pages) to a disk */
|
||||
MDBX_atomic_uint64_t
|
||||
gcrtime; /* Time spending for reading/searching GC (aka FreeDB). The
|
||||
unit/scale is platform-depended, see osal_monotime(). */
|
||||
MDBX_atomic_uint64_t
|
||||
msync; /* Number of explicit msync/flush-to-disk operations */
|
||||
MDBX_atomic_uint64_t
|
||||
fsync; /* Number of explicit fsync/flush-to-disk operations */
|
||||
} MDBX_pgop_stat_t;
|
||||
#endif /* MDBX_ENABLE_PGOP_STAT */
|
||||
|
||||
/* Статистика для профилирования GC.
|
||||
* Логически эти данные может быть стоит вынести в другую структуру,
|
||||
* но разница будет сугубо косметическая. */
|
||||
struct {
|
||||
/* Затраты на поддержку данных пользователя */
|
||||
profgc_stat_t work;
|
||||
/* Затраты на поддержку и обновления самой GC */
|
||||
profgc_stat_t self;
|
||||
/* Итераций обновления GC,
|
||||
* больше 1 если были повторы/перезапуски */
|
||||
uint32_t wloops;
|
||||
/* Итерации слияния записей GC */
|
||||
uint32_t coalescences;
|
||||
/* Уничтожения steady-точек фиксации в MDBX_UTTERLY_NOSYNC */
|
||||
uint32_t wipes;
|
||||
/* Сбросы данные на диск вне MDBX_UTTERLY_NOSYNC */
|
||||
uint32_t flushes;
|
||||
/* Попытки пнуть тормозящих читателей */
|
||||
uint32_t kicks;
|
||||
} gc_prof;
|
||||
} pgop_stat_t;
|
||||
|
||||
#if MDBX_LOCKING == MDBX_LOCKING_WIN32FILES
|
||||
#define MDBX_CLOCK_SIGN UINT32_C(0xF10C)
|
||||
@@ -738,11 +775,9 @@ typedef struct MDBX_lockinfo {
|
||||
|
||||
MDBX_ALIGNAS(MDBX_CACHELINE_SIZE) /* cacheline ----------------------------*/
|
||||
|
||||
#if MDBX_ENABLE_PGOP_STAT
|
||||
/* Statistics of costly ops of all (running, completed and aborted)
|
||||
* transactions */
|
||||
MDBX_pgop_stat_t mti_pgop_stat;
|
||||
#endif /* MDBX_ENABLE_PGOP_STAT*/
|
||||
pgop_stat_t mti_pgop_stat;
|
||||
|
||||
MDBX_ALIGNAS(MDBX_CACHELINE_SIZE) /* cacheline ----------------------------*/
|
||||
|
||||
@@ -962,9 +997,13 @@ struct MDBX_txn {
|
||||
/* Additional flag for sync_locked() */
|
||||
#define MDBX_SHRINK_ALLOWED UINT32_C(0x40000000)
|
||||
|
||||
#define MDBX_TXN_UPDATE_GC 0x20 /* GC is being updated */
|
||||
#define MDBX_TXN_FROZEN_RE 0x40 /* list of reclaimed-pgno must not altered */
|
||||
|
||||
#define TXN_FLAGS \
|
||||
(MDBX_TXN_FINISHED | MDBX_TXN_ERROR | MDBX_TXN_DIRTY | MDBX_TXN_SPILLS | \
|
||||
MDBX_TXN_HAS_CHILD | MDBX_TXN_INVALID)
|
||||
MDBX_TXN_HAS_CHILD | MDBX_TXN_INVALID | MDBX_TXN_UPDATE_GC | \
|
||||
MDBX_TXN_FROZEN_RE)
|
||||
|
||||
#if (TXN_FLAGS & (MDBX_TXN_RW_BEGIN_FLAGS | MDBX_TXN_RO_BEGIN_FLAGS)) || \
|
||||
((MDBX_TXN_RW_BEGIN_FLAGS | MDBX_TXN_RO_BEGIN_FLAGS | TXN_FLAGS) & \
|
||||
@@ -1023,8 +1062,8 @@ struct MDBX_txn {
|
||||
struct {
|
||||
meta_troika_t troika;
|
||||
/* In write txns, array of cursors for each DB */
|
||||
pgno_t *reclaimed_pglist; /* Reclaimed GC pages */
|
||||
txnid_t last_reclaimed; /* ID of last used record */
|
||||
pgno_t *relist; /* Reclaimed GC pages */
|
||||
txnid_t last_reclaimed; /* ID of last used record */
|
||||
#if MDBX_ENABLE_REFUND
|
||||
pgno_t loose_refund_wl /* FIXME: describe */;
|
||||
#endif /* MDBX_ENABLE_REFUND */
|
||||
@@ -1100,9 +1139,7 @@ struct MDBX_cursor {
|
||||
#define C_SUB 0x04 /* Cursor is a sub-cursor */
|
||||
#define C_DEL 0x08 /* last op was a cursor_del */
|
||||
#define C_UNTRACK 0x10 /* Un-track cursor when closing */
|
||||
#define C_RECLAIMING 0x20 /* GC lookup is prohibited */
|
||||
#define C_GCFREEZE 0x40 /* reclaimed_pglist must not be updated */
|
||||
uint8_t mc_flags; /* see mdbx_cursor */
|
||||
uint8_t mc_flags;
|
||||
|
||||
/* Cursor checking flags. */
|
||||
#define CC_BRANCH 0x01 /* same as P_BRANCH for CHECK_LEAF_TYPE() */
|
||||
@@ -1113,7 +1150,7 @@ struct MDBX_cursor {
|
||||
#define CC_LEAF2 0x20 /* same as P_LEAF2 for CHECK_LEAF_TYPE() */
|
||||
#define CC_RETIRING 0x40 /* refs to child pages may be invalid */
|
||||
#define CC_PAGECHECK 0x80 /* perform page checking, see MDBX_VALIDATION */
|
||||
uint8_t mc_checking; /* page checking level */
|
||||
uint8_t mc_checking;
|
||||
|
||||
MDBX_page *mc_pg[CURSOR_STACK]; /* stack of pushed pages */
|
||||
indx_t mc_ki[CURSOR_STACK]; /* stack of page indices */
|
||||
|
||||
Reference in New Issue
Block a user