server/cluster: avoid repeated region size scans (#11072) - #11158
server/cluster: avoid repeated region size scans (#11072)#11158ti-chi-bot wants to merge 2 commits into
Conversation
ref tikv#9574 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
This cherry pick PR is for a release branch and has not yet been approved by triage owners. To merge this cherry pick:
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@lhy1024 This PR has conflicts, I have hold it. |
|
@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: lhy1024 <19542290+lhy1024@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Cherry-pick conflicts appear resolved; removing the |
This is an automated cherry-pick of #11072
What problem does this PR solve?
When multiple stores are in the Preparing state, PD recalculates the same
region sizes for every store during each
checkStoresround. With placementrules enabled,
calculateRangealso callsGetRegionSizeByRangeonce forevery matching rule.
For non-empty key ranges, these repeated scans can significantly increase
Region tree lock contention and delay Region heartbeat processing.
Issue Number: ref #9574
What is changed and how does it work?
Limitations
This PR eliminates duplicate range scans across placement rules and Preparing
stores within one
checkStoresround. Each unique non-empty range is stillscanned in O(N) time once per round. Supporting O(log N) range queries or
incremental range-size aggregation will be handled separately.
Check List
Tests
Related changes
Release note
Summary by CodeRabbit
Bug Fixes
Tests