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

Optimize expression LIKE() ESCAPE() for bin collator #5489

Merged
merged 3 commits into from
Aug 2, 2022

Conversation

solotzg
Copy link
Contributor

@solotzg solotzg commented Jul 28, 2022

What problem does this PR solve?

Issue Number: ref #5294

Problem Summary:

What is changed and how it works?

  • batch match str and optimize code

Benchmark

ENV:

  • tpch100
  • 1 tiflash
  • limit cpu up to 200%
  • original commit: a476307

SQL: subquery like tpch-q13

select count(1) from orders where o_comment like '%pending%deposits%';
Time(s) Original Optimized     Improvement
  35.77 11      
  33.84 10.88      
  35.32 11.11      
  34.82 11.21      
  34.94 10.97     AVG(Original) / AVG(Optimized) - 1.0
AVG 34.938 11.034   Optimized : Original 216.64%

TODO

  • seachers like ASCIICaseSensitiveStringSearcher or Volnitsky are too heavy for small str
  • Aho–Corasick algorithm is NOT friendly for cache locality.
  • Need to optimize strstr search by simd in next pull request.

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

@solotzg solotzg added type/enhancement The issue or PR belongs to an enhancement. type/performance labels Jul 28, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 28, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • windtalker
  • zanmato1984

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 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 Jul 28, 2022
@solotzg
Copy link
Contributor Author

solotzg commented Jul 28, 2022

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 28, 2022

Coverage for changed files

Filename                                               Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Functions/CollationOperatorOptimized.h                      26                 8    69.23%           6                 1    83.33%          99                33    66.67%          16                 6    62.50%
Functions/CollationStringSearchOptimized.h                 141                 3    97.87%          20                 0   100.00%         302                 5    98.34%          84                 2    97.62%
Functions/FunctionsStringSearch.cpp                        645               344    46.67%          57                30    47.37%        1315               691    47.45%         410               223    45.61%
Storages/Transaction/Collator.cpp                          188                38    79.79%          32                 5    84.38%         411                96    76.64%         162                57    64.81%
Storages/Transaction/tests/gtest_tidb_collator.cpp         128                18    85.94%           6                 0   100.00%          91                 0   100.00%          50                19    62.00%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                     1128               411    63.56%         121                36    70.25%        2218               825    62.80%         722               307    57.48%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18848      9438             49.93%    215030  95427        55.62%

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 2, 2022
Copy link
Contributor

@zanmato1984 zanmato1984 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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 2, 2022
@solotzg
Copy link
Contributor Author

solotzg commented Aug 2, 2022

/merge

@ti-chi-bot
Copy link
Member

@solotzg: 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: 4141e41

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

solotzg commented Aug 2, 2022

/rebuild

@solotzg
Copy link
Contributor Author

solotzg commented Aug 2, 2022

/run-integration-test

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 2, 2022

Coverage for changed files

Filename                                               Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Functions/CollationOperatorOptimized.h                      26                 8    69.23%           6                 1    83.33%          99                33    66.67%          16                 6    62.50%
Functions/CollationStringSearchOptimized.h                 141                 3    97.87%          20                 0   100.00%         302                 5    98.34%          84                 2    97.62%
Functions/FunctionsStringSearch.cpp                        645               344    46.67%          57                30    47.37%        1315               691    47.45%         410               223    45.61%
Storages/Transaction/Collator.cpp                          188                38    79.79%          32                 5    84.38%         411                96    76.64%         162                57    64.81%
Storages/Transaction/tests/gtest_tidb_collator.cpp          23                 0   100.00%           6                 0   100.00%          91                 0   100.00%          14                 1    92.86%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                     1023               393    61.58%         121                36    70.25%        2218               825    62.80%         686               289    57.87%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18945      9439             50.18%    214237  95359        55.49%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 30fc64c into pingcap:master Aug 2, 2022
@solotzg solotzg deleted the optimize-like branch August 2, 2022 09:02
solotzg added a commit to solotzg/tiflash that referenced this pull request Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement. type/performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants