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

Storage: Fix DataTypePtr is not shared as expected (#9939) #9952

Open
wants to merge 5 commits into
base: release-8.5
Choose a base branch
from

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #9939

What problem does this PR solve?

Issue Number: close #9947

Problem Summary:

There are about 13,000 tables with 60 enum column in each table, turning into 780,000 DataTypeEnum instances. They takes about 4GB memory.

What is changed and how it works?

before_share_enum.svg.zip
after_share_enum.svg.zip

Storage: Fix DataTypePtr is not shared as expected
* Introduce a class `DataTypePtrCache` and manage the shared cache of `DataTypePtr` instances.
* Introduce `DataTypeFactory::getOrSet(const ASTPtr & ast)` and try to find the cache with data type name as "ast->range.first, ast->range.second"
logging: Turn the logging level of "updateTableColumnInfo" into debug because that could cause lots of logging when restarting tiflash 

Check List

Tests

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

Create 36,000 table with schema like

CREATE TABLE IF NOT EXISTS enum_tbl_000 ( field1 VARCHAR(255), field2 VARCHAR(255), field3 VARCHAR(255),  enum1 ENUM('T', 'F'), enum2 ENUM('T', 'F'), enum3 ENUM('T', 'F'), enum4 ENUM('T', 'F'), enum5 ENUM('T', 'F'), enum6 ENUM('T', 'F'), enum7 ENUM('T', 'F'), enum8 ENUM('T', 'F'), enum9 ENUM('T', 'F'), enum10 ENUM('T', 'F'), enum11 ENUM('T', 'F'), enum12 ENUM('T', 'F'), enum13 ENUM('T', 'F'), enum14 ENUM('T', 'F'), enum15 ENUM('T', 'F'), enum16 ENUM('T', 'F'), enum17 ENUM('T', 'F'), enum18 ENUM('T', 'F'), enum19 ENUM('T', 'F'),  enum20 ENUM('pending', 'running', 'finished', 'failed'), enum21 ENUM('DEFAULT', 'ALL', 'PREDICATE', 'LIST'), enum22 ENUM('NONE', 'READ', 'INTEND', 'WRITE') ) DEFAULT CHARSET=utf8mb4;

Check the memory consumption without/with this fix. From 13:40 to 13:45, without this fix, tiflash consume 15GB memory. From 13:45 to 13:55, with this fix, tiflash consume 8GB memory.
image

  • No code

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

Fix the issue that TiFlash may consume lots of memory when there are many `ENUM` columns on TiDB

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Mar 6, 2025
Copy link
Contributor

ti-chi-bot bot commented Mar 6, 2025

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be approved by the approvers firstly.
  2. AFTER it has been approved by approvers, please wait for the cherry-pick merging approval from triage owners.

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
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

ti-chi-bot bot commented Mar 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo

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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 7, 2025
Copy link
Contributor

ti-chi-bot bot commented Mar 7, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-07 02:50:35.864000293 +0000 UTC m=+582748.992920037: ☑️ agreed by CalvinNeo.

@ti-chi-bot ti-chi-bot bot added the approved label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved do-not-merge/cherry-pick-not-approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants