From 661372d66de09b094d6ba0fbbe4d4c6c8e9de6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Wed, 10 Apr 2024 20:35:28 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=D1=81=D0=BF=D0=BB=D0=B5=D1=81=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=20GC=20=D0=B2=20Erigon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h | 6 ++++++ src/core.c | 18 ++++++++++++++++++ src/internals.h | 6 ++++++ src/options.h | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) 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 */