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

Improve performance of number comparison functions #5670

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Aug 22, 2022

What problem does this PR solve?

Issue Number: ref #5672

Problem Summary:

What is changed and how it works?

using dynamic dispatch
port from ClickHouse/ClickHouse#37399

Check List

Tests

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

Result

--before
mysql > select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from CUSTOMER, ORDERS, LINEITEM where o_orderkey in (         select l_orderkey         from LINEITEM
  group by l_orderkey         having sum(l_quantity) > 314     )     and c_custkey = o_custkey     and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100;
+--------------------+-----------+------------+-------------+--------------+-----------------+
| c_name             | c_custkey | o_orderkey | o_orderdate | o_totalprice | sum(l_quantity) |
+--------------------+-----------+------------+-------------+--------------+-----------------+
| Customer#000128120 |    128120 |    4722021 | 1994-04-07  |    544089.09 |          323.00 |
| Customer#000144617 |    144617 |    3043270 | 1997-02-12  |    530604.44 |          317.00 |
| Customer#000066790 |     66790 |    2199712 | 1996-09-30  |    515531.82 |          327.00 |
| Customer#000015619 |     15619 |    3767271 | 1996-08-07  |    480083.96 |          318.00 |
| Customer#000147197 |    147197 |    1263015 | 1997-02-02  |    467149.67 |          320.00 |
| Customer#000117919 |    117919 |    2869152 | 1996-06-20  |    456815.92 |          317.00 |
| Customer#000126865 |    126865 |    4702759 | 1994-11-07  |    447606.65 |          320.00 |
| Customer#000036619 |     36619 |    4806726 | 1995-01-17  |    446704.09 |          328.00 |
| Customer#000119989 |    119989 |    1544643 | 1997-09-20  |    434568.25 |          320.00 |
+--------------------+-----------+------------+-------------+--------------+-----------------+
9 rows in set (4.40 sec)

-- after 
mysql > select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from CUSTOMER, ORDERS, LINEITEM where o_orderkey in (         select l_orderkey         from LINEITEM
  group by l_orderkey         having sum(l_quantity) > 314     )     and c_custkey = o_custkey     and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100;
+--------------------+-----------+------------+-------------+--------------+-----------------+
| c_name             | c_custkey | o_orderkey | o_orderdate | o_totalprice | sum(l_quantity) |
+--------------------+-----------+------------+-------------+--------------+-----------------+
| Customer#000128120 |    128120 |    4722021 | 1994-04-07  |    544089.09 |          323.00 |
| Customer#000144617 |    144617 |    3043270 | 1997-02-12  |    530604.44 |          317.00 |
| Customer#000066790 |     66790 |    2199712 | 1996-09-30  |    515531.82 |          327.00 |
| Customer#000015619 |     15619 |    3767271 | 1996-08-07  |    480083.96 |          318.00 |
| Customer#000147197 |    147197 |    1263015 | 1997-02-02  |    467149.67 |          320.00 |
| Customer#000117919 |    117919 |    2869152 | 1996-06-20  |    456815.92 |          317.00 |
| Customer#000126865 |    126865 |    4702759 | 1994-11-07  |    447606.65 |          320.00 |
| Customer#000036619 |     36619 |    4806726 | 1995-01-17  |    446704.09 |          328.00 |
| Customer#000119989 |    119989 |    1544643 | 1997-09-20  |    434568.25 |          320.00 |
+--------------------+-----------+------------+-------------+--------------+-----------------+
9 rows in set (4.24 sec)

Release note

None

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • windtalker
  • ywqzzy

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/needs-linked-issue 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. labels Aug 22, 2022
@Lloyd-Pottiger Lloyd-Pottiger marked this pull request as draft August 22, 2022 10:31
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 22, 2022
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/needs-linked-issue labels Aug 23, 2022
@Lloyd-Pottiger Lloyd-Pottiger marked this pull request as ready for review August 23, 2022 03:38
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 23, 2022
@Lloyd-Pottiger
Copy link
Contributor Author

/cc @solotzg @windtalker @ywqzzy

@ywqzzy
Copy link
Contributor

ywqzzy commented Aug 23, 2022

A solid bench is needed

@Lloyd-Pottiger
Copy link
Contributor Author

Running ./dbms/bench_dbms
Run on (40 X 2399.94 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x20)
  L1 Instruction 32 KiB (x20)
  L2 Unified 256 KiB (x20)
  L3 Unified 25600 KiB (x2)
Load Average: 48.56, 24.48, 23.63
# before
--------------------------------------------------------------------------------------------------
Benchmark                                                        Time             CPU   Iterations
--------------------------------------------------------------------------------------------------
NumberComparsionBench/constantEqVector/iterations:100        95193 ns        95195 ns          100
NumberComparsionBench/vectorEqVector/iterations:100         112950 ns       112955 ns          100
NumberComparsionBench/constantLessVector/iterations:100     104847 ns       104850 ns          100
NumberComparsionBench/vectorLessVector/iterations:100       112402 ns       112410 ns          100
# after
--------------------------------------------------------------------------------------------------
Benchmark                                                        Time             CPU   Iterations
--------------------------------------------------------------------------------------------------
NumberComparsionBench/constantEqVector/iterations:100        60521 ns        60521 ns          100
NumberComparsionBench/vectorEqVector/iterations:100          63688 ns        63687 ns          100
NumberComparsionBench/constantLessVector/iterations:100      58405 ns        58405 ns          100
NumberComparsionBench/vectorLessVector/iterations:100        64027 ns        64028 ns          100

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 23, 2022
@Lloyd-Pottiger
Copy link
Contributor Author

change the row_num = 10000000

# before
--------------------------------------------------------------------------------------------------
Benchmark                                                        Time             CPU   Iterations
--------------------------------------------------------------------------------------------------
NumberComparsionBench/constantEqVector/iterations:100     10734751 ns     10734228 ns          100
NumberComparsionBench/vectorEqVector/iterations:100       19793874 ns     19791053 ns          100
NumberComparsionBench/constantLessVector/iterations:100   11959062 ns     11947725 ns          100
NumberComparsionBench/vectorLessVector/iterations:100     19011253 ns     19001708 ns          100
# after
--------------------------------------------------------------------------------------------------
Benchmark                                                        Time             CPU   Iterations
--------------------------------------------------------------------------------------------------
NumberComparsionBench/constantEqVector/iterations:100      8810097 ns      8810259 ns          100
NumberComparsionBench/vectorEqVector/iterations:100       16357388 ns     16312559 ns          100
NumberComparsionBench/constantLessVector/iterations:100    9277899 ns      9278057 ns          100
NumberComparsionBench/vectorLessVector/iterations:100     15475154 ns     15475493 ns          100

@Lloyd-Pottiger
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 30, 2022

Coverage for changed files

Filename                                                                                                Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins/agent/workspace/tiflash-build-common/tiflash/dbms/src/Functions/FunctionsComparison.h         600               304    49.33%          63                29    53.97%         929               509    45.21%         472               284    39.83%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                       600               304    49.33%          63                29    53.97%         929               509    45.21%         472               284    39.83%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18384      8350             54.58%    211825  86274        59.27%

full coverage report (for internal network access only)

@Lloyd-Pottiger
Copy link
Contributor Author

/run-integration-test

@Lloyd-Pottiger
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 30, 2022

Coverage for changed files

Filename                                                                                                Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins/agent/workspace/tiflash-build-common/tiflash/dbms/src/Functions/FunctionsComparison.h         600               301    49.83%          63                28    55.56%         929               502    45.96%         472               285    39.62%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                       600               301    49.83%          63                28    55.56%         929               502    45.96%         472               285    39.62%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18479      8324             54.95%    213784  85949        59.80%

full coverage report (for internal network access only)

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 30, 2022
Copy link
Contributor

@ywqzzy ywqzzy left a comment

Choose a reason for hiding this comment

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

Excellent

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 30, 2022
@Lloyd-Pottiger
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@Lloyd-Pottiger: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: fe5a350

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 30, 2022
@ti-chi-bot
Copy link
Member

@Lloyd-Pottiger: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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.

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 30, 2022

Coverage for changed files

Filename                                                                                                Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins/agent/workspace/tiflash-build-common/tiflash/dbms/src/Functions/FunctionsComparison.h         600               304    49.33%          63                28    55.56%         929               505    45.64%         472               288    38.98%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                       600               304    49.33%          63                28    55.56%         929               505    45.64%         472               288    38.98%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18475      8322             54.96%    213709  85879        59.81%

full coverage report (for internal network access only)

@Lloyd-Pottiger
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@Lloyd-Pottiger: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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.

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 30, 2022

Coverage for changed files

Filename                                                                                                Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins/agent/workspace/tiflash-build-common/tiflash/dbms/src/Functions/FunctionsComparison.h         600               301    49.83%          63                28    55.56%         929               502    45.96%         472               291    38.35%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                       600               301    49.83%          63                28    55.56%         929               502    45.96%         472               291    38.35%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18475      8321             54.96%    213709  85906        59.80%

full coverage report (for internal network access only)

@Lloyd-Pottiger
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@Lloyd-Pottiger: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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.

@Lloyd-Pottiger
Copy link
Contributor Author

/build

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 31, 2022

Coverage for changed files

Filename                                                                                                Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins/agent/workspace/tiflash-build-common/tiflash/dbms/src/Functions/FunctionsComparison.h         600               301    49.83%          63                28    55.56%         929               502    45.96%         472               289    38.77%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                       600               301    49.83%          63                28    55.56%         929               502    45.96%         472               289    38.77%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18475      8323             54.95%    213709  85943        59.79%

full coverage report (for internal network access only)

@Lloyd-Pottiger
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@Lloyd-Pottiger: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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.

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 31, 2022

Coverage for changed files

Filename                                                                                                Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins/agent/workspace/tiflash-build-common/tiflash/dbms/src/Functions/FunctionsComparison.h         600               301    49.83%          63                28    55.56%         929               502    45.96%         472               284    39.83%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                       600               301    49.83%          63                28    55.56%         929               502    45.96%         472               284    39.83%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18475      8321             54.96%    213709  85908        59.80%

full coverage report (for internal network access only)

@Lloyd-Pottiger
Copy link
Contributor Author

/hold

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 31, 2022
@Lloyd-Pottiger
Copy link
Contributor Author

merge into #5748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants