Repository navigation
executor: tiny optimize import into from select performance - #60378
crazycs520 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
crazycs520 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Hi @crazycs520. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions 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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #60378 +/- ##
================================================
+ Coverage 73.1433% 73.5424% +0.3991%
================================================
Files 1710 1710
Lines 472848 472894 +46
================================================
+ Hits 345857 347778 +1921
+ Misses 105725 103850 -1875
Partials 21266 21266
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@crazycs520: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
| fields := exec.RetTypes(e.selectExec) | ||
| var idAllocator int64 | ||
| chkSize := e.selectExec.InitCap() | ||
| maxChkSize := e.selectExec.MaxChunkSize() |
There was a problem hiding this comment.
what's the value of MaxChunkSize?
There was a problem hiding this comment.
It is the value of tidb_max_chunk_size, by default the value is 1024.
D3Hunter
left a comment
There was a problem hiding this comment.
rest lgtm
can you also consider this opt direction #60377 (comment)
|
Please add the necessary test cases. |
|
/hold |
| } | ||
| }() | ||
| selectedRowCh := make(chan importer.QueryRow) | ||
| selectedRowCh := make(chan importer.QueryRow, e.MaxChunkSize()) |
There was a problem hiding this comment.
does the optimization comes from enlarge the channel, or enlarge the below chunk?
in most cases, unbuffered channel is enough
There was a problem hiding this comment.
I prefer to set the channel capacity to worker count * worker batch size. So if the average speed of producer (SELECT side) is larger than consumer (encode worker side) the worker will never be blocked
There was a problem hiding this comment.
Only enlarge chunk size
> 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.532s
[2025/04/02 21:36:16.306 +08:00] [INFO] [chunk_process.go:334] ["process chunk completed"] [table=t] [import-id=97bba291-a9f1-407d-a695-d7bf395664bf] [key=import-from-select] [readDur=44.168811199s] [encodeDur=9.422960425s] [checksum="{cksum=12542963264396444897,size=561438104,kvs=2490588}"] [deliverDur=1.536865319s] [type=query] [takeTime=54.887474621s] []
master
> import into t from select * from sbtest1 join sbtest2 where sbtest2.id <=2000 with thread=16,DISABLE_PRECHECK;
Query OK, 20000000 rows affected
Time: 96.610s
[2025/04/02 21:38:56.446 +08:00] [INFO] [chunk_process.go:334] ["process chunk completed"] [table=t] [import-id=a5ac398c-ebaa-4711-8887-52138fe490c2] [key=import-from-select] [readDur=46.095255199s] [encodeDur=9.143337612s] [checksum="{cksum=4793880330072286733,size=563626556,kvs=2500296}"] [deliverDur=1.546770509s] [type=query] [takeTime=56.509829908s] []
This PR, enlarge the channel and enlarge the chunk size?:
> import into t from select * from sbtest1 join sbtest2 where sbtest2.id <=2000 with thread=16,DISABLE_PRECHECK;
Query OK, 20000000 rows affected
Time: 65.959s[2025/04/02 21:42:58.107 +08:00] [INFO] [chunk_process.go:334] ["process chunk completed"] [table=t] [import-id=8cc33018-c79a-4b42-a133-d3f86bb45201] [key=import-from-select] [readDur=16.859098986s] [encodeDur=7.161220248s] [checksum="{cksum=4348892783063240861,size=564394376,kvs=2503700}"] [deliverDur=1.613289223s] [type=query] [takeTime=25.343078567s] []
see #60377 (comment) |
|
#60384 is much better than this. |
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:
Before:
related tidb log:
This PR:
related tidb log:
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.