node/consensus: priority lock for CE business to preempt tx influx #1430
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds
node/consensus.PriorityLock
that is like a normal mutex but:Lock
guarantees FIFO when acquired, no issues with sleeping goroutines in thesync.Mutex
breaking orderingPriorityLock
jumps the line, getting the lock ahead of others that usedLock
This is intended in the very specific use case of CE where the
mempoolMtx
was locked in:commit
: block commit, priorityprepareBlockProposal
: leader preparing block proposal, priorityQueueTx
: ingest new tx from either p2p announce or RPC broadcast, NOT priorityAll of the "priority" cases are sequential, never concurrent with each other. Only the
QueueTx
spot can be concurrent and at any time, as it is triggered from external sources.This eliminate the one bad spot of mutex contention revealed by running (for a brief period) with
--profile-mode=mutex
while stress tool is flooding the network.