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.
This commit is contained in:
jeffro256
2025-11-26 13:40:33 -06:00
parent 6bb36309d6
commit 0673c957af
6 changed files with 18 additions and 8 deletions
+2 -2
View File
@@ -1850,9 +1850,9 @@ namespace cryptonote
m_blockchain_storage.flush_invalid_blocks();
}
//-----------------------------------------------------------------------------------------------
bool core::get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes)
bool core::get_txpool_complement(std::vector<crypto::hash> hashes, std::vector<cryptonote::blobdata> &txes)
{
return m_mempool.get_complement(hashes, txes);
return m_mempool.get_complement(std::move(hashes), txes);
}
//-----------------------------------------------------------------------------------------------
bool core::update_blockchain_pruning()