From 5168c80be885ca8a3d8325d9cada62dd61befe80 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: Mon, 16 Dec 2024 16:43:49 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D1=81=D0=B1=D0=BE=D1=80=20=D0=B7=D0=B0?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D1=82=20=D0=BD=D0=B0=20`pnl=5Fmerge()`=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20`MDBX=5FENABLE=5FPROFGC`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h | 6 ++++++ src/gc-get.c | 8 ++++++++ src/layout-lck.h | 6 ++++++ src/txn.c | 8 ++++++++ 4 files changed, 28 insertions(+) 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