Skip to content

executor: tiny optimize import into from select performance - #60384

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
crazycs520:refine-import-chunk
Apr 22, 2025
Merged

ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
crazycs520:refine-import-chunk

Conversation

@crazycs520

@crazycs520 crazycs520 commented Apr 2, 2025 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #60377

Problem Summary: tiny optimize import into from select performance

What changed and how does it work?

Tiny fix for better pipeline.

Manual test:

  1. prepare:
sysbench --config-file=sysbench.conf oltp_point_select --tables=2 --table-size=10000 --threads=2 prepare

CREATE TABLE `t` (
  `id` int(11) NOT NULL,
  `k` int(11) NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  `pad` char(60) NOT NULL DEFAULT '',
  `id2` int(11) NOT NULL,
  `k2` int(11) NOT NULL DEFAULT '0',
  `c2` char(120) NOT NULL DEFAULT '',
  `pad2` char(60) NOT NULL DEFAULT '',
  KEY `k_1` (`k`)
);

Before:

> import into t from select * from sbtest1 join sbtest2 where sbtest2.id <=2000 with thread=16,DISABLE_PRECHECK;
Query OK, 20000000 rows affected
Time: 94.425s

related tidb log:

[2025/04/03 01:24:12.759 +08:00] [INFO] [chunk_process.go:334] ["process chunk completed"] [table=t] [import-id=431840f5-f697-4b3b-8093-e8dcb329d77a] [key=import-from-select] [readDur=43.395559463s] [encodeDur=9.013400878s] [checksum="{cksum=1539544195137435216,size=563438023,kvs=2499458}"] [deliverDur=1.608033096s] [type=query] [takeTime=53.673599639s] []

The readDur has 43.39s.

[readDur=43.395559463s] [encodeDur=9.013400878s] [checksum="{cksum=1539544195137435216,size=563438023,kvs=2499458}"] [deliverDur=1.608033096s] [type=query] [takeTime=53.673599639s] 

This PR:

> import into t from select * from sbtest1 join sbtest2 where sbtest2.id <=2000 with thread=16,DISABLE_PRECHECK;
Query OK, 20000000 rows affected
Time: 59.718s

related tidb log:

[2025/04/03 01:26:32.376 +08:00] [INFO] [chunk_process.go:361] ["process chunk completed"] [table=t] [import-id=6bee0397-56b5-4e8b-9383-43f5e8593f22] [key=import-from-select] [readDur=6.501533276s] [encodeDur=9.75518629s] [checksum="{cksum=4058046773982146946,size=564270116,kvs=2503168}"] [deliverDur=1.788105169s] [type=query] [takeTime=18.361915694s] []

The readDur only has 6.5s.

[readDur=6.501533276s] [encodeDur=9.75518629s] [checksum="{cksum=4058046773982146946,size=564270116,kvs=2503168}"] [deliverDur=1.788105169s] [type=query] [takeTime=18.361915694s]

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

@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 2, 2025
@sre-bot

sre-bot commented Apr 2, 2025 •

Copy link
Copy Markdown
Contributor

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 2, 2025
@tiprow

tiprow Bot commented Apr 2, 2025

Copy link
Copy Markdown

Hi @crazycs520. 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 Apr 2, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 62.16216% with 14 lines in your changes missing coverage. Please review.

Project coverage is 74.7785%. Comparing base (3cdb05c) to head (50cbc5e).
Report is 4 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60384        +/-   ##
================================================
+ Coverage   73.1122%   74.7785%   +1.6662%     
================================================
  Files          1716       1732        +16     
  Lines        475637     475984       +347     
================================================
+ Hits         347749     355934      +8185     
+ Misses       106491      98105      -8386     
- Partials      21397      21945       +548     
Flag Coverage Δ
integration 46.0874% <0.0000%> (?)
unit 72.5020% <62.1621%> (+0.1760%) ⬆️

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

Components Coverage Δ
dumpling 52.6553% <ø> (ø)
parser ∅ <ø> (∅)
br 62.1958% <ø> (+14.7662%) ⬆️
🚀 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 D3Hunter left a comment

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.

will send by chunk make performance worse if the data-set is small?

@crazycs520

Copy link
Copy Markdown
Contributor Author

will send by chunk make performance worse if the data-set is small?

I'm not sure what small data-set you mean, 10000 rows? If it's too small, I don't feel like it's making much difference.

IMO, import into is usually used in cases where the amount of data is relatively large.

@crazycs520

Copy link
Copy Markdown
Contributor Author

/test check-dev2

@tiprow

tiprow Bot commented Apr 17, 2025

Copy link
Copy Markdown

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

Details

In response to this:

/test check-dev2

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.

@D3Hunter D3Hunter left a comment

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.

rest lgtm

Comment thread pkg/executor/importer/chunk_process.go Outdated
Comment thread pkg/executor/importer/chunk_process.go Outdated
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 22, 2025
@ti-chi-bot

ti-chi-bot Bot commented Apr 22, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716

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

The pull request process is described here

Details 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 22, 2025
@lance6716

Copy link
Copy Markdown
Contributor

/retest

@ti-chi-bot

ti-chi-bot Bot commented Apr 22, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-04-22 04:57:33.24573833 +0000 UTC m=+331597.057528712: ☑️ agreed by D3Hunter.
  • 2025-04-22 06:03:41.177123156 +0000 UTC m=+335564.988913537: ☑️ agreed by lance6716.

…chunk

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520
crazycs520 force-pushed the refine-import-chunk branch from 0e89934 to 50cbc5e Compare April 22, 2025 06:08
@crazycs520

Copy link
Copy Markdown
Contributor Author

/retest-required

1 similar comment
@crazycs520

Copy link
Copy Markdown
Contributor Author

/retest-required

@ti-chi-bot
ti-chi-bot Bot merged commit 23e5a09 into pingcap:master Apr 22, 2025
@ti-chi-bot ti-chi-bot Bot added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Aug 3, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #70287.
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants