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

perf(consensus): Make late votes outside of last block commits not get to peerMsgQueue #3157

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ValarDragon
Copy link
Collaborator

@ValarDragon ValarDragon commented May 31, 2024

Closes #3154 . Make late votes outside of last blocks precommits not get into the peer msg queue. This lowers the delay for processing more important messages from the peerMsgQueue, and lowers WAL write delays. As noted in the github issue, the number of late votes is actually quite significant.

I don't think theres any test updates needed (all relevant behavior is covered under existing tests. And if you look into the consensus logic, aside from WAL write, all we'd otherwise do is:

		cs.Logger.Debug("vote ignored and not added", "vote_height", vote.Height, "cs_height", cs.Height, "peer", peerID)
                return

We could still do that if we wanted? But doesn't seem that important, since we have the mark late vote still being sent.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

@ValarDragon ValarDragon requested review from a team as code owners May 31, 2024 04:19
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request May 31, 2024
Copy link
Contributor

@cason cason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not spend much resources on messages (any type) which are old and useless for the consensus protocol. So, the goal here is perfectly legit.

But adding the solution to the consensus reactor is not really the best approach. In fact, the consensus reactor should not take the consensus state lock for every received vote, which is super inefficient in any case. While this PR hasn't introduced this behavior, if we really want to decouple reactor and state, this solution goes towards the wrong direction.

I would instead add this check to the state implementation. The goal is anyway to prevent writing this useless vote to the WAL and keeping the consensus lock for longer than needed.

internal/consensus/reactor.go Show resolved Hide resolved
@ValarDragon
Copy link
Collaborator Author

ValarDragon commented Jun 10, 2024

But adding the solution to the consensus reactor is not really the best approach. In fact, the consensus reactor should not take the consensus state lock for every received vote, which is super inefficient in any case. While this PR hasn't introduced this behavior, if we really want to decouple reactor and state, this solution goes towards the wrong direction.

My thinking right now is that we can get the lock removed with #3211 , and then have this able to proceed concurrently (not under the single threaded state.go workload). So we would rather it happen in the reactor

ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request Jun 15, 2024
ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request Jun 17, 2024
ValarDragon added a commit to osmosis-labs/cometbft that referenced this pull request Jun 17, 2024
* Backport cometbft#3211

* Fix Race

* bp cometbft#3157

* Speedup tests that were hitting timeouts

* bp cometbft#3161

* Fix data race

* Mempool async processing

* Forgot to commit important part

* Add changelog
czarcas7ic pushed a commit to osmosis-labs/cometbft that referenced this pull request Jun 19, 2024
* Backport cometbft#3211

* Fix Race

* bp cometbft#3157

* Speedup tests that were hitting timeouts

* bp cometbft#3161

* Fix data race

* Mempool async processing

* Forgot to commit important part

* Add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make late votes not enter consensus peer msg queue
3 participants