Skip to content

Proposer often gossips the first block parts to all peers #1742

Closed

Description

@evan-forbes

ref celestiaorg/celestia-core#1145

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

broken_proposer

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.

fixed_proposer

Activity

  1. evan-forbes commented on Dec 4, 2023

    @evan-forbes
    Author

    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.

  2. lasarojc commented on Dec 5, 2023

    @lasarojc
    Contributor

    Thanks @evan-forbes for sharing these very interesting results. A few questions

    • Which version of the software are you using?
    • Would you be able to reproduce this experiment with a branch having the blockPartMessage being propagated as well?
  3. added
    needs-triage
    on Dec 5, 2023
  4. evan-forbes commented on Dec 6, 2023

    @evan-forbes
    Author

    heyo :)

    I'm using this branch, which is based on v0.34

    what is meant by blockPartMessage, do you mean HasProposalBlockPartMessage?

  5. melekes commented on Dec 6, 2023

    @melekes
    Collaborator

    what is meant by blockPartMessage, do you mean HasProposalBlockPartMessage?

    This is what he meant I believe

  6. lasarojc commented on Dec 6, 2023

    @lasarojc
    Contributor

    heyo :)

    I'm using this branch, which is based on v0.34

    what is meant by blockPartMessage, do you mean HasProposalBlockPartMessage?

    Yes, that one. Sorry for the typo. I see that you are already considering it
    celestiaorg/celestia-core#1079

  7. evan-forbes commented on Dec 6, 2023

    @evan-forbes
    Author

    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.

  8. added
    needs-information
    on Jan 9, 2024
  9. melekes commented on Jan 9, 2024

    @melekes
    Collaborator

    I'll try and get one through today.

    @evan-forbes have you been able to conduct the experiment w/ the fix?

  10. evan-forbes commented on Jan 9, 2024

    @evan-forbes
    Author

    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

  11. added this to the 2024-Q2 milestone on Jan 24, 2024
  12. ebuchman commented on Jan 24, 2024

    @ebuchman
    Contributor

    @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 recheck in the mempool?

  13. 1 remaining item

  14. cason commented on Jan 25, 2024

    @cason

    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.

  15. cason commented on Jan 25, 2024

    @cason

    I can intuitively confirm the reported issue.

    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.

  16. added
    enhancement
    and removed
    needs-triage
    needs-information
    on Jan 25, 2024
  17. cason commented on Jan 25, 2024

    @cason

    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.

  18. adizere commented on Mar 21, 2024

    @adizere
    Contributor

    @sergio-mena and @cason did some investigations into disabling the WAL. Example of the two approaches of disabled WAL: 090bd49 & e2448b9.

    Experimental setup:

    • 10 nodes, all validators
    • colocated in the same DO datacenter, so network latency is very low and throughput very high
    • transaction size 4kb
    • block max size 100mb
    • experiment manifest gist

    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
    block-rate

    Tx rate per second

    tx-rate

    Block size bytes

    Screenshot 2024-03-21 at 21 33 38

    Block size bytes average:

    Screenshot 2024-03-21 at 21 34 30

    Total transactions cleared

    This is the cometbft_consensus_total_txs Prometheus metric.

    total-tx-cleared

    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

    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).
  19. removed this from the 2024-Q2 milestone on Jul 4, 2024
  20. cason commented on Sep 5, 2024

    @cason

    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?

  21. self-assigned this
    on Sep 5, 2024
  22. cason commented on Nov 8, 2024

    @cason

    @evan-forbes, if you don't mind, I'd close this issue given the solution/workaround implemented by #4009.

  23. evan-forbes commented on Nov 8, 2024

    @evan-forbes
    Author

    definitely! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

consensusenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions