Skip to content

dxf: calculate max_node_count and concurrency for next-gen automatically | tidb-test=pr/2584#62995

Merged
ti-chi-bot[bot] merged 28 commits into
pingcap:masterfrom
tangenta:next-gen-calc-auto
Aug 22, 2025
Merged

dxf: calculate max_node_count and concurrency for next-gen automatically | tidb-test=pr/2584#62995
ti-chi-bot[bot] merged 28 commits into
pingcap:masterfrom
tangenta:next-gen-calc-auto

Conversation

@tangenta

@tangenta tangenta commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

What changed and how does it work?

  • Forbid setting tidb_max_dist_task_nodes in next-gen.
  • Calculate the node count and concurrency automatically according to the data size for add index and import into.
  • Add table size estimation by scanning regions.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    TBD
  • 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 14, 2025
@tiprow

tiprow Bot commented Aug 14, 2025

Copy link
Copy Markdown

Hi @tangenta. 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.

Details

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.

@codecov

codecov Bot commented Aug 14, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.63492% with 137 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.8622%. Comparing base (dd5f5ad) to head (cbfe9fe).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #62995        +/-   ##
================================================
+ Coverage   72.7739%   74.8622%   +2.0883%     
================================================
  Files          1810       1872        +62     
  Lines        493564     509565     +16001     
================================================
+ Hits         359186     381472     +22286     
+ Misses       112542     104602      -7940     
- Partials      21836      23491      +1655     
Flag Coverage Δ
integration 48.5778% <28.5714%> (?)
unit 72.3388% <45.6349%> (+0.1143%) ⬆️

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1914% <ø> (+16.8868%) ⬆️
🚀 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.

@D3Hunter

Copy link
Copy Markdown
Contributor

other reorg DDLs which not run on DXF also need tidb_ddl_reorg_worker_cnt to set concurrency, such as lossy modify column, we need allow it changed by user

Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Comment thread pkg/disttask/framework/scheduler/autoscaler.go Outdated
Comment thread pkg/disttask/framework/scheduler/autoscaler.go Outdated
Comment thread pkg/ddl/reorg_util.go Outdated
Comment thread pkg/ddl/reorg_util.go
Comment thread pkg/ddl/reorg_util.go

func estimateTableSizeByID(ctx context.Context, pdCli pdhttp.Client, pid int64) (int64, error) {
sk, ek := tablecodec.GetTableHandleKeyRange(pid)
sRegion, err := pdCli.GetRegionByKey(ctx, codec.EncodeBytes(nil, sk))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why we cannot use the previous sk, ek directly, and use the one get from PD region?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there are specific reasons, this logic is copied from getRegionsInfoForSingleTable. Maybe I can ask the author later.

Comment thread pkg/disttask/framework/scheduler/autoscaler.go Outdated
Comment thread pkg/sessionctx/vardef/runtime_test.go Outdated
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
@tangenta

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Aug 18, 2025

Copy link
Copy Markdown

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

Details

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.

Comment thread pkg/disttask/framework/storage/nodes.go
Comment thread pkg/disttask/framework/scheduler/autoscaler.go Outdated
Comment thread pkg/executor/importer/import.go Outdated
@D3Hunter D3Hunter changed the title ddl: calculate max_node_count and concurrency for next-gen automatically dxf: calculate max_node_count and concurrency for next-gen automatically Aug 18, 2025
Signed-off-by: tangenta <tangenta@126.com>
Signed-off-by: tangenta <tangenta@126.com>
Comment thread pkg/disttask/framework/scheduler/autoscaler.go
return 4
}
concurrency := size / (25 * units.GiB)
concurrency = min(concurrency, int64(coresPerNode-1))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we don't need to minus 1, the 1 is already removed when starting the pod, the runtime.GOMAXPROCS API will return the cores usable to the pod, say a 8c machine, the pod and the runtime.GOMAXPROCS will return 7 already

Comment thread pkg/disttask/framework/scheduler/autoscaler_test.go
Comment thread pkg/disttask/framework/scheduler/autoscaler_test.go Outdated
Comment thread pkg/executor/importer/import.go
Comment thread pkg/disttask/framework/scheduler/autoscaler.go Outdated
@D3Hunter

Copy link
Copy Markdown
Contributor

and please finish the TBD in manual test part

Signed-off-by: tangenta <tangenta@126.com>
@wuhuizuo wuhuizuo changed the title dxf: calculate max_node_count and concurrency for next-gen automatically | tidb-test=pull/2584 dxf: calculate max_node_count and concurrency for next-gen automatically | tidb-test=pr/2584 Aug 22, 2025
@wuhuizuo

Copy link
Copy Markdown
Contributor

/test pull-mysql-client-test-next-gen pull-mysql-client-test

@tiprow

tiprow Bot commented Aug 22, 2025

Copy link
Copy Markdown

@wuhuizuo: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

Details

In response to this:

/test pull-mysql-client-test-next-gen pull-mysql-client-test

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.

@wuhuizuo

Copy link
Copy Markdown
Contributor

/test pull-mysql-client-test

@tiprow

tiprow Bot commented Aug 22, 2025

Copy link
Copy Markdown

@wuhuizuo: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

Details

In response to this:

/test pull-mysql-client-test

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.

Signed-off-by: tangenta <tangenta@126.com>
@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

2 similar comments
@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

Signed-off-by: tangenta <tangenta@126.com>
@tangenta

Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

Signed-off-by: tangenta <tangenta@126.com>
@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

5 similar comments
@tangenta

Copy link
Copy Markdown
Contributor Author

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@ti-chi-bot ti-chi-bot Bot merged commit aa875ea into pingcap:master Aug 22, 2025
31 checks passed
@D3Hunter

D3Hunter commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

/cherry-pick release-nextgen-20250815

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 2, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-20250815: #63347.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-20250815

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm ok-to-test Indicates a PR is ready to be tested. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants