mdbx: отладка всплесков GC в Erigon.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2024-04-10 20:35:28 +03:00
parent c35f5c7517
commit 661372d66d
4 changed files with 31 additions and 1 deletions

6
mdbx.h
View File

@ -4111,6 +4111,12 @@ struct MDBX_commit_latency {
/** \brief Количество страничных промахов (page faults) внутри GC
* при выделении и подготовки страниц для самой GC. */
uint32_t self_majflt;
/* Для разборок с pnl_merge() */
struct {
uint32_t time;
uint64_t volume;
uint32_t calls;
} pnl_merge_work, pnl_merge_self;
} gc_prof;
};
#ifndef __cplusplus

View File

@ -8004,7 +8004,15 @@ next_gc:;
}
/* Merge in descending sorted order */
#if MDBX_ENABLE_PROFGC
const uint64_t merge_begin = osal_monotime();
#endif /* MDBX_ENABLE_PROFGC */
pnl_merge(txn->tw.relist, gc_pnl);
#if MDBX_ENABLE_PROFGC
prof->pnl_merge.calls += 1;
prof->pnl_merge.volume += MDBX_PNL_GETSIZE(txn->tw.relist);
prof->pnl_merge.time += osal_monotime() - merge_begin;
#endif /* MDBX_ENABLE_PROFGC */
flags |= MDBX_ALLOC_SHOULD_SCAN;
if (AUDIT_ENABLED()) {
if (unlikely(!pnl_check(txn->tw.relist, txn->mt_next_pgno))) {
@ -12084,6 +12092,16 @@ static void take_gcprof(MDBX_txn *txn, MDBX_commit_latency *latency) {
latency->gc_prof.wipes = ptr->gc_prof.wipes;
latency->gc_prof.flushes = ptr->gc_prof.flushes;
latency->gc_prof.kicks = ptr->gc_prof.kicks;
latency->gc_prof.pnl_merge_work.time =
osal_monotime_to_16dot16(ptr->gc_prof.work.pnl_merge.time);
latency->gc_prof.pnl_merge_work.calls = ptr->gc_prof.work.pnl_merge.calls;
latency->gc_prof.pnl_merge_work.volume = ptr->gc_prof.work.pnl_merge.volume;
latency->gc_prof.pnl_merge_self.time =
osal_monotime_to_16dot16(ptr->gc_prof.self.pnl_merge.time);
latency->gc_prof.pnl_merge_self.calls = ptr->gc_prof.self.pnl_merge.calls;
latency->gc_prof.pnl_merge_self.volume = ptr->gc_prof.self.pnl_merge.volume;
if (txn == env->me_txn0)
memset(&ptr->gc_prof, 0, sizeof(ptr->gc_prof));
} else

View File

@ -756,6 +756,12 @@ typedef struct profgc_stat {
uint32_t spe_counter;
/* page faults (hard page faults) */
uint32_t majflt;
/* Для разборок с pnl_merge() */
struct {
uint64_t time;
uint64_t volume;
uint32_t calls;
} pnl_merge;
} profgc_stat_t;
/* Statistics of page operations overall of all (running, completed and aborted)

View File

@ -89,7 +89,7 @@
/** Controls profiling of GC search and updates. */
#ifndef MDBX_ENABLE_PROFGC
#define MDBX_ENABLE_PROFGC 0
#define MDBX_ENABLE_PROFGC 1
#elif !(MDBX_ENABLE_PROFGC == 0 || MDBX_ENABLE_PROFGC == 1)
#error MDBX_ENABLE_PROFGC must be defined as 0 or 1
#endif /* MDBX_ENABLE_PROFGC */