New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mempool Update Cut-Through Optimization #21464
Mempool Update Cut-Through Optimization #21464
Conversation
c821ada
to
d4a5796
Compare
Interesting on first look, will review. |
5f98973
to
a4aef7a
Compare
pushed an update to simplify setRemove to hold txids instead of tx reference_wrappers, which eliminated the confusing ownership thing. should make review simpler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments, logic looks right from manual inspection of other limits code
will test
2be4f77
to
e8dafeb
Compare
utACK e8dafeb going to dive into tests next to upgrade to tACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK e8dafeb Code looks correct to me. I'm mostly just suggesting some docs if you retouch.
I wonder if (in addition to this) it would be worth changing ATMP to take a bool check_for_children
param where, if true, looks for descendants in mempool and includes them when applying ancestor/descendant limits. Technically, ATMP is currently not enforcing these rules properly for reorgs by assuming no children in the mempool. That way we can probably remove them in UpdateMempoolForReorg()
before even calling UpdateTransactionsFromBlock()
.
@JeremyRubin could you explain what this does in more layman's terms please? Is this pull anything to do with helping to fill the mempool in a way that reduces filling it with TXs that will get deleted later (due to mempool becoming full)? |
This is an optimization for the case where a reorg puts an ancestor transaction(package) back into the mempool, thus temporarily busting the transaction chain limits of the mempool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A few style comments inline, including a suggested change to minimize the diff in the CTxMemPool interface and in the calling code.
I think the two commits can be squashed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Looking to test this a bit more.
There's potential for a better -- but more sophisticated -- algorithm that can be used taking advantage of epochs, but I figured it is better to do something that is simple and works first and upgrade it later as the other epoch mempool work proceeds as it makes the patches for the epoch algorithm simpler to understand, so you can consider this as preparatory work. It could either go in now if it is not controversial, or we could wait until the other patch is ready to go.
I don't have an opinion on patch ordering but I would be glad if we can land the Epoch changes (#17628) at some point. Either as it is, or after a bit of txmempool internals cleaning/encapsulation :)
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
03d1cae
to
f0d8236
Compare
Addressed style/doc stuff in a separate commit to preserve ACKs (squashable) I also introcuded a new removal reason in a separate commit, this should not be squashed as it is ortho to the main change. @laanwj anything else you'd like to see here? |
I don't understand this. The head commit is what needs ACKs, and that's changed now that there are new commits. I'm very happy to re-review once you've squashed commits and rebased on master. |
f0d8236
to
2820b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2820b04
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to squash the test commit into the first commit, so the changes are atomic.
2820b04
to
81efedb
Compare
Addressed all feedback; keeping tests separate from changes for easier A/B comparison. However, I have reordered them so Tests come first which is more practical. |
Weak ACK 81efedb. Weak because of my limited mempool knowledge, though code looks OK, and I successfully ran unit and extended functional tests. |
When I read the commit:
based on the wording, I assumed that we were "filtering" these entries out before adding them to the mempool. However, after reviewing the PR it seems that these entries are still added to the mempool, state is still calculated/updated and cached, it's just that we are now (pre-emptively) removing Is my understanding correct? If so, it makes me wonder where the performance improvement is coming from. To me it seems all the same work is done before/after this PR, just earlier. Re: my review comment 9264766, |
Code review ACK 81efedb |
Looks like there has been a silent merge conflict though. Local compilation results in:
I think it's simply a matter of changing |
81efedb
to
a1b6371
Compare
…e improved algorithm
Often when we're updating mempool entries we update entries that we ultimately end up removing the updated entries shortly thereafter. This patch makes it so that we filter for such entries a bit earlier in processing, which yields a mild improvement for these cases, and is negligible overhead otherwise.
a1b6371
to
c5b36b1
Compare
rebased, test failures are unrelated it looks like (this PR doesn't touch secp?) |
reran ci (was unrelated failure) |
requesting re-acks from: |
reACK c5b36b1 |
utACK c5b36b1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK c5b36b1
The change looks correct to me, the doc rework for the touched functions is an improvement.
RFM? |
c5b36b1 Mempool Update Cut-Through Optimization (Jeremy Rubin) c49daf9 [TESTS] Increase limitancestorcount in tournament RPC test to showcase improved algorithm (Jeremy Rubin) Pull request description: Often when we're updating mempool entries we update entries that we ultimately end up removing the updated entries shortly thereafter. This patch makes it so that we filter for such entries a bit earlier in processing, which yields a mild improvement for these cases, and is negligible overhead otherwise. There's potential for a better -- but more sophisticated -- algorithm that can be used taking advantage of epochs, but I figured it is better to do something that is simple and works first and upgrade it later as the other epoch mempool work proceeds as it makes the patches for the epoch algorithm simpler to understand, so you can consider this as preparatory work. It could either go in now if it is not controversial, or we could wait until the other patch is ready to go. ACKs for top commit: instagibbs: reACK c5b36b1 sipa: utACK c5b36b1 mzumsande: Code Review ACK c5b36b1 Tree-SHA512: 78b16864f77a637d8a68a65e23c019a9757d8b2243486728ef601d212ae482f6084cf8e69d810958c356f1803178046e4697207ba40d6d10529ca57de647fae6
Summary: Often when we're updating mempool entries we update entries that we ultimately end up removing the updated entries shortly thereafter. This patch makes it so that we filter for such entries a bit earlier in processing, which yields a mild improvement for these cases, and is negligible overhead otherwise. Increase limitancestorcount in tournament RPC test to showcase improved algorithm This is a backport of [[bitcoin/bitcoin#21464 | core#21464]] Notes: - I did not see a significant gain for this functional test. If there is any improvement, it is less than the usual variability (+- 10 seconds for a test that takes 220 seconds). - the `policy/mempool.h` include is needed for `DEFAULT_ANCESTOR_LIMIT` and `DEFAULT_ANCESTOR_SIZE_LIMIT` Test Plan: `ninja && ninja check check-functional-extended` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D12589
Often when we're updating mempool entries we update entries that we ultimately end up removing the updated entries shortly thereafter. This patch makes it so that we filter for such entries a bit earlier in processing, which yields a mild improvement for these cases, and is negligible overhead otherwise.
There's potential for a better -- but more sophisticated -- algorithm that can be used taking advantage of epochs, but I figured it is better to do something that is simple and works first and upgrade it later as the other epoch mempool work proceeds as it makes the patches for the epoch algorithm simpler to understand, so you can consider this as preparatory work. It could either go in now if it is not controversial, or we could wait until the other patch is ready to go.