-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add zcash.mempool.size.transactions and zcash.mempool.size.bytes metrics #2860
Conversation
The code in this PR seems like it will always give the correct mempool serialized size. But there's some risk that we'll refactor the code, and forget to add or remove the size when changing the mempool transactions. But I think the (If we ever have a bug, we can wrap the set in a type that updates the size and metrics when the set changes.) |
@dconnolly I just noticed that this calculation is very similar to the eviction weight from ZIP-401 in #2780. So we might want to merge this PR pretty quickly to avoid conflicts. |
c500f19
to
10c370b
Compare
I've moved this PR out of draft and will keep working on the remaining metrics in a separate PR to make that easier. |
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.
Is it effective to, instead of tracking a separate size value from the source of truth, the transactions in the verified set itself, iterate over all the tx's in the verified set, and add up their sizes? Looks like they are pre-calculated on each UnminedTx
already (which is not my favorite for the same reasons but it exists now so). There can be a method size()
on VerifiedSet
that is then called by the update_metrics()
method.
That's the alternative, but a bit inefficient. I don't really know if that's a problem or not. It could mean iterating ~20K times (per ZIP-401 limits) each time a transaction is inserted or removed in the mempool which seems bad, on the other hand the mempool should be usually much smaller. |
Yeah if Zcash average mempool were / gets larger, it would be inefficient, but it seems like our mainnet mempool has single-digit counts of transactions most of the time, maybe we can get away with this for the time being and not have to worry about a refactor misaligning these tracker values |
I've also just learned that |
Ah careful, we are currently using a fork of |
I've implemented the on-the-fly computation in 4402cda Feel free to tinker with the PR (i.e. revert that commit if the old approach ends up being chosen) to speed things up during the next hours, I don't want to block further work that depends on this 😁 |
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.
Awesome 😁
ZIP-401 is designed for denial of service prevention. If we want a more reliable API, we could wrap the set in a type that updates the size and metrics when the set changes. |
Motivation
We need metrics for the mempool per #2626
Specifications
Designs
Solution
Add zcash.mempool.size.transactions and zcash.mempool.size.bytes metrics (see #2626 )
It's part of #2626, but does not closes it.
Review
Just a draft to show the current work, and a question: is it worthwhile to track
transactions_serialized_size
in this slightly error-prone way to avoid iterating the entire list to compute the total size every time?#2780 uses the total size of transactions of the mempool which is tracked by the code in this PR, so @dconnolly might want to review this soon.
Reviewer Checklist
Follow Up Work
Remaining metrics will be done in a separate PR.