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

*: speed up create table and reduce memory usage when the number of tables is relatively large #49371

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

zimulala
Copy link
Contributor

@zimulala zimulala commented Dec 12, 2023

What problem does this PR solve?

Issue Number: close #49370

Problem Summary:
ListTables took a lot of time when the number of tables was relatively large

What changed and how does it work?

Because the unmarshal of the TableInfo structure takes a large proportion of time, we only needn't all structures of the TableInfo. So we use TableNameInfo instead of it.

Check List

Tests

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

Memory usage
Before this PR, when the 113k table is created, TiDB OOM (14G+) appears.
After this PR, the maximum memory of TiDB is nearly 6.9G when creating 113k tables, and the maximum memory usage is 11G when 400k tables are created

Time taken
Execute checkTableNotExistsFromStore function consumption of time.

Total Table Count Current DB Table Count Master Branch Take Time After this PR Table Time
437k 215k 23-26s 12-14s

Master branch info:
截屏2023-12-12 14 56 09

截屏2023-12-12 15 15 27

After this PR info(The middle area is particularly high because the owner of another service is transferred):
截屏2023-12-12 14 56 16

截屏2023-12-12 15 15 19
  • 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 12, 2023
Copy link

tiprow bot commented Dec 12, 2023

Hi @zimulala. 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/test-infra repository.

Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Merging #49371 (56410e3) into master (9e34417) will increase coverage by 0.5482%.
Report is 42 commits behind head on master.
The diff coverage is 60.8695%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49371        +/-   ##
================================================
+ Coverage   71.0590%   71.6073%   +0.5482%     
================================================
  Files          1368       1417        +49     
  Lines        401946     424599     +22653     
================================================
+ Hits         285619     304044     +18425     
- Misses        96463     101586      +5123     
+ Partials      19864      18969       -895     
Flag Coverage Δ
integration 44.3091% <60.8695%> (?)
unit 71.0589% <ø> (-0.0001%) ⬇️

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 47.2682% <ø> (-5.6933%) ⬇️

@pingcap pingcap deleted a comment from ti-chi-bot bot Dec 12, 2023
Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12-14s is still not good enough IMO 🤔 Can you leave the issue open? Maybe others can try different solutions for it.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 12, 2023
@zimulala
Copy link
Contributor Author

12-14s is still not good enough IMO 🤔 Can you leave the issue open? Maybe others can try different solutions for it.

This is a solution with relatively small changes and relatively large benefits. As for the other possible optimizations, they are more complex (the root cause may be JSON unmarshal problems) and may not have a good solution in the short term. Subsequent optimization may be more like #19177.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 13, 2023
Copy link

ti-chi-bot bot commented Dec 13, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-12 09:50:40.590817187 +0000 UTC m=+349731.628044116: ☑️ agreed by lance6716.
  • 2023-12-13 02:33:43.971681022 +0000 UTC m=+409915.008907949: ☑️ agreed by tiancaiamao.

@zimulala
Copy link
Contributor Author

/rebuild

Copy link

ti-chi-bot bot commented Dec 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: crazycs520, Defined2014, lance6716, okJiang, tangenta, tiancaiamao

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Dec 13, 2023
@zimulala
Copy link
Contributor Author

/retest-required

Copy link

tiprow bot commented Dec 14, 2023

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

In response to this:

/retest-required

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit 918df0a into pingcap:master Dec 14, 2023
@zimulala zimulala deleted the zimuxia/check-tbls branch December 14, 2023 04:02
@zimulala zimulala changed the title *: speed up create table when the number of tables is relatively large *: speed up create table and reduce memory usage when the number of tables is relatively large Dec 22, 2023
@3AceShowHand 3AceShowHand added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label May 24, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #53545.

@Benjamin2037 Benjamin2037 added the affects-7.5 This bug affects the 7.5.x(LTS) versions. label May 27, 2024
ti-chi-bot bot pushed a commit that referenced this pull request May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.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.

Speed up create table when the number of tables is relatively large, and reduce memory usage
10 participants