tx_memory_pool: speedup get_complement() for large requests #10186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes complexity from$M * N$ to $(2 * N+M) * log2(M)$ , where $M$ is the requester's mempool size and $N$ is the responder's mempool size. 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 $(2 * 55000+55000)*log2(55000)$ comparisons (about 2.6 million), a 99.83% reduction.
This commit is especially noteworthy for FCMP++ stressnet node performance when considering seraphis-migration#177 is merged into the stressnet branch. The cited change makes the pool complement p2p call much more frequently.