diff --git a/mdbx.h b/mdbx.h index 16fa1066..fd29387a 100644 --- a/mdbx.h +++ b/mdbx.h @@ -4139,6 +4139,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/gc-get.c b/src/gc-get.c index 196001f9..a32f2755 100644 --- a/src/gc-get.c +++ b/src/gc-get.c @@ -1064,7 +1064,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 |= ALLOC_SHOULD_SCAN; if (AUDIT_ENABLED()) { if (unlikely(!pnl_check(txn->tw.relist, txn->geo.first_unallocated))) { diff --git a/src/layout-lck.h b/src/layout-lck.h index f4a2a368..b635c595 100644 --- a/src/layout-lck.h +++ b/src/layout-lck.h @@ -50,6 +50,12 @@ typedef struct gc_prof_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; } gc_prof_stat_t; /* Statistics of pages operations for all transactions, diff --git a/src/txn.c b/src/txn.c index 627ddc79..38e53e5a 100644 --- a/src/txn.c +++ b/src/txn.c @@ -418,6 +418,14 @@ 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->basal_txn) memset(&ptr->gc_prof, 0, sizeof(ptr->gc_prof)); } else