Notice do_propagate_statements takes in the oder of seconds, when dealing with a lot of statements (100k)
Do propagate took 4377 ms
Do propagate took 4998 ms
Do propagate took 4703 ms
This is bad for a few reasons:
- It slows the propagation to other peers.
- It keeps the main loop busy for this amount of time.
The main culprit for this is this line of code:
|
let encoded_size = chunk.encoded_size(); |
, which repeatedly encodes all statements after each chunk send.
The fix is to pick a chunk size, so that on the hot path, we don't have repeatedly encode all statements we want send in a loop.