-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
113809: kvstreamer: add limit to how many eager batches are issued r=yuzefovich a=yuzefovich **kvstreamer: add limit to how many eager batches are issued** This commit fixes extremely suboptimal behavior of the streamer in the InOrder mode in some cases. In particular, previously it was possible for the buffered responses to consume most of the working budget, so the streamer would degrade to processing all requests effectively one BatchRequest with one Get / Scan at a time, significantly increasing the latency. For example, the query added as a regression test that performs 30k Gets across 10 ranges would usually take on the order of 1.5s (which is not great already since in the non-streamer path it takes 400ms), but in the degenerate cases it could be on the order of 20-30s. Similar behavior could occur in the OutOfOrder mode too where we would issue more BatchRequests in which only one request could be satisfied (although in OutOfOrder mode the problem is not as severe - we don't buffer any results since we can always return them right away). This problem is now fixed by imposing the limit on the budget's usage at which point the streamer stops issuing "eager" requests. Namely, now, when there is at least one request in flight, the streamer won't issue anymore requests once `limit * eagerFraction` is exceeded. This effectively reserves a portion of the budget for the "head-of-the-line" batch. The "eager fraction" is controlled by a session variable, separate for each mode. The defaults of 0.5 for InOrder and 0.8 for OutOfOrder modes were chosen after running TPCH queries and the query that inspired this commit. These values bring the number of gRPC calls for the reproduction query from 1.5k-2k range to below 200 and the query latency to be reliably around 400ms. I don't really see any significant downsides to this change - in the worst case, we'd be utilizing less of the available memory budget which is not that big of a deal, so I intend to backport this change. Also, setting the eager fractions to large values (greater than 1.0 is allowed) would disable this limiting behavior and revert to the previous behavior if we need it. Fixes: #113729. Release note (bug fix): Previously, when executing queries with index / lookup joins when the ordering needs to be maintained, CockroachDB in some cases could get into a pathological behavior which would lead to increased query latency, possibly by 1 or 2 orders of magnitude. This bug was introduced in 22.2 and is now fixed. **kvstreamer: increase default avg response multiple** This commit increases the default value for `sql.distsql.streamer.avg_response_size_multiple` cluster setting from 1.5 to 3.0. This setting controls the factor by which the current "avg response size" estimate is multiplied and allows for TargetBytes parameter to grow over time. In the reproduction query from the previous commit it was determined that the growth might not be as quick as desirable. The effect of this change is as follows: - if we have responses of varying sizes, then we're now likely to be more effective since we'll end up issuing less BatchRequests - if we have responses of similar sizes, then we might pre-reserve too much budget upfront, so we'll end up with lower concurrency across ranges. Thus, we don't want to increase the multiple by too much; however, keeping it at 1.5 can be quite suboptimal in some cases - 3.0 seems like a decent middle ground. This number was chosen based on running TPCH queries (both via InOrder and OutOfOrder modes of the streamer) and the reproduction query. (For the latter this change reduces the number of gRPC calls by a factor of 3 or so.) Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
- Loading branch information
Showing
15 changed files
with
210 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.