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

[WIP] coprocessor: separate thread for encoding data for batch cop #5349

Closed
wants to merge 1 commit into from

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Jul 11, 2022

Signed-off-by: JaySon-Huang [email protected]

What problem does this PR solve?

Issue Number: close #4415

Problem Summary:

What is changed and how it works?


TPC-H sf=10

Time(s) Original Optimized
Q1 TBD TBD
Q2 TBD TBD
-- disable mpp, enable batch cop
set tidb_allow_mpp=0;set tidb_isolation_read_engines="tiflash"; explain analyze /*PLACEHOLDER*/ select     l_returnflag,     l_linestatus,     sum(l_quantity) as sum_qty,     sum(l_extendedprice) as sum_base_price,     sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,     sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,     avg(l_quantity) as avg_qty,     avg(l_extendedprice) as avg_price,     avg(l_discount) as avg_disc,     count(*) as count_order from     lineitem where     l_shipdate <= date_sub('1998-12-01', interval 108 day) group by     l_returnflag,     l_linestatus order by     l_returnflag,     l_linestatus;
+--------------------------------+-------------+----------+-------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+
| id                             | estRows     | actRows  | task              | access object  | execution info                                                                                                                                                                                                                                                                                                                                                    | operator info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | memory   | disk    |
+--------------------------------+-------------+----------+-------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+
| Sort_6                         | 2.98        | 4        | root              |                | time:1.98s, loops:2                                                                                                                                                                                                                                                                                                                                               | test.lineitem.l_returnflag, test.lineitem.l_linestatus                                                                                                                                                                                                                                                                                                                                                                                                                                                               | 34.3 KB  | 0 Bytes |
| └─Projection_8                 | 2.98        | 4        | root              |                | time:1.98s, loops:4, Concurrency:OFF                                                                                                                                                                                                                                                                                                                              | test.lineitem.l_returnflag, test.lineitem.l_linestatus, Column#19, Column#20, Column#21, Column#22, Column#23, Column#24, Column#25, Column#26                                                                                                                                                                                                                                                                                                                                                                       | 11.4 KB  | N/A     |
|   └─HashAgg_14                 | 2.98        | 4        | root              |                | time:1.98s, loops:4, partial_worker:{wall_time:1.98287475s, concurrency:5, task_num:1, tot_wait:9.913951777s, tot_exec:54.456µs, tot_time:9.914021331s, max:1.982838083s, p95:1.982838083s}, final_worker:{wall_time:1.982955868s, concurrency:5, task_num:3, tot_wait:9.914271152s, tot_exec:207.259µs, tot_time:9.914483773s, max:1.98293307s, p95:1.98293307s} | group by:test.lineitem.l_linestatus, test.lineitem.l_returnflag, funcs:sum(Column#27)->Column#19, funcs:sum(Column#28)->Column#20, funcs:sum(Column#29)->Column#21, funcs:sum(Column#30)->Column#22, funcs:avg(Column#31, Column#32)->Column#23, funcs:avg(Column#33, Column#34)->Column#24, funcs:avg(Column#35, Column#36)->Column#25, funcs:count(Column#37)->Column#26, funcs:firstrow(test.lineitem.l_returnflag)->test.lineitem.l_returnflag, funcs:firstrow(test.lineitem.l_linestatus)->test.lineitem.l_l... | 129.5 KB | N/A     |
|     └─TableReader_15           | 2.98        | 4        | root              |                | time:1.98s, loops:2, cop_task: {num: 1, max: 0s, proc_keys: 0, copr_cache_hit_ratio: 0.00}                                                                                                                                                                                                                                                                        | data:HashAgg_9                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | 1.54 KB  | N/A     |
|       └─HashAgg_9              | 2.98        | 4        | batchCop[tiflash] |                | tiflash_task:{time:1.97s, loops:256, threads:1}                                                                                                                                                                                                                                                                                                                   | group by:Column#50, Column#51, funcs:sum(Column#40)->Column#27, funcs:sum(Column#41)->Column#28, funcs:sum(Column#42)->Column#29, funcs:sum(Column#43)->Column#30, funcs:count(Column#44)->Column#31, funcs:sum(Column#45)->Column#32, funcs:count(Column#46)->Column#33, funcs:sum(Column#47)->Column#34, funcs:count(Column#48)->Column#35, funcs:sum(Column#49)->Column#36, funcs:count(1)->Column#37                                                                                                             | N/A      | N/A     |
|         └─Projection_20        | 59513965.06 | 58773499 | batchCop[tiflash] |                | tiflash_task:{time:1.62s, loops:943, threads:20}                                                                                                                                                                                                                                                                                                                  | test.lineitem.l_quantity, test.lineitem.l_extendedprice, mul(test.lineitem.l_extendedprice, minus(1, test.lineitem.l_discount))->Column#42, mul(mul(test.lineitem.l_extendedprice, minus(1, test.lineitem.l_discount)), plus(1, test.lineitem.l_tax))->Column#43, test.lineitem.l_quantity, test.lineitem.l_quantity, test.lineitem.l_extendedprice, test.lineitem.l_extendedprice, test.lineitem.l_discount, test.lineitem.l_discount, test.lineitem.l_returnflag, test.lineitem.l_linestatus                       | N/A      | N/A     |
|           └─Selection_13       | 59513965.06 | 58773499 | batchCop[tiflash] |                | tiflash_task:{time:797.5ms, loops:943, threads:20}                                                                                                                                                                                                                                                                                                                | le(test.lineitem.l_shipdate, 1998-08-15 00:00:00.000000)                                                                                                                                                                                                                                                                                                                                                                                                                                                             | N/A      | N/A     |
|             └─TableFullScan_12 | 60363016.00 | 60166770 | batchCop[tiflash] | table:lineitem | tiflash_task:{time:654.5ms, loops:943, threads:20}                                                                                                                                                                                                                                                                                                                | keep order:false                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | N/A      | N/A     |
+--------------------------------+-------------+----------+-------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

None

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 11, 2022
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 11, 2022

Coverage for changed files

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DAGContext.cpp                    117                81    30.77%          26                13    50.00%         181               115    36.46%          74                58    21.62%
DAGDriver.cpp                     112               112     0.00%           5                 5     0.00%         152               152     0.00%          46                46     0.00%
DAGStorageInterpreter.cpp         436               436     0.00%          32                32     0.00%         884               884     0.00%         290               290     0.00%
StreamWriter.cpp                  136               136     0.00%          10                10     0.00%         115               115     0.00%          48                48     0.00%
StreamWriter.h                      8                 8     0.00%           8                 8     0.00%          23                23     0.00%           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                             809               773     4.45%          81                68    16.05%        1355              1289     4.87%         458               442     3.49%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18522      9582             48.27%    208831  96490        53.80%

full coverage report (for internal network access only)

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 11, 2022

Coverage for changed files

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DAGContext.cpp                    117                81    30.77%          26                13    50.00%         181               115    36.46%          74                58    21.62%
DAGDriver.cpp                     112               112     0.00%           5                 5     0.00%         152               152     0.00%          46                46     0.00%
DAGStorageInterpreter.cpp         436               436     0.00%          32                32     0.00%         884               884     0.00%         290               290     0.00%
StreamWriter.cpp                  136               136     0.00%          10                10     0.00%         115               115     0.00%          48                48     0.00%
StreamWriter.h                      8                 8     0.00%           8                 8     0.00%          23                23     0.00%           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                             809               773     4.45%          81                68    16.05%        1355              1289     4.87%         458               442     3.49%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18522      9582             48.27%    208831  96510        53.79%

full coverage report (for internal network access only)

@JaySon-Huang
Copy link
Contributor Author

/run-integration-test

@JaySon-Huang
Copy link
Contributor Author

TODO: consider using SyncTunnelSender introduced in #5286 ?

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2022
@ti-chi-bot
Copy link
Member

@JaySon-Huang: PR needs rebase.

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.

@JaySon-Huang JaySon-Huang deleted the batch_cop_encode branch August 19, 2023 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

batchCop writes data to TiDB just using one thread.
3 participants