forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvserver: compute MVCCStats in AdminSplit instead of splitTrigger
Previously, we computed MVCC stats for the LHS and RHS of a split in splitTrigger, while holding latches. This resulted in high tail latencies due to foreground work not being able to proceed as long as the split holds these latches. More details in cockroachdb#119499. This change moves some of the stats computation to AdminSplit, where no latches are held. In particular, in AdminSplit, we pre-compute the part of the LHS stats corresponding to user-data spans, and pass that to the splitTrigger. In the splitTrigger, we iterate only over the non-user spans in the range (which are small), and combine the resulting stats with the passed in user stats to arrive at the new LHS stats. The RHS stats are derived by substituting the LHS stats from the total on-disk stats. This computation does not produce 100% correct stats because any writes concurrent with the split may not be attributed correctly to the LHS or RHS. Therefore, both LHS and RHS stats are marked with ContainsEstimates. To prevent the stats from drifting after successive splits, we kick off a stats re-computation in AdminSplit (only if the on-disk stats contain estimates). Thus, each split may introduce some stats estimates, but before doing so it will correct any previous estimates. There are two invariants that the stats computation guarantees: 1. Non-user stats (SysBytes, SysCount, etc.) are always correct. This is because we scan those spans while holding latches. 2. If there are no writes concurrent with the split, the stats are always correct. Fixes: cockroachdb#119499 Release note (performance improvement): Splits no longer hold latches for time proportional to the range size while computing MVCC stats. Instead, MVCC stats are pre-computed before the critical section of the split. As a side effect, the resulting stats are no longer 100% accurate because they may correctly distribute writes concurrent with the split. To mitigate this, and to prevent the stats from drifting after successive splits, the existing stored stats are re-computed and corrected (if needed) as part of the non-critical section of the split.
- Loading branch information
1 parent
4b963ea
commit b59305c
Showing
11 changed files
with
292 additions
and
30 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
Oops, something went wrong.