Skip to content
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

planner,util/ranger: reduce mem allocs on rebuildRange #58362

Closed
wants to merge 2 commits into from

Conversation

zyguan
Copy link
Contributor

@zyguan zyguan commented Dec 18, 2024

What problem does this PR solve?

Issue Number: ref #56649

Problem Summary: A lot of small objects will be allocated when rebuildRange, which leads to notable runtime overhead. See the following cpu profile of a index-scan workload (nearly half of rebuildRange time is spent on mallocgc).

image

2024-12-18_100758
2024-12-18_100816

What changed and how does it work?

Introduce a planctx level allocator for allocating/reusing range releated objects, includes:

  • internal point
  • small []*point (len <= 4)
  • common Range converted from points (with single low/high value)

After this PR, the cpu profile of the same benchmark can be:

image

2024-12-18_101955

The heap alloc metrics are shown as the following:

image

Here are benchmark results:

workload threads baseline this PR diff
idxscan 30 44223.97 44990.54 1.7%
idxscan 60 49583.53 50980.52 2.8%
idxscan 120 50929.30 52141.18 2.4%

The idxscan workload executes select id from sbtest1 where k between {N} and {N+10} on sysbench oltp dataset.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: zyguan <zhongyangguan@gmail.com>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Dec 18, 2024
Copy link

ti-chi-bot bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign rustin170506 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

tiprow bot commented Dec 18, 2024

Hi @zyguan. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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 kubernetes-sigs/prow repository.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 80.89172% with 60 lines in your changes missing coverage. Please review.

Project coverage is 73.6063%. Comparing base (cea46f1) to head (880415e).
Report is 74 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58362        +/-   ##
================================================
+ Coverage   73.2259%   73.6063%   +0.3803%     
================================================
  Files          1675       1675                
  Lines        462254     466298      +4044     
================================================
+ Hits         338490     343225      +4735     
+ Misses       102989     102226       -763     
- Partials      20775      20847        +72     
Flag Coverage Δ
integration 43.2124% <80.8917%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 46.0470% <ø> (+0.0090%) ⬆️

Signed-off-by: zyguan <zhongyangguan@gmail.com>
Copy link

ti-chi-bot bot commented Dec 18, 2024

@zyguan: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 880415e link true /test unit-test

Full PR test history. Your PR dashboard.

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@zyguan zyguan marked this pull request as draft December 18, 2024 03:37
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 18, 2024
@winoros
Copy link
Member

winoros commented Dec 23, 2024

The plan cache is going to be instance level. I think this is not resonable for instance level plan cache?

@zyguan
Copy link
Contributor Author

zyguan commented Dec 24, 2024

The plan cache is going to be instance level. I think this is not resonable for instance level plan cache?

I'm not sure, but the instance-level plan cache also need to adjustCachedPlan -> RebuildPlan4CachedPlan -> rebuildRange, right?

This is a draft PR to show the issue of util/ranger, a possible solution and the improvement can be archived by it. After discussing with @cfzjywxk and @qw4990 , we think the risk of this PR outweighs the benefits, so no plan to move forward.

@zyguan zyguan closed this Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants