Apply doc-count batching policy to transactions before pipelining #1808
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.
Problem
In #1762 pipelining was introduced during indexing from the golden stores. This improves IO resource utilisation and delivers a substantial improvement to ingest throughput.
However one implication is that document stores can receive a much higher set of ids to fetch a time, because now the documents for many transactions are fetched at once. There is some concern ( #1800 ) that the increased concurrent request volume may be triggering errors or breaching request-per-second limits.
Solution
This PR then represents an early mitigation strategy that attempts to allow some transaction batching while putting some limits on the number of fetches document stores will be requested to do in a single eager operation.
The mechanism added batches transactions according to number of referenced docs, so that many small transactions can benefit from a lot of batching together, but larger transactions will be issued in smaller batches.
Note that a single transaction can reference any number of documents, and so for large enough transactions this PR will not help - however that issue will have been around pre #1762.
This represents a tactical, speculative change and may not resolve the S3 / R2 problem raised in #1800. Further benchmarks are necessary to determine what impact the batching policy has on overall ingest throughput, though due to the lack of any batching prior to #1762, I assume no performance regression.
Configuration
A configuration variable is available to vary the ideal batch doc-count on the ingester:
:batch-preferred-doc-count
.I would consider this variable a temporary tuning parameter we can use early on while testing but I would not consider it part of the configuration surface of XTDB.