You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposer often gossips the first block parts to all peers #1742
Currently when the proposer creates a block, it will send each block part over the internal message queue. This can actually take a some time. The gossip routine doesn't account for that and will start gossiping immediately, which results in sending the same block parts to all peers instead of sending them randomly.
This is why when we trace the block parts, we often see them downloaded in order. This also defeats the purpose of using block parts entirely, as we end up gossiping the entire block to all peers.
below we can see a diagram that illustrates block propagation for a given height that shows this occuring. on the y axis we have block part indexes, and on the x axis
If we simply wait for the block to go over the internal message queue before gossiping, it fixes the issue and we gossip all of the block parts randomly!
There's still quite a bit of room to optimize which parts we send to each peer. One simple non-breaking change would be to not gossip block parts entirely randomly. Instead, we should keep track of which parts have been sent to any peer, and prefer to send a part to a peer if it has been sent to fewer peers.
While I'm convinced that this was one of the bottlenecks, it certainly isn't the only one since this change still doesn't increase throughput on its own. ATM, I think there's quite a lot of backup occurring, because we frequently end up receiving block parts super late.
the green line is the instance where that node had received all block parts at least once. the block shown above are quite large, but this occurs with smaller blocks as well.
yeah, we've ran similar experiments on it a few weeks ago, but not combined with the above fix. I'll try and get one through today. Interestingly neither of the above actually increases throughput, at least in the experiements we're running.
yeah I've ran a version with the combined fix and unfortunatley we are still hitting the same throughput limitations as before. Nothing we change seems to have an effect on throughput, and bandwidth is not being fully utilized.
another interesting observation is that we can see messages coming in quite late. combined with the fact that bandwidth is not being fully utilized, it seems like there is a clog somewhere. the next step for us I think will be to investigate things lower in the stack to see if they are performing as expected celestiaorg/celestia-core#1162. Then we'll work our way up to see if any queues are getting overloaded or mutexes hit
Would you be able to reproduce this experiment with a branch having the blockPartMessage being propagated as well?
This might alleviate the redundancy, but does not address the problem here. Notice that we are talking about the proposer propagating a block for "the first time". Namely, no one has the block yet, so no one will send us the HasBlockPart message.
The proposer indeed adds the Proposal and all BlockPart messages to the internal message queue. This queue is consumed by the main consensus routine (cs.receiveRoutine). We first accept our own Proposal, which configures the block we are looking for (cs.ProposalBlockParts), then we process each block part in order.
Processing local messages takes time, longer than processing remote messages, because we synchronously persist internal messages to the WAL (cs.wal.WriteSync(mi)). I suspect that this is the main reason for the delay when processing block parts (or between processing different parts).
We need to accept a block part in order to render it available to the consensus gossip layer. Since we have to pay for the cost of persisting each block part before accepting it, the gossip routines will likely find a Proposal to send, then the first block part, then only two block parts (thus sending the second), etc. etc.
yeah I've ran a version with the combined fix and unfortunatley we are still hitting the same throughput limitations as before.
More as a suggestion, having in mind my previous comment: have you tried to not use the WAL to persist consensus messages/events? Notice that since the disk is slower than the network, I wouldn't expect a protocol for the crash-recovery model to be network bound. Moreover, we also have the processing cost of producing/verifying signatures. In other words, I don't expect BFT protocols in general to be network bound.
What we found is that completely disabling the WAL can have up to ~30% positive impact reducing of block latency. The WAL is on the critical path of building/proposing blocks so this is expected, but we didn't know how much of an impact this might have. We expect that in WAN networks where the latency/bandwidth between nodes dominates bigger part of block lifecycle the impact of disabling WAL will be lower than 30%.
Block rate per minute
The two dips on the left side of the white line show the two surges of workload in the experiment with vanilla "With WAL" CometBFT v1.0-alpha.2. The two dips on the right show the workload surges in the setup that has no WAL (commit 090bd49; e2448b9 showed similar but slightly less improvements).
With WAL the average block rate is around 9 blocks per minute during surges
Without WAL, it's 12 blocks per minute
Tx rate per second
Block size bytes
Block size bytes average:
Total transactions cleared
This is the cometbft_consensus_total_txs Prometheus metric.
Blocks tend to be smaller with no WAL, because more blocks are being produced and Comet can clear the client workload faster. The average rate of client workload is 8MB/sec (4kb each transaction * 2000 tx/sec) but tm-load-test adapts to broadcast_tx_response, so the workload rate in reality is never 8MB/sec, but it depends on how fast Comet can clear transactions. In this plot we can see how much better "no WAL" is in terms of total client workload cleared by around ~9K transactions.
Consensus rounds
With no WAL, consensus fails more often to reach decision in round 0.
Some takeaways
With WAL, CometBFT produces bigger blocks, at a slower rate. Without WAL, blocks tend to be smaller, at a faster rate, and with lower incidence of going into round > 0. The total client workload cleared without WAL throughout the experiment run is higher by ~9K transactions.
We will further investigate WAL, but do not expect optimizations to bring significant block latency improvements in production networks
The more important problem we want to tackle on the mid-term is making block production resilient to surges in load: Irrespective of client tx load, as long as the proposer is not faulty/asynchronous, block production should finish in round 0. This is not what happens (see "consensus rounds" plot).
Activity
evan-forbes commentedon Dec 4, 2023
the green line is the instance where that node had received all block parts at least once. the block shown above are quite large, but this occurs with smaller blocks as well.
lasarojc commentedon Dec 5, 2023
Thanks @evan-forbes for sharing these very interesting results. A few questions
blockPartMessagebeing propagated as well?evan-forbes commentedon Dec 6, 2023
heyo :)
I'm using this branch, which is based on v0.34
what is meant by blockPartMessage, do you mean HasProposalBlockPartMessage?
melekes commentedon Dec 6, 2023
This is what he meant I believe
lasarojc commentedon Dec 6, 2023
Yes, that one. Sorry for the typo. I see that you are already considering it
celestiaorg/celestia-core#1079
evan-forbes commentedon Dec 6, 2023
yeah, we've ran similar experiments on it a few weeks ago, but not combined with the above fix. I'll try and get one through today. Interestingly neither of the above actually increases throughput, at least in the experiements we're running.
melekes commentedon Jan 9, 2024
@evan-forbes have you been able to conduct the experiment w/ the fix?
evan-forbes commentedon Jan 9, 2024
yeah I've ran a version with the combined fix and unfortunatley we are still hitting the same throughput limitations as before. Nothing we change seems to have an effect on throughput, and bandwidth is not being fully utilized.
another interesting observation is that we can see messages coming in quite late. combined with the fact that bandwidth is not being fully utilized, it seems like there is a clog somewhere. the next step for us I think will be to investigate things lower in the stack to see if they are performing as expected celestiaorg/celestia-core#1162. Then we'll work our way up to see if any queues are getting overloaded or mutexes hit
ebuchman commentedon Jan 24, 2024
@evan-forbes can you share more about how you're testing and what you're seeing?
For instance are you adjusting proposer timeouts upwards to enable large blocks to be gossipped within a single round?
And are you disabling
recheckin the mempool?1 remaining item
cason commentedon Jan 25, 2024
This might alleviate the redundancy, but does not address the problem here. Notice that we are talking about the proposer propagating a block for "the first time". Namely, no one has the block yet, so no one will send us the
HasBlockPartmessage.cason commentedon Jan 25, 2024
I can intuitively confirm the reported issue.
The proposer indeed adds the
Proposaland allBlockPartmessages to the internal message queue. This queue is consumed by the main consensus routine (cs.receiveRoutine). We first accept our ownProposal, which configures the block we are looking for (cs.ProposalBlockParts), then we process each block part in order.Processing local messages takes time, longer than processing remote messages, because we synchronously persist internal messages to the WAL (
cs.wal.WriteSync(mi)). I suspect that this is the main reason for the delay when processing block parts (or between processing different parts).We need to accept a block part in order to render it available to the consensus gossip layer. Since we have to pay for the cost of persisting each block part before accepting it, the gossip routines will likely find a
Proposalto send, then the first block part, then only two block parts (thus sending the second), etc. etc.cason commentedon Jan 25, 2024
More as a suggestion, having in mind my previous comment: have you tried to not use the WAL to persist consensus messages/events? Notice that since the disk is slower than the network, I wouldn't expect a protocol for the crash-recovery model to be network bound. Moreover, we also have the processing cost of producing/verifying signatures. In other words, I don't expect BFT protocols in general to be network bound.
adizere commentedon Mar 21, 2024
@sergio-mena and @cason did some investigations into disabling the WAL. Example of the two approaches of disabled WAL: 090bd49 & e2448b9.
Experimental setup:
What we found is that completely disabling the WAL can have up to ~30% positive impact reducing of block latency. The WAL is on the critical path of building/proposing blocks so this is expected, but we didn't know how much of an impact this might have. We expect that in WAN networks where the latency/bandwidth between nodes dominates bigger part of block lifecycle the impact of disabling WAL will be lower than 30%.
Block rate per minute
The two dips on the left side of the white line show the two surges of workload in the experiment with vanilla "With WAL" CometBFT v1.0-alpha.2. The two dips on the right show the workload surges in the setup that has no WAL (commit 090bd49; e2448b9 showed similar but slightly less improvements).
Tx rate per second
Block size bytes
Block size bytes average:
Total transactions cleared
This is the
cometbft_consensus_total_txsPrometheus metric.Blocks tend to be smaller with no WAL, because more blocks are being produced and Comet can clear the client workload faster. The average rate of client workload is 8MB/sec (4kb each transaction * 2000 tx/sec) but tm-load-test adapts to
broadcast_tx_response, so the workload rate in reality is never 8MB/sec, but it depends on how fast Comet can clear transactions. In this plot we can see how much better "no WAL" is in terms of total client workload cleared by around ~9K transactions.Consensus rounds
With no WAL, consensus fails more often to reach decision in round
0.Some takeaways
0. The total client workload cleared without WAL throughout the experiment run is higher by ~9K transactions.0. This is not what happens (see "consensus rounds" plot).cason commentedon Sep 5, 2024
I've come up with a potentially simple and non-intrusive solution (I'd say workaround) for this scenario here: #4009
@evan-forbes , do you mind testing it to see if the results are the expected?
feat(consensus): proposer locks part set until all parts are added (#…
cason commentedon Nov 8, 2024
@evan-forbes, if you don't mind, I'd close this issue given the solution/workaround implemented by #4009.
evan-forbes commentedon Nov 8, 2024
definitely! thanks