-
Notifications
You must be signed in to change notification settings - Fork 2k
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
improve performance of total_mempool_fees()
and total_mempool_cost()
#17107
Conversation
Pull Request Test Coverage Report for Build 7290982749
💛 - Coveralls |
It may be worth to run the profiler with these 3 pragma changes as well, if you haven't tried them. cache_size journal_mode temp_store def __init__(self, mempool_info: MempoolInfo, fee_estimator: FeeEstimatorInterface):
self._db_conn = sqlite3.connect(":memory:")
self._items = {}
self._block_height = uint32(0)
self._timestamp = uint64(0)
with self._db_conn:
self._db_conn.execute("PRAGMA cache_size = -200000;")
self._db_conn.execute("PRAGMA journal_mode = OFF;")
self._db_conn.execute("PRAGMA temp_store = 2;") |
@neurosis69 the mempool's sqlite database is |
my understanding is that a |
I'm with you, it doesn't sound reasonable but there are still some hints in the documentation, that's why I asked. For instance, this info is from the journal_mode parameter:
If it's safe to deactivate it I'd guess that a lots of sqlite internal code is skipped. |
|
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, I think we're only missing accounting for (and covering) the case of removing conflicting transactions when adding a transaction.
a9826db
to
a2bb610
Compare
thanks for the review! I've updated it to move the accounting into |
f56f79d
to
0752d8c
Compare
d774255
to
3a0e4ce
Compare
3a0e4ce
to
8c282e1
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
1 similar comment
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
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.
aok
…()` (Chia-Network#17107) * improve performance of total_mempool_fees() and total_mempool_cost() * log when updating the mempool using the slow-path * extend test to ensure total-cost and total-fee book-keeping stays in sync with the DB * lower mempool size from 50 blocks to 10 blocks
Purpose:
Currently, the mempool asks sqlite what the total cost and total fees are of the items in the mempool. This is very reliable as all the book-keeping is done by sqlite. However, it's also slow. It appears sqlite does not maintain these sums continuously, but actually computes them every time we ask.
This patch adds "manual" book-keeping of the total cost and total fees in the mempool, avoiding a SQL query every time we want to know.
Current Behavior:
total_mempool_fees()
andtotal_mempool_cost()
are expensive calls.New Behavior:
total_mempool_fees()
andtotal_mempool_cost()
are cheap calls.profiles
Before
After