From 0761024b349048ebf79dbfe71caab11826833464 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Mon, 3 Nov 2025 17:05:57 -0600 Subject: tx_memory_pool: speedup get_complement() for large requests Changes complexity from M*N to (2*N+M)*log2(M). The FCMP++ stressnet recently hit mempool sizes of ~55k txs. If the requesting node's mempool is populated, this results in an average of (55000*55000)/2 (about 1.5 billion) comparisons for the responding node. Under this commit, this would be reduced to (55000+55000)*log2(55000) comparisons (about 2.6 million), a 99.83% reduction. --- src/cryptonote_core/cryptonote_core.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cryptonote_core/cryptonote_core.cpp') diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index d30bc72a7..e9932ca39 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1843,9 +1843,9 @@ namespace cryptonote m_blockchain_storage.flush_invalid_blocks(); } //----------------------------------------------------------------------------------------------- - bool core::get_txpool_complement(const std::vector &hashes, std::vector &txes) + bool core::get_txpool_complement(std::vector hashes, std::vector &txes) { - return m_mempool.get_complement(hashes, txes); + return m_mempool.get_complement(std::move(hashes), txes); } //----------------------------------------------------------------------------------------------- bool core::update_blockchain_pruning() -- cgit v1.2.3