feat: use a separate limit for the ingress payload #7441
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.
Background
Currently, when building a block we make sure that the included payload, which consists of ingress messages, xnet messages, etc, doesn't exceed 4MB. The main reason for enforcing the bound is that we want the blocks to be small enough so that they are delivered relatively quickly to enough peers. If, for example, it takes longer than 1 second to deliver a rank-0 block to enough peers, a rank-1 block could be meanwhile proposed and notarized, potentially leading to forks and decreased finalization rate.
With the hashes-in-blocks feature being enabled since the end of last year, delivering a block full of ingress messages is much faster now- even if a block maker proposes a block with 4MB of ingress messages, what it sends over the wire is much smaller than that, meaning that the bandwidth is not so easily saturated.
Since the introduction of Caffeine.ai, some subnets have been under heavy ingress messages load. Upon inspecting the internal metrics, we have often seen that the blocks are completely full and we could have delivered more messages to the execution, if only the block's size limits had been bigger.
Proposal
In this PR we propose to change the way we limit the size of the ingress payload. To be more precise, we propose to have two limits in place instead of just one:
memory_limit, which would limit how big the ingress payload is when stored in memory. Note, that in this PR we set thememory_limitto a constant value of8MB.wire_limit, which would limit how big the ingress payload is when sent over a wire. Note, that with hashes-in-blocks feature, we only send the ids ingress messages as part of the ingress payload. Thewire_limitis adjusted dynamically, depending on how much other data (such as xnet messages) the block already contains.Results
We've ran several benchmarks to evaluate what kind of throughput we can expect on a healthy subnet with 13 nodes.
Setup
2000 msgs per sec, 8KiB each, 4 canisters
40 msgs per sec, 0.5MB each, 4 canisters