fix(core/mempool): improve perf of retrieve transactions #4710
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.
Description
Motivation and Context
Mempool storage has a very long running write lock while retrieving txns (many inputs) for a block and processing a published block. This manifests with the status line freezing and with miners unable to retrieve a block template.
Fairly minor improvements/low hanging fruit, however with many inputs this change greatly reduces the time to complete and I was able to mine these transactions.
Some possible optimisations for future
if compact inputs are propagated, input.output_hash() will not actually have to generate the hash when doing the O(nmj) comparison.compact input broadcasting from wallets is probably not worth the effort at this stageHow Has This Been Tested?
Mempool freeze is reduced and blocks can be mined, however it is still slow for many inputs.