-
Notifications
You must be signed in to change notification settings - Fork 293
scheduler: Speed up region scanning before table splitting #12222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @hongyunyan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request primarily focuses on refactoring the RegionCache
interface and its mock implementation within the keyspan
package. The goal is to align the mock interface more closely with the actual tikv.RegionCache
behavior, allowing for direct retrieval of tikv.Region
objects. This change simplifies the logic in the regionCountSplitter
by removing redundant region lookups, ultimately improving code clarity and efficiency in how key spans are managed and split based on region information.
Highlights
- RegionCache Interface Update: The
RegionCache
interface incdc/scheduler/internal/v3/keyspan/mock.go
has been refactored. TheListRegionIDsInKeyRange
andLocateRegionByID
methods were removed, and a newLoadRegionsInKeyRange
method was introduced. This new method now directly returns a slice of*tikv.Region
objects, simplifying subsequent data access. - Mock Implementation Refinement: The
mockCache
implementation inmock.go
was updated to conform to the newRegionCache
interface. It now constructstikv.Region
objects, utilizing theunsafe
package to populate the unexportedmeta
field for testing purposes. - Simplified Region Splitting Logic: The
splitter_region_count.go
file was updated to leverage the newRegionCache
interface. This change eliminates the need for separateLocateRegionByID
calls, as thetikv.Region
objects are now directly available, leading to more concise and efficient code for determining span boundaries.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the keyspan splitter to reduce RPCs by using LoadRegionsInKeyRange
instead of fetching region information one by one. This is a solid performance improvement.
} | ||
return false | ||
|
||
// meta.id is not exported, so we use unsafe to access it more easier for test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on this line is inaccurate. It's the region.meta
field that is unexported, not meta.id
. metapb.Region.Id
is an exported field.
// meta.id is not exported, so we use unsafe to access it more easier for test. | |
// region.meta is not exported, so we use unsafe to set it for testing. |
zap.Any("startKey", startKey), | ||
zap.Any("endKey", endKey)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## master #12222 +/- ##
================================================
+ Coverage 55.0752% 55.0802% +0.0050%
================================================
Files 1030 1030
Lines 143235 143545 +310
================================================
+ Hits 78887 79065 +178
- Misses 58553 58667 +114
- Partials 5795 5813 +18 🚀 New features to boost your workflow:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: asddongmen, lidezhu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/retest |
/cherry-pick release-7.5 |
@hongyunyan: new pull request created to branch In response to this:
Instructions 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. |
/cherry-pick release-8.1 |
/cherry-pick release-8.5 |
@hongyunyan: new pull request created to branch In response to this:
Instructions 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. |
@hongyunyan: new pull request created to branch In response to this:
Instructions 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. |
What problem does this PR solve?
Issue Number: close #12221
What is changed and how it works?
use
LoadRegionsInKeyRange
instead ofListRegionIDsInKeyRange
to speed up the region scanning performanceCheck List
Tests
We make a tidb cluster with nearly 5w regions(region size is 5MB)
After optimization, the time cost of scanning regions reduce to 450ms from 10s.
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note