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

privilege: reuse chunk in loadTable function #59821

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #55563

Problem Summary:

What changed and how does it work?

chunk.Renew cause more allocations and wastes memory, change the code from chunk.Renew to req.GrowAndReset(1024)

strings.Clone is required in decodeTableRow functions.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Modify the code to call LoadSomeUsers manually, the database have 2M users and load 1/10 of them.

 func (e *ShowExec) fetchShowEngines(ctx context.Context) error {
+       fmt.Println("!!!!!!!")
        ctx = kv.WithInternalSourceType(ctx, kv.InternalTxnMeta)
-       exec := e.Ctx().GetRestrictedSQLExecutor()
+       // exec := e.Ctx().GetRestrictedSQLExecutor()
+
+       // rows, _, err := exec.ExecRestrictedSQL(ctx, nil, `SELECT * FROM information_schema.engines`)
+       // if err != nil {
+       //      return errors.Trace(err)
+       // }
+       // e.result.AppendRows(rows)
 
-       rows, _, err := exec.ExecRestrictedSQL(ctx, nil, `SELECT * FROM information_schema.engines`)
+       p := privileges.NewMySQLPrivilege()
+       userList := make(map[string]struct{}, 200000)
+       for i:=1000000; i< 1200000; i++ {
+               userList[fmt.Sprintf("test%d", i)] = struct{}{}
+       }
+       err := p.LoadSomeUsers(e.Ctx().GetSQLExecutor(), userList)
        if err != nil {
                return errors.Trace(err)
        }
 
-       e.result.AppendRows(rows)
        return nil
 }

Compare the memory usage before vs after:
image

And compare the heap alloc_space before vs after:

image image
  • 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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 27, 2025
Copy link

tiprow bot commented Feb 27, 2025

Hi @tiancaiamao. 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 Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.7946%. Comparing base (67edd7d) to head (20bbed4).
Report is 47 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59821        +/-   ##
================================================
+ Coverage   72.9760%   73.7946%   +0.8186%     
================================================
  Files          1699       1703         +4     
  Lines        469387     476571      +7184     
================================================
+ Hits         342540     351684      +9144     
+ Misses       105739     103630      -2109     
- Partials      21108      21257       +149     
Flag Coverage Δ
integration 42.9152% <100.0000%> (?)
unit 72.6364% <100.0000%> (+0.4582%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 47.6816% <ø> (+2.6591%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tiancaiamao
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Feb 27, 2025

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 7, 2025
Copy link

ti-chi-bot bot commented Mar 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CbcWestwolf, lcwangchao

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:
  • OWNERS [CbcWestwolf,lcwangchao]

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 10, 2025
Copy link

ti-chi-bot bot commented Mar 10, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-07 07:47:50.161679523 +0000 UTC m=+600583.290599271: ☑️ agreed by lcwangchao.
  • 2025-03-10 05:43:32.143219991 +0000 UTC m=+161767.748748918: ☑️ agreed by CbcWestwolf.

@ti-chi-bot ti-chi-bot bot merged commit b72ff3b into pingcap:master Mar 10, 2025
24 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Mar 10, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #59981.
But this PR has conflicts, please resolve them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants