From 38513b6346fb743aa3c34b0daeb10ea81829d3e5 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 23 Jun 2025 14:00:11 +0700 Subject: [PATCH 1/3] perf: temporary cache for consequent calls of CDeterministicMNList for historical blocks It speeds ups blocks's Undo up to 10x. It speeds up RPC `protx diff` up to 9x --- src/evo/deterministicmns.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index e3e850bdb9df..17c19fd6bf66 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -778,6 +778,13 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlockInternal(gsl::not_n for (const auto& diffIndex : listDiffIndexes) { const auto& diff = mnListDiffsCache.at(diffIndex->GetBlockHash()); snapshot.ApplyDiff(diffIndex, diff); + if (snapshot.GetHeight() % 32 == 0) { + // Add this temporary mini-snapshot to cache. + // This extra cached mn-list helps to improve performance of GetListForBlock + // for close blocks, because in the worst cases each of them requires to retrieve + // and apply up to 575 diffs + mnListsCache.emplace(snapshot.GetBlockHash(), snapshot); + } } if (tipIndex) { From bfca7268728358477e19e7bb12a16062156dfe44 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 18 Aug 2025 15:13:15 +0700 Subject: [PATCH 2/3] perf: do not create mini-snapshots during re-index --- src/evo/deterministicmns.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index 17c19fd6bf66..5ec5066b5aef 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include