Skip to content
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: Make mempool.update release a mutex for Reap earlier #6232

Closed
4 tasks
ValarDragon opened this issue Mar 10, 2021 · 4 comments
Closed
4 tasks

mempool: Make mempool.update release a mutex for Reap earlier #6232

ValarDragon opened this issue Mar 10, 2021 · 4 comments
Labels
C:mempool Component: Mempool stale for use by stalebot

Comments

@ValarDragon
Copy link
Contributor

ValarDragon commented Mar 10, 2021

Summary

Make the clist_mempool release a write lock suitable for reaping early once its recheck'd MaxBlockBytes worth of txs.

Currently the clist_mempool has an update mutex that gets write-locked when you receive a new block, and readlocked when receiving a new tx and when proposing a block. This design makes it risky for validators to have large mempool sizes if the application has a notable tx recheck time.

However there is not that much contention between any of these methods. Instead we could make more granular locks to capture where contention is possible. The needs we have are:

  • Update rechecks and potentially removes each tx, starting from the beginning and going to the end of the list.
  • Reap needs the first MaxBytes worth of txs to be free.
  • CheckTx checks a Tx and appends it to the end of the clist.

We can mitigate the contention between update and reap by having Update make a separate write lock on the first max bytes worth of txs until its done with that many bytes. (So the release conditions are recheck finishes the entire mempool, or MaxTxBytes have passed recheck) Then reap only depends on the write lock for the first max bytes worth of txs.

We can still keep CheckTx write locked as before. It is possible that we could deflate the lock contention for CheckTx, but I think approaches to do so for the current clist_mempool will not be useful for future prioritized mempools, hence I don't suggest doing so now. I do think lower the conflation in locks for Update and Reap will be useful even in future prioritized mempool designs. (E.g. the lock free mempool proposed in #2147)

This issue arose from ABCI++ discussions, but is not related to ABCI++.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@tessr tessr added the C:mempool Component: Mempool label Apr 29, 2021
@tessr tessr added this to Untriaged 🥚 in Tendermint Core Project Board via automation Apr 29, 2021
@tessr tessr moved this from Untriaged 🥚 to To Do 📝 in Tendermint Core Project Board Apr 29, 2021
@tessr tessr added this to the v0.35 milestone Apr 29, 2021
@alexanderbez
Copy link
Contributor

alexanderbez commented Jun 29, 2021

What's the concrete proposal here @ValarDragon? The Reap* methods obtain read-lock automatically, whereas Update requires the caller to explicitly acquire a write-lock via Lock.

@ValarDragon
Copy link
Contributor Author

Its to change the write lock for update to be managed internally to the method, and to instead be semantically changed into two different write locks, one for the first MaxBytes worth of txs, and the second for all remaining txs. Then Reap's read lock only needs to get a lock on the first MaxBytes worth of txs, not all txs.

This makes larger mempool sizes then safe for apps with long rechecks

@alexanderbez
Copy link
Contributor

How much of a priority or necessity do you think this is @ValarDragon? Does this help Osmosis? If so, in what ways? Do you have benchmarks?

@ValarDragon
Copy link
Contributor Author

This is not at all a significant issue, nor really relevant to osmosis / gaia imo beyond a general desire to safely allow for larger mempools.

This is something that came up as a side-idea on one of the ABCI++ calls.

@alexanderbez alexanderbez removed this from the v0.35 milestone Jul 13, 2021
@github-actions github-actions bot added the stale for use by stalebot label Jul 16, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:mempool Component: Mempool stale for use by stalebot
Projects
No open projects
Development

No branches or pull requests

3 participants