diff --git a/mdbx.h b/mdbx.h index e19e47c8..3cd26c5a 100644 --- a/mdbx.h +++ b/mdbx.h @@ -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 diff --git a/src/core.c b/src/core.c index f364b97c..24fa17f0 100644 --- a/src/core.c +++ b/src/core.c @@ -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 diff --git a/src/internals.h b/src/internals.h index 64bf7355..f753e569 100644 --- a/src/internals.h +++ b/src/internals.h @@ -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) diff --git a/src/options.h b/src/options.h index 73d892af..d8d63ef2 100644 --- a/src/options.h +++ b/src/options.h @@ -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 */